su command

What's the behavoir of su command when it is invoked in each of the following form;
su
su -
su - someusername

If you don't provide the user-name, the default assumption is super user (root)

su => login as root
su someuser => login as someuser

a hyphen (-) is an option flag which tells whether the new users environment has to be exported or not. ( running .profiles, various environment settings for the target user)

so in that way, you actually have four options:

su -
su
su - someusername
su someusername

su - or just su?

Sorry, I should have mentioned that.

with hyphen, the new user environment will be exported.

1 Like