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:
- Open the terminal.
- Type the following command:
passwd
- Press Enter.
- You will be prompted to enter your old password. Type it and press Enter.
- 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.
- 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:
- Open the terminal.
- 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:
Make sure to omit the angle brackets (passwd <username> <new password>
<>
) when entering the actual username and password. - 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.