To change a user’s password in Linux, you can use the passwd
command. Here’s a step-by-step guide on how to do it:
1. Change Your Own Password:
If you’re changing your own password, follow these steps:
- Open a terminal.
- Type the following command and press Enter:
passwd
- You will be prompted to enter your current password.
- After entering your current password, you’ll be prompted to enter a new password.
- Enter the new password and press Enter.
- You will be asked to retype the new password for confirmation.
- If the new password meets the system’s requirements (e.g., length, complexity), it will be updated.
2. Change Another User’s Password (as a Root or Sudo User):
If you’re an administrator and need to change another user’s password, use the following steps:
- Open a terminal.
- Type the following command, replacing
username
with the target user’s username:sudo passwd username
- You will be prompted to enter your own password (if using
sudo
). - After that, you’ll be asked to enter the new password for the specified user.
- Enter the new password and press Enter.
- You will be asked to retype the new password for confirmation.
- If the password meets the system requirements, it will be updated.
3. Tips:
- Ensure the new password is strong, typically containing a mix of uppercase letters, lowercase letters, numbers, and special characters.
- If you see a “password strength” prompt, it means your system has password complexity policies in place.
That’s it! The passwd
command is a simple and effective way to change passwords in Linux.