Ubuntu 22.04 Reset Root User Password Command Line


The root user has superuser privileges and can perform administrative tasks, so it’s important to keep its password secure. In this tutorial, you will learn how to change or reset root user password in Ubuntu 22.04 using the command line or terminal.

How to Reset Root User Password in Ubuntu 22.04 Command Line

Steps to reset root user password in ubuntu 22.04 using terminal or command line:

  • Step 1: Open a Terminal
  • Step 2: Access Root Privileges
  • Step 3: Change Root Password
  • Step 4: Exit Root Shell
  • Step 5: Test the New Password

Step 1: Open a Terminal

To begin, open a Terminal window. You can do this by pressing Ctrl + Alt + T simultaneously or by searching for “Terminal” in the application launcher.

Step 2: Access Root Privileges

In order to change the root password, you need to have superuser (root) privileges. You can do this by using the sudo command before the command you want to run. The first step is to elevate your privileges:

sudo -i

This will prompt you to enter your user password. After entering the password, you will be granted a root shell, and the command prompt will change to something like:

root@yourhostname:~#

Step 3: Change Root Password

Now that you are logged in as the root user, you can change the root password using the passwd command:

passwd

Running this command will prompt you to enter a new password for the root user. You will be asked to enter the new password twice for confirmation. Please ensure that your password is strong and not easily guessable.

Step 4: Exit Root Shell

After you have successfully changed the root password, you should exit the root shell to return to your regular user privileges:

exit

Step 5: Test the New Password

To ensure that the root password has been changed successfully, you can open a new Terminal window and try logging in as the root user using the new password:

su

You’ll be prompted to enter the root password. If you successfully log in, then the password change was successful.

Conclusion

  • Changing the root password via the command line involves using the passwd command under root privileges.
  • Always prioritize security and create strong, unique passwords.
  • Limit the usage of the root account and prefer sudo for administrative tasks to reduce security risks.
  • Exercise caution, back up important data, and work in a controlled environment when making system changes.
  • For any issues, consult official documentation or seek assistance from the Ubuntu community.

Recommended Tutorials

Jaspreet Singh Ghuman

Jaspreet Singh Ghuman

Jassweb.com/

Passionate Professional Blogger, Freelancer, WordPress Enthusiast, Digital Marketer, Web Developer, Server Operator, Networking Expert. Empowering online presence with diverse skills.

jassweb logo

Jassweb always keeps its services up-to-date with the latest trends in the market, providing its customers all over the world with high-end and easily extensible internet, intranet, and extranet products.

Contact
San Vito Al Tagliamento 33078
Pordenone Italy
Item added to cart.
0 items - 0.00
Open chat
Scan the code
Hello 👋
Can we help you?