You are on page 1of 3

Difference Between su and su – Command in Linux

geeksforgeeks.org/difference-between-su-and-su-command-in-linux/

February 22, 2021

Difficulty Level : Basic


Last Updated : 15 Mar, 2021

As a new Linux user, you may always face confusion regarding the difference between su
command and su – command. But before knowing about the difference between su and
su – command, we need to make ourselves familiar with Linux User Environment

Linux User Environment: Linux’s systems are multi-user environments. Whenever Linux
operating system creates a new shell session(after a new terminal being started on Linux)
it started preparing an environment for itself. This environment basically holds the
Environment variable(Environmental depends on shell type, Bash is generally used by
most of the Linux distribution).

For example, pwd command is an environmental variable.

The major difference between su & su – command

su command is an abbreviation for “substitute user” because it is used for switching to


another user during a normal login session, but it is often mistaken as an abbreviation for
“super user” as mainly su command is used for getting “super user” privileges as when su
command is run without a username, we automatically become the superuser after giving
the correct root password and after that, we will enter root’s default environment, by only
typing the following command:

su

Now logged in as root user/super user

1/3
Directory Differences between su & su –

When we switch from one user to another user using the normal su command the current
directory remains the same as of the previous user like this

When we switch from one user to another user using su — command the current
directory changes to the home directory of the target user like this:

Path Differences

su command does not create a new User Environment (in the simple term they pretends
to be the target user) but su — creates a totally new User Environment (in the simple
term they are actually the target user) that we can check with environment variables like:

echo $PATH

For su command

For su – command

2/3
For more info check the su manual by typing:

man su

My Personal Notes arrow_drop_up

3/3

You might also like