Linux Login as Superuser ( root user )

September 8, 2019

Rate this post

How do I login as superuser or root user in a Linux operating systems? How do I become superuser in Linux?

The superuser, or root, is a special user account used for system administration purpose on Linux.

Linux superuser

In Linux and Unix like computer operating systems, root is the conventional name of the user who has all rights or permissions (to all files and programs) in all modes (single- or multi-user). The root user can do many things an ordinary user cannot, such as changing the ownership of files and binding to ports numbered below 1024. The etymology of the term may be that root is the only user account with permission to modify the root directory of a Unix system.

Linux Login as Superuser

You need to use any one of the following command to log in as superuser / root user on Linux:

  1. su command – Run a command with substitute user and group ID in Linux
  2. sudo command – Execute a command as another user on Linux

How to become superuser in Linux

Let us see some examples of the su and sudo command to become superuser in Linux.

Become a superuser in Linux using sudo command

You must be part of special secondary group on Linux:

  • sudo group on a Debian or Ubuntu Linux
  • wheel group on a CentOS/RHEL/Fedora/Oracle Linux

You can see your secondary group membership by running either groups command or id command
$ groups
$ id

Next run the following command to become a root/super user:
$ sudo -i
When promoted type your password to gain root shell.

Log in as a superuser/root user using the sudo command on Linux

Superuser login – How to become Superuser in Linux using su

Under Linux (and other Unixish operating systems) you use command called su. It is used is used to become another user during a login session or to login as super user. If invoked without a username, su defaults to becoming the super user. It is highly recommend that you use argument - to su command. It is used to provide an environment similar to what the user root would expect had the user logged in directly. Type su command as follows:
$ su -
Sample outputs:


Once you typed the root user password, you become super or root user.

Exiting from su or sudo session

You simply need to type the following exit command or logout command:
Another option is to press the CTRL and d keys simultaneously to exit from su or sudo session:

How to exit from su or sudo command

See also:

Posted by: SXI ADMIN

The author is the creator of SXI LLC and a seasoned sysadmin, DevOps engineer, and a trainer for the Linux operating system/Unix shell scripting. Get the latest tutorials on SysAdmin, Linux/Unix and open source topics via RSS/XML feed or weekly email newsletter.