Ubuntu 22.04 Reset Root User Password Command Line

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

AuthorAdmin

My name is Devendra Dode. I am a full-stack developer, entrepreneur, and owner of Tutsmake.com. I like writing tutorials and tips that can help other developers. I share tutorials of PHP, Python, Javascript, JQuery, Laravel, Livewire, Codeigniter, Node JS, Express JS, Vue JS, Angular JS, React Js, MySQL, MongoDB, REST APIs, Windows, Xampp, Linux, Ubuntu, Amazon AWS, Composer, SEO, WordPress, SSL and Bootstrap from a starting stage. As well as demo example.

Leave a Reply

Your email address will not be published. Required fields are marked *