How to Change the Root Password on Ubuntu

The root account in Ubuntu is a powerful administrative account that grants full control over the system. It is essential to keep the root password secure, as it protects critical system files and settings. However, there may be instances where you need to change the root password, whether it's for security reasons or simply because you forgot it. In this article, we will provide a step-by-step guide on how to change the root password on Ubuntu.

To change the root password on Ubuntu, you'll need to access the command line interface, also known as the terminal. There are several ways to open the terminal, but the easiest method is to use the keyboard shortcut Ctrl + Alt + T. Alternatively, you can use the search function or navigate through the applications menu to find the terminal.

Logging in as Root:

By default, Ubuntu disables the root account and uses sudo (Superuser Do) to perform administrative tasks. Therefore, before changing the root password, we need to enable the root account temporarily.

  1. Run the following command:
sudo passwd root

2. You will be prompted to enter your user password.

3. Next, you will be prompted to enter the new password for the root account. Type a strong, secure password and press Enter.

4. Confirm the new password by retyping it and pressing Enter. Once you have completed these steps, the root account will be enabled, and you can proceed to change the root password.

In the terminal, type the following command and press Enter:


You will be prompted to enter the root password you set earlier. Type the new root password and press Enter.

Congratulations! You have successfully changed the root password on Ubuntu. However, it is crucial to disable the root account again to maintain the system's security.

Disabling the Root Account

Open the terminal as before and run the following command:

sudo passwd -l root

You will be prompted to enter your user password. Type your password and press Enter.


Changing the root password on Ubuntu is a straightforward process that involves enabling the root account temporarily, changing the password, and then disabling the root account again. Remember that the root account holds significant power over the system, so it is crucial to choose a strong password and keep it secure.

Always exercise caution when using the root account, as improper usage can lead to unintended consequences or system instability. It is recommended to rely on the sudo command for most administrative tasks instead of logging in as root.