Introduction

Are you looking to change the root password in Ubuntu?

Changing passwords is a good practice and should be done periodically.

Linux allows multiple user accounts, each having its own password. Users can only change their own password. However, there is always a sudo/root (SuperUser) account. Root users can change the password of any account, including their own. By default, the root user is locked.

There are three (3) ways to change passwords in Ubuntu.

The first two (2) options use the command line, and the other uses Linux’s graphical interface (GUI).

how to change ubuntu default root password

Prerequisites

  • Ubuntu installed and running
  • A user with sudo privileges
  • Access to a terminal/command line
  • The apt-get tool, pre-loaded in Ubuntu and other Debian-based distros

Change the Root Password in Ubuntu

Option 1: Changing Ubuntu password in the command line

To change the sudo password, using the sudo command:

1. First, open the terminal using the keyboard shortcut CTRL+ALT+T.

2. Query for a password change by running the command:

sudo passwd root

You will be prompted to enter and verify the new password. The output will inform you the password was updated successfully.

output after ubuntu changing root password

Option 2: Change sudo password with the passwd command

An alternative is to switch to the root user and then run the command to change the root password.

1. First, open the terminal (CTRL+ALT+T).

2. Switch to the root user with the command:

sudo –i

Type in your current password and hit Enter. The output you receive should show that you can now run commands as root.

sudo root example

3. Next, change the password by running the command:

passwd

Type and retype the new password to verify the change.

4. After changing the password, log out of the root user with the command:

exit

5. Exit out of the terminal with the same command:

exit

Option 3: Changing Ubuntu password using GUI

To change the default root password in Ubuntu without using the terminal or any commands, use the graphical interface.

1. Open the Activities overview by pressing the Windows or Super key.

2. Type settings in the search bar and click on the Settings icon.

3. In Settings, click on the Details card (which is most likely the last one).

Ubuntu’s graphical interface with details selected

4. Next, click on Users. This lists all the details about the root user, including the password. Click on the password bar.

GUI of Ubuntu users and password

5. This will open a new Change Password pop-up. Here, type in your current root password, your new root password and verify the new password by retyping it.

6. Once you have filled in all the fields, click Change to confirm the changes.

confirmation of the change of password

Conclusion

This article provides three (3) ways to change the sudo password for the root user on Ubuntu. Any of the three options include simple steps that anyone can follow and complete.

Finally, make sure that your password includes both lower and upper case letters, numbers and special characters. It is essential to have a strong password to prevent brute force attacks.