To change the root user password on Ubuntu, you need to open the terminal and use the sudo -i command to switch to the root user, after that, type the sudo passwd root command and press Enter, this will open a prompt to change the password.
How to Change the Root Password on Ubuntu 22.04
Here are some steps to change root user password on Linux Ubuntu 22.04 or 20.04 using command line:
Step 1 – Open Terminal
First of all, open the terminal using the keyboard shortcut CTRL+ALT+T.
Step 2 – Switch to the Root User
Now you have to switch from normal user to root user on ubuntu, for this, you have to type the command sudo -i on your terminal or command line and hit enter:
sudo -i
Run the whoami
command to verify that the user is changed:
whoami
The output of the above-given command:
root
Step 3 – Change the Root Password on Ubuntu 22.04
Now on your ubuntu terminal window, you have to type sudo passwd root, and this command will help to set or change the password of root user.
sudo passwd root
When you type sudo passwd root, after that the prompt for enter password and re-enter password will open, here you enter your new password for the root user and change it.
That’s it! The root password has been changed.
Step 4 – Verify Root User New Password
This is an option step, if you want to verify the password of your root user that you have changed by using above the steps, you have to use the command:
su -
Here is the video guide on how to change or reset the root user password on ubuntu:
Conclusion
Through this tutorial, we have learned how to change root user password in linux ubuntu using command line.