Skip to main content

User Management

Switch to Root User in Ubuntu

Learn to switch to the root user in Ubuntu in this basic tutorial.

Linux users generally execute the command with sudo whenever the changes are going to affect the root system.

sudo command_that_requires_root_access

But what if you want to switch to the root user so that you don't have to use sudo with every command?

Unlike other Linux distributions, Ubuntu normally won't let you configure the root account while the installation process.

But you can switch to the root user with sudo:

sudo su

Switch to root user in Ubuntu

In this tutorial, I'm going to share two ways by which you can switch to a root user in Ubuntu or any other Linux distribution:

  • Using the sudo command
  • Configuring the root account

So let's start with the first one.

1. Switch to root user using sudo

If you haven't configured the root account and don't want to, then refer to this method.

To switch to the root user, you have to execute the su (switch user) and when executed without any options, it will switch to the root user:

sudo su

When it asks for the password, you have to use your account password as you normally do with any other sudo command.

Also, the password entering is not shown on the terminal. Just type and press enter.

switch to root user using sudo in Ubuntu

As you can see, when I used the whoami command, it showed I'm logged in as a root user.

See Logged in Users on Ubuntu Linux
Wondering who else is currently logged in to your system? Here are various ways to see logged in users on Ubuntu.

2. Configure the root account and switch to it

As I said earlier, Ubuntu does not include any option to configure a root account while the installation process so if you want to configure the root account, then, here's how you do it.

To configure the root account, all you have to do is set the root password use the following command:

sudo passwd root
change password of root account in ubuntu

Once done, you can use the su command without any options and enter the new password to switch to the root account:

su
switch to root account using the su command in Ubuntu linux

And there you have it!

On a related topic, you may want to know how to list users in Ubuntu.

How to List Users in Ubuntu Command Line
Learn various ways of listing users in Ubuntu Linux. You’ll also learn the difference between the system and regular users.

Forgot the sudo and root password? Let me help

If you forgot the sudo and root passwords then how would you change the password? Well, it is quite easy and we made a dedicated tutorial for that:

How to Reset Forgotten Ubuntu Password in 2 Minutes
If you forgot your user password on Ubuntu, don’t worry. You can reset an Ubuntu password very easily. This guide explains an easy method for changing the root password on Ubuntu. The method should also be applicable to other Linux distributions.

Still, having issues to switch to the root account? Leave a comment and I'll help you out.