How To Set/Change Root Password In Ubuntu?

How To Set/Change Root Password In Ubuntu?

 

This post was last updated on August 1st, 2020 at 03:37 pm

A root user is a most privileged user account in a Unix based operating system. It has access to all the commands and files of the system. A root user is also called a superuser or administrator because it is needed to perform administrative tasks.

It is used to perform tasks such as installing software, changing the ownership and permissions of files, and managing other user accounts which cannot be done with a normal user account.

Ahead in this article, we will see how we can set/change and disable or remove the password of the root user.

Root account in Ubuntu/Linux Mint

In Ubuntu or a distribution based on Ubuntu, a standard root account is created while the installation of the operating system but no password is assigned to it. Ubuntu comes sudo only by default, which means you are given the ability to execute a task with superuser privileges by using the sudo command. After installing OS If you want you can set or remove the password of the root account by using the terminal.

How to Set/Change the password of root

Since the root account in Ubuntu is created with no password. Use the following steps to assign a password-

1. You can set it in one go by using the following command –

sudo passwd root

This will ask you to enter the new Unix password, enter it and then retype the same password in the next line. Once the password gets assigned it will display a message that password updated successfully.

Now you can check it by using the following command –

sudo -

It will ask you to enter the root password, enter it. Now you will be logged in as root.

2. Another way to set or change the password of root is –

sudo -i

This will prompt you to enter the user password and then switched to root. Now enter the following command to set/change the password.

passwd

Again it will ask you to enter the new Unix password, enter it and then retype the same password in the next line. Once the password gets assigned it will display a message password updated successfully.

Use the following command to logout from the root –

exit

How to disable the root User Account?

Now if you want to disable the root account login, then execute the following command in your terminal.

sudo passwd -dl root

Where,

-d or --delete – The option will delete the password of a user and make a named account passwordless

-l or --lock – This option will disable the password of an account by changing it to a value which matches no possible encrypted value. It adds ! at the beginning of the password.

Now you can verify it by executing the following command-

sudo -

When you enter your root password it will display a message saying authentication failure. It means the root account login has been disabled.

To know more about passwd command see its manual page by using-

man passwd
Previous How To Install Korn Shell in Ubuntu?
Next How To Find IP Address From Domain Name In Linux/Unix?
 

About author

You might also like

Linux Topics 0 Comments

How To Install GParted On CentOS 8?

Gparted (also known as GNOME partition editor) is a free partitioning tool. This is a GUI application that uses GNU parted in the backend. Gparted is used to create, delete,

System Admin 0 Comments

How To Setup Nginx Server In Linux?

This post was last updated on August 1st, 2020 at 09:43 pmNginx, which is pronounced as ‘engine x’ is a free, opensource and high-performance HTTP server. It is among the

Linux Topics 0 Comments

How To Install And Configure Fish Shell In Ubuntu 20.04 LTS?

This post was last updated on August 1st, 2020 at 10:33 amIn Unix-like operating systems such as Linux, a shell is a program that interprets the command, executes, takes input(s),

0 Comments

No Comments Yet!

You can be first to comment this post!

Leave a Reply