What is different between su <username>and su - <username>
Hi guys,
What is different between su <username>and su - <username> Is there any other options available to switch user. |
'su -' is a login shell, where you can assume the user environment of the target user
|
Even Su <username> has the same effect
Why do we use hyphen in between? |
su, without the hyphen, you continue to retain your current Environment. In simple terms, just the $USER and $HOME change to root. While the rest of bash Global variables stay the same. On certain distributions like OpenSuSe, even when I login as just su, I don't have access to 'fdisk' as opposed to su -.
Variable(s) are not the only thing that changes between su and su -. Like 'su' is a emulated session and 'su -' is the real deal. Probably can start GUI applications in just 'su' and fail in 'su -', unable to connect to X server. Something to that effect. |
All times are GMT -5. The time now is 04:14 PM. |