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.
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
2. Enter your account password
3. Type in the new root password.
4. Retype the root password.
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.
3. Enter the new password.
4. Retype the new password to confirm.
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.
2. Type settings in the search bar and click the Settings icon.
3. Click the Users card.
4. Select the user for whom you want to change the password.
5. Click the Password field.
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.
7. Once you have filled in all the fields, 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.