Tuesday, September 28, 2010

A Note On Su

I just learned this yesterday, and thought I'd share.

On a Linux system, doing:
(sudo) su -

And doing
(sudo) su

Does different things. When you include the dash, it loads root's environment. When you skip the dash, it makes you root but leaves you in your standard user environment. This is obvious once you know what to look for, but it took me a minute to figure out when I had forgotten that dash.

1 comment:

  1. funny, I just saw a bug on a system involving this exact issue. What's particularly nasty is when you expect root's path statement to be in force, but your path is present instead. CentOS, for example, doesn't give regular users the same path that includes useradd. Fun ensues.