Changing your password in Linux is a basic but essential skill for keeping your system secure. This guide covers the passwd command, which works on virtually every Linux distribution, whether you’re using a desktop, server, or even a container. You’ll learn how to change your own password, how to change another user’s password (if you have sudo access), and how to handle common issues like forgotten passwords.
What You’ll Need
- Access to a terminal (Ctrl+Alt+T on most desktop Linux systems, or an SSH session for remote servers).
- Your current password (if changing your own password).
- Sudo or root privileges (if changing another user’s password).
Step-by-Step
- Open a terminal. On most desktop Linux distributions, you can press
Ctrl+Alt+Tto open a terminal window. If you’re on a remote server, log in via SSH. - Run the
passwdcommand. To change your own password, simply typepasswdand press Enter. You don’t need to add your username; the command assumes you want to change the password for the current user. - Enter your current password. The system will prompt you for your current (old) password. Type it and press Enter. Note that as you type, nothing will appear on screen—this is a security feature, not a glitch.
- Enter your new password. You’ll be asked to type your new password. Choose a strong one: at least 12 characters, mixing uppercase, lowercase, numbers, and symbols. Avoid common words, your name, or simple sequences.
- Re-enter your new password. To confirm, you’ll be asked to type the new password again. Make sure it matches exactly.
- Wait for confirmation. If successful, you’ll see a message like
passwd: password updated successfully. Your password is now changed. - To change another user’s password (requires sudo): Type
sudo passwd username, replacingusernamewith the actual login name. You’ll be prompted for your own sudo password (not the target user’s), then you can set a new password for that user. You won’t need to enter the old password. - To force a user to change their password at next login: Use
sudo passwd -e username. This expires the password immediately, so the user will be forced to set a new one the next time they log in. - To change the root password (if you’re root): If you’re logged in as root, just type
passwdand set a new root password. If you’re a sudo user, usesudo passwd root.
Common Mistakes
- Typing the old password incorrectly. If you mistype your current password, the command will fail with “Authentication token manipulation error.” Double-check for typos, especially if Caps Lock is on.
- Choosing a weak password. The system may reject passwords that are too short, too simple, or based on dictionary words. This is a good thing—it forces you to pick something secure.
- Mismatched new passwords. If the two entries for the new password don’t match, you’ll get a “Passwords do not match” error and have to start over.
- Forgetting to use sudo when changing another user’s password. If you’re not root and you try to change another user’s password without sudo, you’ll get a permission denied error.
- Using the same password for multiple systems. Even if you change it on one machine, other systems remain vulnerable. Use a password manager to generate and store unique passwords.
Tips
- Use a passphrase. A sentence like “Correct-Horse-Battery-Staple” is much easier to remember and harder to crack than a short random string.
- Change your password regularly. Security best practices suggest changing passwords every 90 days, especially for root or admin accounts.
- Check password strength. You can use the
cracklib-checkcommand (if installed) to test a password before setting it:echo "YourPass" | cracklib-check. - Use SSH keys instead of passwords. For remote servers, SSH keys are more secure and convenient than passwords. You can still change your password, but consider setting up key-based authentication.
- Never share your password. Even with IT support, avoid sharing passwords. Instead, use sudo or temporary access.
- If you’re a sysadmin, set password expiration policies. Use
chageto set maximum days between password changes:sudo chage -M 90 username.
Troubleshooting
- “Permission denied” when changing another user’s password. This means you don’t have sudo privileges. Either ask the system administrator to grant you access, or log in as root (if you know the root password).
- “Authentication token manipulation error” when changing your own password. This usually means your current password was incorrect. Try again, ensuring Caps Lock is off and you’re typing the correct password.
- “Password has been used recently” or “Password is too similar to the old one.” The system is enforcing password history or similarity rules. Choose a completely different password.
- You forgot your password and can’t log in. If you’re on a single-user system, you can reboot into recovery mode (hold Shift during boot on GRUB) and reset the password from the root shell. On many distributions, you can also use a live USB to chroot into the system and run
passwd. For cloud servers, most providers offer a recovery console or a way to reset the root password from their control panel. - Password changed but you’re still prompted for the old one in some applications. Some GUI apps (like keyrings or browsers) cache your old password. You may need to update them or log out and back in.
- passwd command not found. This is extremely rare, but if it happens, your PATH may be misconfigured. Try using the full path:
/usr/bin/passwd.
Frequently Asked Questions
Do I need to be root to change my own password?
No. Any user can change their own password with the passwd command. You only need root or sudo privileges to change another user’s password.
What is the difference between passwd and chpasswd?
passwd is interactive and prompts for the old and new passwords. chpasswd is designed for batch changes, reading lines of username:newpassword from standard input. It’s useful for scripts but requires root privileges.
How do I change the password for a user without being prompted for the old one?
If you have sudo access, use sudo passwd username. You’ll be asked for your own sudo password, not the user’s old password, and you can set a new one directly.
Can I change my password without knowing the old one?
No, not normally. The system requires the old password to verify your identity. If you’ve forgotten it, you’ll need to use recovery methods (like a root shell) or contact your system administrator.
How do I force a password change at next login?
Use sudo passwd -e username. This expires the password immediately, so the user will be prompted to set a new one the next time they log in.
Does changing my password affect SSH keys?
No. SSH keys are separate from your account password. If you use SSH keys to log in, changing your password won’t affect that. However, if you use a password to protect your SSH private key, that’s a different password managed by the SSH client.
Related
General steps for current mainstream versions; menus can differ by device and version. See the disclaimer or report an error.
More in this bed
- Hogwarts Legacy Microsoft Visual C Runtime Error Fix
- Set Up UPI Payments Through WhatsApp
- Pair Oppo Enco Earbuds with Android, iPhone & Windows
- Fix Administrator Account Disabled Error in Windows 11
- How to Play Kodi on Smart TV from PC
- Factory Reset on Samsung Galaxy: What It Erases