The superuser, or root, is a special user account used for system administration purpose on Linux.
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:
- su command – Run a command with substitute user and group ID in Linux
- 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
Next run the following command to become a root/super user:
$ sudo -i
When promoted type your password to gain root shell.
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 -
Password: <TYPE ROOT PASSWORD> #
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: