LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   What is different between su <username>and su - <username> (https://www.linuxquestions.org/questions/linux-newbie-8/what-is-different-between-su-username-and-su-username-764449/)

pinga123 10-25-2009 11:54 PM

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.

lhorace 10-26-2009 12:04 AM

'su -' is a login shell, where you can assume the user environment of the target user

pinga123 10-26-2009 12:09 AM

Even Su <username> has the same effect
Why do we use hyphen in between?

lhorace 10-26-2009 12:35 AM

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.