For security reasons, it is recommended to change the root password periodically on Ubuntu. On Ubuntu, there are three types of users: root, standard, and system user. The standard user can only change their password. The system user can change their own and standard user password. However, the root user can change the standard and system user password. In short standard users and system users can’t change the root password because the root user is locked by default.
This article will provide a guide to changing the root password on Ubuntu.
How do I Change Root Password in Ubuntu 24.04
There are three methods through which you can change or reset the root password on Ubuntu. These are the methods to change the root password using:
- passwd Command
- sudo passwd Command
- Settings
Method 1: Change Root Password in Ubuntu using passwd Command
The root user password can be changed using the passwd command. The passwd command in Linux is used to change or set the user password. To change the root user password, we must log in as the root user. Let’s check the following steps to change the root password on Ubuntu 24.04.
Step 1: Enable the Root User Account
First, press CTRL + Alt + T to open the Terminal. Then, switch to the root user account from the standard user account by running this command:
sudo -i
Step 2: Change the Root User Password
Now, run the passwd command to open the password configuration utility. First type, the new password you want to set for the root user account and then retype the password change the root user password:
passwd
The output confirms that the password was changed successfully.
Step 3: Log Out from the Root User Account
Once done, run the exit command to logout from the root user account:
exit
Step 4: Test the Root User Password Change
Once logged out, now, let’s check the password change by logging in to the root user account. To log in to the root user account, run the su – command. Then, type the password you changed and hit the Enter button:
su -
From the output, it can be observed that we logged in to the root user account, which confirms that the password was changed.
Method 2: Change Root Password in Ubuntu using sudo passwd Command
You can also change the root password using the sudo command. To change the root user password using the sudo command check these instructions.
Run this command to open the password change prompt. You will be asked to enter the new password and then retype the new password to change the root user password:
sudo passwd root
Once the password is changed, type the exit command to log out from the prompt:
exit
Method 3: Change the Root Password in Ubuntu using the Settings (GUI)
In case, if you are new to Ubuntu and don’t have any idea about using the Terminal, then, you can change the root password by using the system Settings. To change the root password using system settings, check the following instructions.
Step 1: Open Settings
Press Windows + A shortcut key to open the search box, then search and open Settings:
Step 2: Open Users Window
Open System settings and then navigate to the Users settings:
Step 3: Unlock the User Settings
Click on the button to unlock the user settings so you can change the root user password:
Enter the user password to authenticate the unlocking of user settings:
Step 4: Change Root User Password
Now, click on the Password section to change the root user password:
Enter the current password, then type the new password and confirm it. Once done, click on the Change button to change the root user password:
How to Disable the Root Account in Ubuntu 24.04
Once you are done with changing the password, you can then disable the root account. To disable the root account on Ubuntu, run this command:
sudo passwd -dl root
Conclusion
You can change the root password through system settings and Terminal. To change the root password using system settings, first, navigate to Settings > System > Users > then, unlock user settings and change the password. To change the root password using Terminal, first switch to the root account by running the su – command. Then, run the passwd command to change the root password. Another method to change the root password through Terminal is to run the sudo passwd root command, type, and retype the password you want to set for the root user account.
Frequently Asked Questions
How to change root password in Ubuntu 24.04 using passwd command?
To change the root password in Ubuntu 24.04 using the passwd command, you need to log in as the root user, open the Terminal, and run the passwd command to set a new password.
What is the difference between standard user, system user, and root user in Ubuntu password management?
In Ubuntu, the standard user can only change their password, the system user can change their own and standard user password, while the root user can change the standard and system user password.
Can standard users change the root password in Ubuntu?
No, standard users cannot change the root password in Ubuntu since the root user is locked by default for security reasons.
How to enable the root user account in Ubuntu to change the password?
To enable the root user account in Ubuntu, open the Terminal, switch to the root user account using 'sudo -i', and then use the passwd command to change the root password.
What are the methods to change or reset the root password in Ubuntu 24.04?
You can change or reset the root password in Ubuntu 24.04 using the passwd command, sudo passwd command, or through the Settings.
Is logging out from the root user account necessary after changing the root password in Ubuntu?
Yes, it is recommended to log out from the root user account after changing the root password in Ubuntu for security purposes.
How can I confirm that the root password was changed successfully in Ubuntu 24.04?
You can confirm that the root password was changed successfully in Ubuntu 24.04 by running the passwd command and checking the output for a confirmation message.
What keyboard shortcut can be used to open the Terminal in Ubuntu 24.04?
To open the Terminal in Ubuntu 24.04, you can use the keyboard shortcut CTRL + Alt + T.