CompTIA Linux+ (XK0-004)
Red Hat Enterprise Linux
More Resources
Git and Github
Learn Docker and Kubernates
Tips and Tricks

The Root User Account

Root user is special. It is used to do things that require an elevated privilege. Let's take a deep look into it.

Root account

Almost every Linux OS has a root account that is used for doing things that require elevated privileges. It's the first account created on the system and when the OS boots up a lot of activities it performs in the very beginning requires this elevated privileges. This user has every single access across your system.

When do we use this?

We need this root level access when installing a software or configuring a hardware, drivers, etc. Otherwise, we shouldn't be using this account at all. Because there are chances of making mistakes at the root level can be quite risky!

So the key is we don't need to log-in as root. We should rather be able to perform certain actions as root by temporarily becoming root.

When it is created?

On Red Hat based systems (such as Red Hat, Fedora, CentOS), you are required to create a root user when installing the OS. This account is separate from the user account.

On Debian-based systems (such as Ubuntu, Kali, Linux Mint), it creates a user during installation and gives the elevated privileges. You can perform tasks that require system level privileges with sudo.

root account with id = 0.

There are a few ways to switch to the root account.

The Old method:

[email protected]:~$ sudo su -
[sudo] password for bk:

The su command lets you become a root user but it also lets you impersonate any other user (if you have root level privileges). This ability comes handy when a user needs your help and wants you to look into the system.

The Preferred Method:

[email protected]:~$ sudo whoami

Set up SUDO

Remember: It’s easier to simply add a user to the sudo or wheel group to grant sudo privileges. If you need to set up a fine-grained permission then you should use visudo.

In some systems like Red Hat and CentOS, you are required to login as root at least once and modify the /etc/sudoers file to set up sudo for a user.

/etc/sudoers file lists all the users who have sudo permission. Though you can directly modify this /etc/sudoers file, the challenge is if you accidently make a mistake, you would breaksudo. So it is recommended to use the visudo utility. It does the syntax checking before applying the update.


In the above example, the user, amit, can run the login from any host (both local and remote) and impersonate as anyone (can be root or any user in the system), and run any command he wants.

In the above example, the user, sumit, has permission to run only one command (i.e. useradd).

Here’s a breakdown of the granted sudo privileges:

[username] [any-hostname]=([run-as-username]:[run-as-groupname]) [commands-allowed]

For a group we used % in front of a group, for example, %admin. Otherwise, the rules stay the same.