Professional Documents
Culture Documents
geeksforgeeks.org/difference-between-su-and-su-command-in-linux/
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).
su
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
3/3