The passwd command changes any user's password from the terminal
To change a password for a user account in Linux, you use the passwd command in the terminal. If you are changing your own password, type passwd and press Enter — the system will prompt you for your current password, then ask you to enter and confirm a new one. If you are an administrator changing another user's password, type passwd username (replacing "username" with the actual account name) and press Enter — you will not need the old password, only the new one twice.
The password change takes effect when ready. The next time that user logs in, they must use the new password. If you are changing your own password and remain logged in, you stay logged in — the new password applies only to future login attempts.
Key Takeaways
- Type passwd alone to change your own password; type passwd username to change another user's password if you have administrator rights.
- When changing your own password, you must know and enter your current password first.
- When an administrator changes a user's password, the old password is not needed, and the user must use the new password at their next login.
- The system will reject passwords that are too short or too similar to the username or previous passwords, depending on your Linux distribution's rules.
- You can force a user to change their password at next login by using passwd -e username if you have root or sudo access.
Changing your own password with passwd
Open a terminal window and type the command exactly as shown:
passwd
Press Enter. The terminal will display a prompt asking for your current password. Type it and press Enter — the characters will not appear on screen as you type, which is normal. If you enter the wrong password, the command will fail and you will see a message like "passwd: Authentication token manipulation error" or "passwd: password unchanged". Try again from the beginning.
If your current password is correct, the terminal will ask you to enter your new password. Type it carefully — again, you will not see the characters. Press Enter. The system will then ask you to re-enter the new password to confirm it matches. Type it again and press Enter. If both entries match, the password changes when ready and you will see a message like "passwd: password updated successfully".
Changing another user's password as root or with sudo
If you have administrator access (root or sudo privileges), you can change any user's password without knowing their current one. Open a terminal and type:
sudo passwd username
Replace "username" with the actual login name of the account whose password you want to change. Press Enter. The system will ask for your own password (your sudo password), not the target user's password. Enter it and press Enter.
The terminal will then prompt you to enter the new password for that user. Type it and press Enter. You will be asked to re-enter it to confirm. Once both entries match, the password is changed. The user will need to use this new password the next time they log in.
What happens if the password does not meet system requirements
Linux systems enforce password rules that vary by distribution. Common rules include minimum length (often 8 characters), a mix of uppercase and lowercase letters, numbers, or special characters, and a check that the password is not too similar to the username or previous passwords.
If your new password does not meet these rules, the passwd command will reject it and display a message explaining why — for example, "BAD PASSWORD: The password is shorter than 8 characters" or "BAD PASSWORD: The password is a palindrome". You will be prompted to enter a different password. Try a longer password with a mix of character types.
If you are an administrator and need to set a password that would normally be rejected, you can use sudo passwd -f username to force the change, though this bypasses the security checks and is not recommended for regular use.
Forcing a user to change their password at next login
If you are an administrator and want to require a user to change their password the next time they log in, use the -e flag:
sudo passwd -e username
This expires the user's current password when ready. When they log in next, the system will not allow them to proceed until they set a new password. This is useful when you have set a temporary password for a new account or suspect a password may have been compromised.
Troubleshooting common passwd errors
If you see "passwd: user 'username' does not exist", you have typed the username incorrectly or that account does not exist on this system. Double-check the spelling and try again. Use the id username command to verify the account exists.
If you see "passwd: Permission denied", you are trying to change another user's password without sudo or root access. Only administrators can change other users' passwords. If you need to change your own password, use passwd without a username.
If you see "passwd: Authentication token manipulation error" when changing your own password, your current password entry was wrong, or there is a file permission issue on the system. Try the command again and enter your current password carefully. If the error persists, contact your system administrator.
Using passwd with other options
The passwd command has additional flags for specific tasks. The -l flag locks an account, preventing login: sudo passwd -l username. The -u flag unlocks it: sudo passwd -u username. The -d flag removes a password entirely, allowing login without one: sudo passwd -d username — this is rarely used and creates a security risk.
You can view password expiration settings with sudo chage -l username, which shows when the password was last changed and when it will expire if your system has expiration rules enabled. Most home and small office systems do not use password expiration, but corporate environments often do.
Frequently Asked Questions
What if I forget my password and cannot log in?
You will need physical access to the machine or administrator help. If you have another administrator account on the system, log in with that account and use sudo passwd yourusername to reset your password. If you are the only administrator, you may need to boot into recovery or single-user mode, which varies by Linux distribution — consult your distribution's documentation or contact your system administrator.
Can I see what password I just typed?
No. The passwd command intentionally hides password input for security — characters do not appear on screen as you type. This prevents someone looking over your shoulder from seeing your password. Type carefully and use the re-entry prompt to catch mistakes.
Does changing my password log me out?
No. Changing your password while logged in keeps you logged in. The new password takes effect only for future login attempts. If you are logged in remotely via SSH, you will not be disconnected.
How often should I change my password?
That depends on your security needs and your system's policy. Personal home systems have no strict requirement. Work systems often have policies set by your administrator — if your system enforces password expiration, you will be prompted to change your password after a set number of days. If you suspect your password has been compromised, change it when ready.
Can I change a password without using the terminal?
Most graphical Linux desktops include a Settings or System Settings process where you can change your own password through a GUI instead of the terminal. Look for "Users" or "Accounts" in your system settings. However, administrators typically use the terminal to change other users' passwords because the GUI tools usually do not offer that option.