How to Change Sudo or Root Password in Ubuntu

April 10, 2019

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).

header image 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 a new password. The output will inform you the password was updated successfully.

example output after ubuntu changing root password
image of terminal to exit changes after password reset

Option 2: Change sudo Password with the passwd Command

An alternative is to switch to the root user and then run the passwd 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.

example command for sudo -l

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

passwd

Type and retype a 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).

example of Ubuntu 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 example of Ubuntu users and password

5. This will open a new Change Password pop-up. 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.

change password prompt in ubuntu

Conclusion

This article provides three (3) ways to change the 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.

Was this article helpful?
YesNo
Sofija Simic
Sofija Simic is an experienced Technical Writer. Alongside her educational background in teaching and writing, she has had a lifelong passion for information technology. She is committed to unscrambling confusing IT concepts and streamlining intricate software installations.
Next you should read
How to Install Ubuntu 18.04 Bionic Beaver
July 5, 2019

Ubuntu 18.04 (codenamed Bionic Beaver) is a free, open-source distribution of Linux, based on the Debian...
Read more
How to Enable & Set Up .htaccess File on Apache
April 9, 2019

The .htaccess file in Apache is a tool that allows configurations at the directory and subdirectory level...
Read more
How To Add User to Sudoers & Add User to Sudo Group on CentOS 7
December 5, 2018

This guide will walk you through the steps to create or add a sudo user on CentOS 7. The "sudo" command...
Read more
How to Reset or Change the Root Password in Linux
October 22, 2018

In Linux, root privileges (or root access) refers to a user account that has full access to all files...
Read more