Skip to content

passwd MacOS command

The MacOS passwd command allows users to change their account password easily and securely. By using this command, users can update their password to enhance security and comply with password expiration policies. The passwd command provides a simple and effective way for MacOS users to manage their account passwords without hassle.

Terminal window
passwd [options] [username]
OptionDescription
-l, —lockLock the password of the specified account
-u, —unlockUnlock the password of the specified account
-d, —deleteDelete the password of the specified account
-e, —expireForce the specified account to change their password upon next login
-h, —helpDisplay help message
ParameterDescription
usernameThe username of the account for which the password should be changed or modified
Terminal window
passwd

This command allows the current user to change their own password.

Change Another User’s Password (Requires Root Privileges)

Section titled “Change Another User’s Password (Requires Root Privileges)”
Terminal window
sudo passwd username

Using sudo with passwd allows the root user to change another user’s password.

Terminal window
sudo passwd -e username

Setting an expiration date for a user’s password can be done with the “-e” option.

Terminal window
sudo passwd -l username

Lock a user’s account temporarily to prevent them from logging in.

Terminal window
sudo passwd -u username

After locking a user’s account, it can be unlocked again using the “-u” option.

To use the passwd command in bash, execute the following command:

Terminal window
passwd

How to change the password for a specific user in MacOS?

Section titled “How to change the password for a specific user in MacOS?”

To change the password for a specific user in MacOS, use the passwd command followed by the username you want to change the password for:

Terminal window
passwd username

How to force a user to change their password at the next login in MacOS?

Section titled “How to force a user to change their password at the next login in MacOS?”

To force a user to change their password at the next login in MacOS, use the -e option with the passwd command along with the username:

Terminal window
passwd -e username

How to display password status information in MacOS?

Section titled “How to display password status information in MacOS?”

To display password status information in MacOS, use the -S option with the passwd command:

Terminal window
passwd -S

How to change the password algorithm in MacOS?

Section titled “How to change the password algorithm in MacOS?”

To change the password algorithm in MacOS, use the -h option followed by the desired algorithm with the passwd command:

Terminal window
passwd -h algorithm

How to lock a user account in MacOS using passwd?

Section titled “How to lock a user account in MacOS using passwd?”

To lock a user account in MacOS using passwd, you can use the -l option followed by the username:

Terminal window
passwd -l username

How to unlock a locked user account in MacOS using passwd?

Section titled “How to unlock a locked user account in MacOS using passwd?”

To unlock a locked user account in MacOS using passwd, you can use the -u option followed by the username:

Terminal window
passwd -u username

How to set a maximum number of days before a password change is required in MacOS?

Section titled “How to set a maximum number of days before a password change is required in MacOS?”

To set a maximum number of days before a password change is required in MacOS, use the -n option with the passwd command followed by the number of days:

Terminal window
passwd -n days
  • Change the user’s password
  • Update password aging information
  • Set password expiration information
  • Lock or unlock a user’s account