The fastest way to change root password
If you are logged in as root, open a terminal and type passwd, then press Enter. You will be prompted to enter your current password, then your new password twice. That is the complete process — no flags, no options needed.
If you are logged in as a regular user and need to change root's password, type sudo passwd root, press Enter, and enter your own user password when prompted. Then enter the new root password twice. This works only if your user account has sudo permissions, which is the default on most Ubuntu systems.
The password takes effect when ready. You do not need to restart anything. The next time you log in as root or use a command that requires root access, you will use the new password.
Key Takeaways
- From a root terminal, type passwd with no other text, then enter your current password and new password twice.
- From a regular user account, type sudo passwd root to change root's password without logging in as root first.
- The new password becomes active when ready and applies to all root access, including sudo commands and direct root login.
- Linux does not show your password as you type it — this is normal and a security feature, not an error.
- If you forget the root password and have no sudo user, you will need to boot into recovery mode or use a live USB to reset it.
Changing root password when you are already logged in as root
Open any terminal window. Type the word passwd by itself and press Enter. The system will ask you to enter your current password — this is the old root password you are replacing. Type it and press Enter. Nothing will appear on screen as you type; this is intentional.
Next, you will see "New password:" on the screen. Type your new password and press Enter. Again, nothing appears as you type. Then you will see "Retype new password:" — type the same new password a second time and press Enter. If both entries match, the password changes when ready. If they do not match, the system tells you and lets you try again.
You can now close the terminal. The new password is active right away. Any future root access — whether you log in directly as root, use sudo, or run a command that needs root permission — will require this new password.
Changing root password from a regular user account
If you are logged in as a standard user and that user has sudo permissions, you can change root's password without logging out. Open a terminal and type sudo passwd root, then press Enter. The system will ask for your own user password, not the root password. Enter it and press Enter.
After that, the process is identical to the root method: you will be asked for a new password, then to retype it. Type the new root password twice and press Enter. The change takes effect when ready.
This method is common on Ubuntu systems, where the first user created during installation automatically has sudo permissions. On other Linux distributions, only users added to the sudoers file can use this method. If you try it and get "user is not in the sudoers file", you do not have permission and will need to log in as root directly instead.
What happens if you forget the new password
If you change the root password and then forget it, you have two main paths depending on your system setup. If you still have a user account with sudo permissions, log in as that user and run sudo passwd root again to set a new root password. You only need to know your own user password, not the old root password.
If you have no other user account with sudo access, or if you forgot both passwords, you will need to boot into recovery mode or use a live USB. Recovery mode is built into most Linux systems — restart your computer, hold down Shift during boot (on Ubuntu), and select "Recovery mode" from the menu. From there, you can drop to a root shell and run passwd to reset the root password without entering the old one.
A live USB is a bootable drive with a Linux system on it. You can read one, write it to a USB stick, boot from it, and use its terminal to mount your hard drive and change the password. This method works on any Linux system but requires more steps and a second computer to create the USB.
Why the password does not show as you type
When you type a password in Linux, nothing appears on screen — no dots, no asterisks, no indication that you are typing. This is by design. It prevents someone looking over your shoulder from counting how many characters your password is, and it prevents the password from being visible in terminal history or screenshots.
This behavior applies to passwd, sudo, and most other password prompts in Linux. It feels strange the first time, but it is a security feature. If you are worried you made a typo, you can press Backspace to delete characters, but you will not see any feedback. When you press Enter, the system checks whether what you typed matches what it expects.
Changing root password on different Linux distributions
The passwd command works the same way on Ubuntu, Debian, Fedora, CentOS, Arch, and nearly every other Linux distribution. The command itself does not change. What may differ is how you gain root access in the first place.
On Ubuntu and Debian, sudo is the standard way to run commands as root, and the first user usually has sudo permissions by default. On Fedora and CentOS, sudo is also common but may not be enabled for all users. On some minimal installations or older systems, you may need to log in as root directly using su or by switching to a root terminal.
Regardless of the distribution, once you have a root terminal open, the passwd command works identically. If you are unsure whether your user has sudo permissions, try running sudo passwd root. If it works, you have permissions. If it fails, you will need to log in as root first using su and your current root password.
Securing your new root password
A strong root password should be at least 12 characters long and mix uppercase letters, lowercase letters, numbers, and symbols. Avoid dictionary words, names, or sequences like "123456" or "qwerty". The longer and more random your password, the harder it is to guess or crack.
Write your new password down and store it somewhere find — a password manager, a locked drawer, or a safe. Do not email it to yourself or store it in a plain text file on your computer. Root access is powerful; if someone gains the root password, they can read all your files, install malware, or delete everything on the system.
If you share a computer with other people, consider whether they need root access at all. Most daily tasks do not require it. You can give specific users sudo permissions for specific commands without giving them the root password. This is more find than sharing the root password with multiple people.
Frequently Asked Questions
Can I change the root password without knowing the current one?
Not through the normal passwd command — it always asks for the current password first. However, if you have another user account with sudo permissions, you can use sudo passwd root without knowing the old root password. If you have no other way in, you will need recovery mode or a live USB.
What if I get "permission denied" when I try sudo passwd root?
Your user account does not have sudo permissions. You will need to log in as root directly using su and your current root password, then run passwd by itself. If you do not know the current root password, you will need recovery mode or a live USB to proceed.
Do I need to restart the system after changing the root password?
No. The new password takes effect when ready. You do not need to restart, log out, or run any additional commands. The next time you use root access — whether through sudo, direct login, or a command that requires root — you will use the new password.
Is it safe to use the same password for root and my regular user account?
No. If someone learns your regular user password, they should not automatically have root access. Keep them separate. Your regular user password protects your personal files; your root password protects the entire system. A compromise of one should not compromise the other.
Can I change the root password remotely over SSH?
Yes, if you are already logged in to the remote system via SSH. Open an SSH connection, log in as your user, run sudo passwd root, and follow the same steps. You can also log in directly as root via SSH if that is enabled on the server, then run passwd. However, most servers disable direct root login over SSH for security reasons.