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.

passwd Syntax:

Terminal window
passwd [options] [username]

passwd Options:

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

Parameters:

ParameterDescription
usernameThe username of the account for which the password should be changed or modified

passwd Command Usage Examples:

Change Your Own Password

Terminal window
passwd

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

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.

Set Password Expiration for a User

Terminal window
sudo passwd -e username

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

Lock a User’s Account

Terminal window
sudo passwd -l username

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

Unlock a User’s Account

Terminal window
sudo passwd -u username

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

How do I use passwd in MacOS?

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?

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?

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?

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?

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?

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?

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?

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

Applications of the passwd command

  • Change the user’s password
  • Update password aging information
  • Set password expiration information
  • Lock or unlock a user’s account