How to Change Root or Sudo Password in Ubuntu

April 16, 2024

Introduction

Sudo and root privileges allow you to execute commands with elevated permissions, and managing these passwords ensures that only authorized users perform critical administrative tasks. Therefore, knowing how to change the root or sudo password in Ubuntu is crucial for maintaining system security and control.

The following text explains how to change the root or sudo password in Ubuntu.

How to Change Root or Sudo Password in Ubuntu

Prerequisites

  • Ubuntu system (this tutorial uses Ubuntu 22.04).
  • A user with sudo privileges.
  • Access to the terminal.

How to Change Root Password in Ubuntu

The root password in Linux is the master password that grants unrestricted access to all system files, settings, and commands. To change the root password, take the following steps:

1. Run the passwd command:

sudo passwd root
sudo passwd root terminal output

2. Enter your account password

3. Type in the new root password.

Enter new root password terminal output

4. Retype the root password.

Retype root password terminal output

The output confirms the password has been changed successfully.

How to Change Sudo Password in Ubuntu

The sudo password is required to execute administrative commands using the sudo command. It allows users to temporarily gain superuser or root privileges without logging in directly as the root user.

There are two ways to change the sudo password in Ubuntu. The following text elaborates on both of them.

Method 1: Change sudo Password via Command Line

To change the sudo password via the terminal, use the passwd command:

sudo passwd [username]

For example, to change the password of user sara, do the following:

1. Run the passwd command:

sudo passwd sara

2. Type your current password.

sudo passwd sara terminal output

3. Enter the new password.

Type new sudo password terminal output

4. Retype the new password to confirm.

Password changed terminal output

The output shows the password has been changed.

Method 2: Change Sudo Password via GUI

To change the sudo password in Ubuntu without using the terminal or any commands, use the graphical user interface (GUI). Follow these steps:

1. Open the Activities overview.

Activities in Ubuntu

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

Settings in Ubuntu

3. Click the Users card.

Users tab in Ubuntu

4. Select the user for whom you want to change the password.

5. Click the Password field.

Password field in Ubuntu

6. This opens a new Change Password pop-up. Type in your current password and the new sudo password, and verify the new password by retyping it.

change password window

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

Click Change to confirm the changes

Conclusion

After reading this article, you now know how to change sudo and root passwords in Ubuntu using two different methods.

Next, learn how to create strong passwords for greater protection.

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