How to Login as a Root on Ubuntu

In Ubuntu (and other Linux distributions), the root user has super privileges and can do all administrative tasks. The root user can access all the system files, packages, and other user accounts.

In detail, the root user plays a vital role in Linux systems as it holds absolute control and unrestricted access to critical system resources, allowing system administration tasks, system-wide changes, and the ability to modify and manage files, settings, and processes.

Being a Linux user, you have accessed/switched to the root user account to perform various administrative tasks. Today’s tutorial will guide you through all the methods (CLI and GUI) to log in as a root user on Ubuntu, i.e., Ubuntu 22.04.

How to Log in as a Root User on Ubuntu?

The root user’s account can be accessed from the terminal (command line terminal) and login screen (graphical user interface). The terminal method switches you from the currently logged-in user to the root user.

Method 1: Log in as a Root User Using Terminal (CLI Method)

The “switch user (su)” command switches the user to the other account followed by its name. The syntax of the su command to switch to the root user is as follows:

$ su -

The hyphen (-) in the command will switch the current user to the root user.

Example: Switch From Normal to a Root User

Right now, if you see the following screenshot, we are logged in as a user named “vboxuser”:

To switch to the root user, use the command provided below. You have to provide the root password to log in:

$ su -

The “root@linuxgenie” shows that the root user is in action. Let’s perform a package update using the root user (You do not have to use the sudo in this case):

# apt update

Sometimes, the “su -” command does not act as it should. Let’s understand why it occurs and see how it can be fixed.

Bonus Tip: Set up Root Password

If the “su -” command does not execute or prompt an error, you have not set up the root password yet. For that, use the “sudo passwd” command to set the root password:

$ sudo passwd

Once the root password is set, use the “su -” command to log in as a root user. Now, you must use the password you set up in the above setup.

Method 2: Log in as a Root User Using Log in Screen (GUI Method)

Usually, when you turn on your Ubuntu system, the number of users appears on the login screen, and you can easily log in as a specific user. However, there is no such root user account shown. Let’s show you how to get the root login user on the login screen.

Step 1: Set up Root User Password

First, ensure that you have set up the root user password. If not, use the sudo passwd command to do so:

$ sudo passwd

Step 2: Configure the GNOME Display Manager

Now, open the GNOME display manager’s configuration file in any editor (nano/vim):

$ sudo nano /etc/gdm3/custom.conf

Put the following line at the end of the file:


Step 3: Configure the PAM (Pluggable Authentication Module) Service

Open the PAM’s configuration module file using the command:

$ sudo nano /etc/pam.d/gdm-password

And you have to comment on the line highlighted below, as this will allow you to log in as a root user from the root user:

Step 4: Log in as a Root User

Now, restart/reboot your Ubuntu system. When the login screen appears, you will see an option, “Not list?” as shown below:

Click on it, and enter the “root” in the username text box. Hit enter after that:

Now, provide the root user password:

Upon successful authentication, you will be logged in as a root, and now you have all the privileges of a root user account. When you open up a terminal, it will show that you are logged in as a root user:

Wrap Up

You must have root account access to perform any system/network administrative task. A root user in Ubuntu can be accessed from the terminal and the login screen. The terminal method uses the “su -” command to switch from the current to root users. Moreover, to log in to Ubuntu as a root user from the login screen, you must perform various configurations, as demonstrated here.

This post has briefly explained both methods to log in as a root user on Ubuntu. For more tips and tricks on Ubuntu (and other Linux distributions), keep visiting Linux Genie.

Print Friendly, PDF & Email