The passwd command is the fastest way to change your password

Open a terminal and type passwd, then press Enter. Linux will ask you to enter your current password, then prompt you twice for your new password. That's it — your password changes when ready. You do not need to restart or log out.

If you're logged in as a regular user, passwd changes only your own password. If you're logged in as root or using sudo, you can change another user's password by typing passwd username — for example, passwd james would change James's password.

The system will reject a password that's too short (usually fewer than 8 characters) or too similar to your username or previous passwords. If your new password is rejected, try something longer and less predictable.

Key Takeaways

  • Type passwd in the terminal, enter your current password, then type your new password twice to change it when ready.
  • Linux requires new passwords to be at least 8 characters and different enough from your username and old password.
  • If you forget your password, you can reset it by booting into single-user mode or using a live USB, but the process depends on your distribution.
  • Root users can change another user's password by typing passwd username, but regular users can only change their own.
  • Some systems enforce password expiration — you may be forced to change your password after a set number of days, and the system will warn you before it expires.

What happens if you forget your password

If you cannot log in, you'll need physical access to the machine or another user account with sudo privileges. The fastest route depends on your setup. If another user on the system has sudo access, ask them to run sudo passwd your_username to reset your password for you.

If you're the only user, you can boot into single-user mode (also called recovery mode) and reset your password from there. On Ubuntu, restart the machine, hold Shift during boot to open the GRUB menu, select recovery mode, and choose the option to drop to a root shell. Then type passwd your_username and enter a new password. On other distributions, the boot process differs — check your distribution's documentation for the exact steps.

A live USB is another option: boot from a Linux live USB, mount your hard drive, and use chroot to change the password from the mounted filesystem. This method works on any distribution but requires you to have a live USB already prepared.

Changing your password on a remote server

If you're connected to a remote server over SSH, the passwd command works exactly the same way. Type passwd, enter your current password, then your new password twice. The change takes effect when ready on the remote system.

Some servers restrict password changes through SSH or require you to use a web panel instead. If passwd returns an error like "Authentication token manipulation error," your system administrator may have locked down password changes. Contact them to learn the correct method for your server.

Understanding password expiration policies

Some systems are configured to force you to change your password after a certain number of days. You'll see a warning message when you log in, telling you how many days remain before your password expires. Once it expires, you cannot log in until you change it.

To check when your password expires, type chage -l in the terminal. This shows your password expiration date and the number of days until it expires. If your password is set to never expire, the output will say "never."

System administrators set these policies in the /etc/login.defs file or through tools like chage. As a regular user, you cannot change the expiration policy — only your system administrator can do that.

Changing your password with sudo

If you have sudo privileges, you can change another user's password without knowing their current password. Type sudo passwd username and press Enter. The system will ask for your own password (to verify you have sudo access), then prompt you to enter the new password for that user twice.

This is useful if you're setting up a new user account or resetting a password for someone else on your system. The user does not need to be logged in, and they will be able to use the new password the next time they log in.

Changing your password in a graphical desktop

If you're using a desktop environment like GNOME or KDE, you can change your password through the Settings process instead of the terminal. Open Settings, look for "Users" or "Accounts," select your user account, and click "Change Password." You'll be asked to enter your current password, then your new password twice.

The graphical method works the same way as the terminal command — your password changes when ready and takes effect the next time you log in. Some desktop environments also let you change your password from the login screen itself, though this option is less common.

Frequently Asked Questions

Can I change my password without entering my current password?

No, Linux requires you to enter your current password before setting a new one. This prevents someone from changing your password if they gain temporary access to your unlocked terminal. The only exception is if you're logged in as root or using sudo, in which case you can change another user's password without knowing theirs.

What makes a strong password in Linux?

Linux does not enforce specific rules, but most systems reject passwords shorter than 8 characters and passwords too similar to your username or previous passwords. A strong password typically includes uppercase and lowercase letters, numbers, and symbols. Avoid dictionary words and personal information like birthdays or names.

How long does it take for a password change to take effect?

Your password changes when ready after you type it in the terminal. You do not need to restart or log out. If you're already logged in, you stay logged in with the old password until you log out and log back in with the new one.

Can I undo a password change?

No, once you change your password, the old one no longer works. If you change your password by mistake, you'll need to change it again to something you remember, or ask another sudo user to reset it for you.

What if passwd returns "permission denied"?

This usually means your password file is locked or your account is restricted. Contact your system administrator. On some systems, the root user may have disabled password changes for certain accounts, or your account may be set to use a different authentication method like LDAP or Active Directory.