In the Linux operating system, users are assigned passwords to ensure security. To change a user’s password, the passwd command is used. In this guide, we will explore how to use the passwd command effectively.

Changing Your Password

If you want to change your own password, follow these steps:

  1. Open the terminal.
  2. Type the following command:
    passwd
    
  3. Press Enter.
  4. You will be prompted to enter your old password. Type it and press Enter.
  5. Next, you will be asked to enter a new password. Type the new password and press Enter. Note that as you type, no characters or asterisks will appear on the screen.
  6. Finally, you will be asked to re-enter the new password for confirmation. Type it again and press Enter.

Your password will be changed successfully.

Changing Another User’s Password (as root)

If you have superuser privileges (such as being the root user), you can also change the password for another user. Here’s how:

  1. Open the terminal.
  2. Type the following command, replacing <username> with the username of the user whose password you want to change, and <new password> with the new password you want to assign:
    passwd <username> <new password>
    
    Make sure to omit the angle brackets (<>) when entering the actual username and password.
  3. Press Enter.

The password for the specified user will be changed without requiring the old password.

Note: The passwd command can be used on Linux, macOS, WSL (Windows Subsystem for Linux), and any UNIX-like environment.

Tags: Linux, passwd, user password, change password, command line.