Skip to content

Click on each book below to review & buy on Amazon.

As an Amazon Associate, I earn from qualifying purchases.

CompTIA Linux+ XK0-005 - 2.2 - Account Management: passwd

In a Linux environment, managing user accounts is a critical aspect of identity management. The passwd command is a powerful utility that allows you to create and modify user account passwords. This guide will walk you through the process of using the passwd command for account management and explain some common options available.

Understanding passwd

The passwd command is used to manage user account passwords in Linux. It provides the following functionalities:

  • Password Creation: With passwd, you can set or change a user's password. It prompts you to enter and confirm the new password securely.

  • Password Policy: passwd enforces certain password policies, such as password length, complexity, and expiration. These policies are typically defined by the system administrator in configuration files.

  • Root Privileges: Changing another user's password requires root privileges. Only the root user or a user with sudo privileges can use passwd to modify passwords for other user accounts.

Using passwd for Account Management

Changing Your Own Password

To change your own password using passwd, follow these steps:

  • Run the following command:

  • You will be prompted to enter your current password. After entering it correctly, press Enter.

  • Next, enter your new password. As you type, the password characters will not be displayed on the screen.

  • Retype the new password when prompted to confirm it.

  • If the password change is successful, you will see a confirmation message.

Changing Another User's Password (with root privileges)

To change another user's password as the root user or with sudo privileges, use the following command:

sudo passwd <username>

Replace <username> with the actual username of the user whose password you want to change. Follow the same steps as mentioned above for changing your own password.

Common Options for passwd

Here are some common options that can be used with the passwd command:

  • -l, --lock: This option locks the specified user account by putting a "!" character in front of the encrypted password in the /etc/shadow file. It prevents the user from logging in with their password.

  • -u, --unlock: This option unlocks a previously locked user account by removing the "!" character from the encrypted password in the /etc/shadow file. It allows the user to log in again.

  • -e, --expire: This option forces the specified user to change their password during the next login. It sets the password expiration date to the current date, making the password expired.

  • -d, --delete: This option deletes the user's password, effectively disabling the account. The user will not be able to log in with a password but may still be able to log in using other authentication methods (such as SSH key-based authentication).


Managing user account passwords is an important aspect of identity management in Linux systems. The passwd command provides a convenient and secure way to create, modify, and enforce password policies for user accounts. By understanding the usage of passwd, including some common options, and following the steps outlined in this guide, you can effectively manage user passwords and ensure the security of your Linux system.

Support DTV Linux

Click on each book below to review & buy on Amazon. As an Amazon Associate, I earn from qualifying purchases.

NordVPN ®: Elevate your online privacy and security. Grab our Special Offer to safeguard your data on public Wi-Fi and secure your devices. I may earn a commission on purchases made through this link.