Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

When I use

su root

and then use

gnome-terminal

I get warning

** (gnome-terminal:2677): WARNING **: Failed to connect to the session manager: None of the authentication protocols specified are supported

and new terminal window does not opens.But when I use

su -

and then use

gnome-terminal

new window opens without any warning . Why is it so ?

share|improve this question

1 Answer 1

up vote 2 down vote accepted

The environment setup when providing - is much more complete. From the man page:

The optional argument - may be used to provide an environment 
similar to what the user would expect had the user logged in directly.

In particular SESSION_MANAGER is missing if you do su root.

You can output the environments by using env | sort > /var/tmp/XXX.env with XXX being different for the - and root invocation, and then compare the output using diff. In my setup (Ubuntu 12.04) this results in about twice as many lines in the su - case (53 vs. 27).

share|improve this answer
    
So when do we use "su root" ? [ I mean If we can use "su -" for everything ( + some extra benefits ) what is the use of having "su root" ] –  Tushar Makkar May 14 '13 at 5:28
    
That depends on what you want to achieve. su - takes longer to initialize, that might not be a problem in your use case. I personally tend to use sudo -s -H to get an interactive root shell. That is setup on my system so I can use my own password (instead of the root password). –  Anthon May 14 '13 at 5:34

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.