Linux Login as Superuser ( root user )

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:
🐧 Get the latest tutorials on Linux, Open Source & DevOps via RSS feed or Weekly email newsletter.

🐧 14 comments so far... add one

CategoryList of Unix and Linux commands
Disk space analyzersdf ncdu pydf
File Managementcat cp mkdir tree
FirewallAlpine Awall CentOS 8 OpenSUSE RHEL 8 Ubuntu 16.04 Ubuntu 18.04 Ubuntu 20.04
Network UtilitiesNetHogs dig host ip nmap
OpenVPNCentOS 7 CentOS 8 Debian 10 Debian 8/9 Ubuntu 18.04 Ubuntu 20.04
Package Managerapk apt
Processes Managementbg chroot cron disown fg jobs killall kill pidof pstree pwdx time
Searchinggrep whereis which
User Informationgroups id lastcomm last lid/libuser-lid logname members users whoami who w
WireGuard VPNAlpine CentOS 8 Debian 10 Firewall Ubuntu 20.04
14 comments… add one
  • ALHASSAN HADARU Feb 15, 2011 @ 8:43

    i like to learning more about linux

  • qsdf Jan 12, 2012 @ 21:23

    It is interesting to notice how easy it is to find this information on the web, how to login as a superuser, and how it is difficult to find the information about how to log OUT of superuser (exit). Wouldn’t it make sense to put these things together ? I guess that someone who just learnt how to log in as a superuser would also immediately need to know how to log out.
    And by the way, your answer after “A” doesn’t answer the questions “Q” at the beginning of the article.

  • Danji Jun 5, 2012 @ 23:51

    Hey, i tried this but my linux said:
    Error with approval ( think thats how you translate it..
    its bothering me alot and i tripple checked the password it is correct

  • German Islas Jr Jun 9, 2012 @ 4:21

    what version of lunux are you using? if you are using any ubuntu based linux for example you, you can only use the super user to run comands, you cant stay loged in as the super user.

    Ex: to install an aplication, you would opne a terminal and enter

    sudo apt-get install name_of_application.

    the sudo or su comand will indicate to linux that you are trying to run the comand as the super user or administrator, but in ubuntu after the application is done installing it will go back to regular user to aboid any security breach. y have to realize that the when you are in super user mode it can be verry danguros becasue bc you can do anything, like deleting all you files and messing up your operating system.

    so in conclution you get that message because your linux you might not be running any other comands after the sudo or su comand.

    i hope that made sense.

  • shainy Jul 27, 2012 @ 17:36

    i am grave trouble i forgot ma superuser password hw to recover it

  • vijay kumar Aug 3, 2013 @ 5:58

    I am new to linux, i want to learn more about linux as much possible. i am using ubuntu and suse.
    i try to log in as supper user by su command, and provide password i used to login my system but it shows Authentication failure. please guide me.

    Thanks and regards

  • rohit Sep 9, 2013 @ 6:33

    Earlier i used to login to root by typing ip address and port, i just remember the ip address but i forgot the port number, can anybody please help.

    • Chaos Feb 12, 2014 @ 6:53

      I think you are using telnet or ssh, if telnet it is port 23 and for ssh it uses port 22. Hope it helps.

  • rini sowmya Oct 2, 2013 @ 6:43

    i just now logged in as super user but i want to delete it.what i should do for that???

    • Caleb Jan 10, 2017 @ 22:14

      All you need to do is type: Exit

      or press Control D

  • Manu May 25, 2014 @ 2:29

    thanks for this! learning linux command line scripts now after installing fedora in my nephew’s inspiron 1525, was wondering how to get to root user, other sites weren’t explaining well enough so again, thanks a million! :)

  • Caleb Jan 10, 2017 @ 22:10

    Being a super user can be VERY dangerous so I suggest you know what your doing if your going to become a super user but another way to get root access is to type into the command line:

    sudo -i

  • agilan Sep 12, 2020 @ 8:08

    su: Authendication failiure

Leave a Reply

Your email address will not be published.

Use HTML <pre>...</pre> for code samples. Still have questions? Post it on our forum