If you want to change the password of the current user that you are logged into the Mac using Terminal then you can make use of the security set-keychain-password command.
Steps to Change Current User Password Using Mac Terminal:
- Open Terminal App,
- Now type the command: security set-keychain-password
- Enter the old password.
- Enter new password.
- Re-Enter new password.

% security set-keychain-password
Old Password:
New Password:
Retype New Password:
Note: The command sudo passwd <user-name> will not work to change the current user password, you would see this warning.
% sudo passwd code2care
Password:
Changing password for code2care.
Old password:
New password:
################################### WARNING ###################################
# This tool does not update the login keychain password. #
# To update it, run `security set-keychain-password` as the user in question, #
# or as root providing a path to such user's login keychain. #
###############################################################################
This is not an AI-generated article but is demonstrated by a human on an M1 Mac running macOS Sonoma 14.0.
Please support independent contributors like Code2care by donating a coffee.
Buy me a coffee!

Comments & Discussion
Facing issues? Have questions? Post them here! We're happy to help!