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

You issue the command head * what would the resulting output be?

535


What is the symbol of linux?

552


How use more command in linux?

546


What is tty name?

564


What is s in permission linux?

515






why is the tar command used?

548


What is df -h command?

665


What is bc command in unix?

521


What is devops model?

524


How do I check my disk space?

473


Brief about finger username?

566


In order to display the last five commands you have entered using the fc command, you would type?

522


How do I list directories in linux?

562


What are commands in grammar?

529


What is difference between comm and CMP command?

527