How to Change Root Password in Ubuntu 22.04?

By Hardik Savani May 1, 2024 Category : Ubuntu

Hi Dev,

In this example, I will show you how to change root password in ubuntu 22.04. This article will give you a simple example of how to change root password in ubuntu terminal. you'll learn ubuntu 22.04 change root password. It's a simple example of ubuntu 22.04 set root password.

Certainly, you can reset the root user password on Ubuntu 22.04 using the `sudo -i` command followed by the `passwd` command. Here's a step-by-step guide, along with explanations for each step:

Step 1: Open a Terminal

Open a terminal window on your Ubuntu 22.04 system. You can do this by pressing `Ctrl+Alt+T` or by searching for "Terminal" in the applications menu.

Step 2: Access the Root Shell

Run the following command to access a root shell:

sudo -i

- `sudo` allows you to run commands with superuser (root) privileges.

- `-i` stands for "interactive" and opens a new shell with root privileges.

You'll be prompted to enter your user password to confirm your identity. This is necessary because you're gaining root access.

Upon entering your user password, you will gain access to a root shell, and the command prompt will transition to a format similar to:

root@yourhostname:~#

Step 3: Reset the Root Password

Once you have the root shell, you can reset the root user's password using the `passwd` command. Replace `new_password` with your desired new password:

passwd

- You'll be prompted to enter and confirm the new password.

Step 4: Exit the Root Shell

After you've successfully changed the root password, you can exit the root shell and return to your regular user shell:

exit

- This command exits the root shell and returns you to your normal user session.

Step 5: Log in as Root

You can now log in as the root user using the new password you set.

Using `sudo -i` followed by `passwd` is a convenient way to reset the root password, but it should be used with caution. The root user has extensive privileges, and you should only use it when necessary for system administration tasks. In most cases, it's recommended to use the `sudo` command with your regular user account to perform administrative actions.

I hope it can help you...

Tags :
Shares