Difference Between Su, Sudo Su, Sudo -i, and Sudo -s

Linux TLDR
Last Updated:
Reading time: 1 minutes

There are tons of reasons to switch to another user’s or the root user’s account; however, there are multiple ways to do so, which you are going to learn today.

Tutorial Details

DescriptionDifferent ways to switch user account
Difficulty LevelModerate
Root or Sudo PrivilegesYes
OS CompatibilityUbuntu, Manjaro, Fedora, etc.
Prerequisitessudo, su
Internet RequiredNo

su command

The “su” command is the most common way to switch to another user account. If you are the root user, it will not ask for a password.

However, if you are not a root user then you are still able to switch to another user account unless you know their account password.

$ su jake

Output:

Switching user using su command

sudo su command

The sudo su command is also similar to the previous command, except that it is mostly used by users with sudo privileges.

While using this command, you must know your current user password with sudo privileges.

$ sudo su jake

Output:

Switching user using su command with superuser privilege

sudo -i command

Again, it is also similar to the previous two commands.

You can use this command to execute a command as a root user without switching to the root account by specifying your current account password with sudo privileges, as shown.

$ sudo -i whoami

Output:

Executing command with different user

sudo -s command

Again, identical to the above command, “No, you are WRONG!” This command is mostly used to switch to the root user account without reading or changing any user’s environmental files.

It is best used when you want to access the root account with its $SHELL environmental value.

$ sudo -s

Output:

Executing command with different user with user environment

That’s the final end; I’ll talk to you in the next article.

Join The Conversation

Users are always welcome to leave comments about the articles, whether they are questions, comments, constructive criticism, old information, or notices of typos. Please keep in mind that all comments are moderated according to our comment policy.