What is the Difference between 'su' and 'su-' ?

Answer Posted / alf55

Answer 2 is the most correct. Really "su" is "switch user"
and its format is "su optional_options optional_username"
where a missing "username" defaults to "root".

The options "-", "-l", and "--login" are all equivalent.

When the "-" is used, the shell is initialized as if logged
into the machine as the specified user (hence you also end
up in your the home directory of "username". Without the
"-", the current environment is left intact but the user has
been switched to that of "username" hence you are still in
the current directory.

From the "man su" page:
{{{
-, -l, --login
Provide an environment similar to what the user
would expect had
the user logged in directly.

When - is used, it must be specified as the last
su option. The
other forms (-l and --login) do not have this
restriction.
}}}

Is This Answer Correct ?    8 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is $@ in shell?

541


What is the use of cp p command?

575


What is the command to check cpu speed in linux?

530


How do I check dns entry?

565


How do I know my linux shell version?

517






How do you open a command prompt when issuing a command?

562


What is $$ in shell script?

519


What is the command to delete a file linux?

532


How do you kill a process in linux?

558


How do I find the linux version?

513


The ‘logout’ built in command is used to

764


What is the makefile in c?

549


You have a tab delimited file called phonenos and want to change each tab to four spaces. What command can you use to accomplish this?

561


What does && mean in bash?

580


What is difference between sh and bash?

516