I would like to know what is the difference between

  • su -
  • sudo bash
  • sudo sh

I cannot login as root while doing su - because I do not have the root password - I mean I have my user password with which I can sudo "command" but this password does not work for su - I can log in as root with sudo bash with my user password and I can login while doing sudo sh but then I get a command prompt in this form #

2 Answers 2



In Linux (and Unix in general), there is a SuperUser named Root. The SuperUser can do anything and everything, and thus doing daily work as the SuperUser can be dangerous. You could type a command incorrectly and destroy the system. Ideally, you run as a user that has only the privileges needed for the task at hand. In some cases, this is necessarily Root, but most of the time it is a regular user.

su -

This command is used to login at root account.
By default, the Root account password is locked in Ubuntu. This means that you cannot login as Root directly or use the su command to become the Root user. However, since the Root account physically exists it is still possible to run programs with root-level privileges. This is where sudo comes in - it allows authorized users (normally "Administrative" users) to run certain programs as Root without having to know the root password.

See How to Enable Root Account.

sudo sh

This command runs "sh" as a super user.
The sh utility is a command language interpreter that shall execute commands read from a command line string, the standard input, or a specified file.

sudo bash

This command runs "bash" as a super user.
Bash is the shell, or command language interpreter. Bash is an sh-compatible shell that incorporates useful features from the Korn shell (ksh) and C shell (csh). It is intended to conform to the IEEE POSIX P1003.2/ISO 9945.2 Shell and Tools standard. It offers functional improvements over sh for both programming and interactive use. In addition, most sh scripts can be run by Bash without modification.

References: 1, 2, 3.

  • 7
    It's worth noting that you can log in as the super user by running sudo su - without a root password. Because sudo runs the su - command with root permissions, you will only be prompted for the user's password. This has the advantage of setting up the root user's environment, which may not be done by simply running a shell with sudo.
    – Aaron D
    Feb 26, 2013 at 2:19
  • A good explanation of the env vars that change with these: unix.stackexchange.com/questions/35338/…
    – alchemy
    Apr 24, 2023 at 4:48

su -:

This will change your user identifier and inherit the environment variables as if you had logged in with that user. Normally you would use the format su - <userid> to login as the user . If you drop the "userid" it assumes you are trying to login as root - which you can't (unless you change the root password).

sudo bash & sudo sh:

Anything after the sudo is a program to run - so in these cases you are asking to run a couple of shells - bash and dash respectively. use man bash and man sh for more details on the different shells.

Related Questions:

  • Ok, thanks for reply but what is the default password for root then ? Where can I find it ?
    – Patryk
    Aug 14, 2011 at 11:41
  • @lordmonkey root doesn't have a password, and doesn't need one. sudo -i will give you a login shell like su - would, except sudo asks for your password, not root's.
    – geirha
    Aug 14, 2011 at 13:39

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .