Special offer
popup-offers
English
+370 5 205 5502 sales@monovm.com

How to Enable Root Account in Ubuntu?

How to enable the root account in Ubuntu? Find out this and much more in today's article.

28 May, 21 by Antoniy Yushkevych 5 min Read

List of content you will read in this article:

If you are a newbie, you may be scratching your head about how to enable your root account in Ubuntu! Well, for several security purposes, the root user account is kept disabled. Before we begin, here is some preface. 

When you install Ubuntu, a root account is created. The catcher here is that you do not have the provision to set the password for the account. 

Let us assist you in enabling the user account in Ubuntu! This tutorial will help you to understand several other factors too, including how to disable the account and set up a password for your root account. Read on!

 

Follow the commands mentioned below to find out the root user account password details:

sudo grep root /etc/passwd

Output:

The x in the output signifies that the account’s password is empty.

sudo grep root /etc/shadow

Output:

Here, ! signifies that the password is locked. What does this mean? Well, this means that the user does not have the access to set a password for the account. 

This is an issue, isn’t it? Here is a solution. Following are a few steps that you must follow in order to enable the account and subsequently set a password:

  • Temporary Method
  • Command-Line and Graphical User Interface Method
  • Command-Line Method

Let us understand each method in detail.

 

You use this method when you want to temporarily enable a root account. Follow the command mentioned below:

sudo -i

Output:

Now, if you want to disable an account, just log out of the session and type the following command:

exit

Output:

 

When you follow this method, you can easily access your root account either from the GUI or the command line. Use the following command:

sudo -i passwd root

Output:

As you can see, the password is updated successfully. 

Secondly, here is how you can access the root account through the graphical user interface.

Type root in the first textbox.

Type your root account password.

As soon as you type the password, you encounter an error message. The reason is that there is a security layer in the graphical interface that stops any login until and unless several other configuration files are configured. 

This basically provides extra security. In order to log in through the graphical user interface, follow these steps and edit the following files:

/etc/gdm3/custom.conf

/etc/pam.d/gdm-password

After editing these files, next up is to back up the following configuration files:

sudo cp /etc/gdm3/custom.conf /etc/gdm3/custom.conf_backup

sudo cp /etc/pam.d/gdm-password /etc/pam.d/gdm-password_backup

Now, simply, open the “/etc/gdm3/custom.conf” configuration file

sudo vi /etc/gdm3/custom.conf

Moving on, write the following mentioned line under the ‘security’ textbox.

AllowRoot=true

Output:

Press save and exit. 

Now, open “/etc/pam.d/gdm-password” which is a configuration file.

As soon as you hunt down the following line, add ‘#’ at the beginning of that line, just as shown below.

#auth required pam_succeed_if.so user != root quiet_success

Just save and hit exit on the ‘gdm’ configuration file.

In order to see the changes that you just made, simply reboot the system. To do so, type the following command:

sudo reboot -f

As you have rebooted your system, login into the root account now.

Bam! You can log in to the root account easily. 

 

Additionally, if you want to disable the root account, simply use the following command:

sudo passwd -dl root

Output:

Reverse whatever changes you made in the two configuration files earlier. 

Delete “AllowRoot=true” from the “/etc/gdm3/custom.conf” configuration file as shown below.

Next, delete the ‘#’ from  “/etc/pam.d/gdm-password”.

And you are done!

 

Using the command-line method, you can easily enable or disable the root account through the command line. Here, you cannot log in through a graphical interface.

Use the following command, to enable the root account:

sudo -i passwd root

Output:

The screenshot shows that you can access the root account. Along with that, you can set the password for the root account as well. Now, you can go to your root account by typing the following command:

su – root

Output:

 

Moreover, to disable the root account, enter:

sudo passwd -dl root

Output:

To be one hundred percent sure, switch to the root account and see if the process is successful.

If you see the same message like the above image, then yes, you have successfully disabled the account as now you can see that the authentication has failed. 

 

These were few methods to help you enable or disable the root account in Ubuntu.

We hope that the article solved your queries and provided you with a better understanding of the topic. If you have any questions or suggestions, please leave them in the comment section below.

Antoniy Yushkevych

Master of word when it comes to technology, internet and privacy. I'm also your usual guy that always aims for the best result and takes a skateboard to work. If you need me, you will find me at the office's Counter-Strike championships on Fridays or at a.yushkevych@monovm.com