Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I thought that using su as a regular user made you root temporarily, but encountered an issue where I get "bash: usermod: command not found" when I try to perform a usermod with su, whereas the command definitely exists when I log in as root.

Are super user and root different things? If so, what limitations should I be aware of?

share|improve this question
3  
sudo is there to protect you from yourself as it is too easy to make mistakes running as root. I've been a unix-head since way before sudo, never make an rm I didn't mean, and still use sudo in preference to a root shell. Typing 4 characters, a space, and sometimes my user password requires far more awareness of root privilege than having # as a shell prompt. –  msw Jul 6 '10 at 22:07
1  
@msw: true, but sometimes sudo is unnecessarily inconvenient, e.g. when you're going to be running a series of commands as root or you want to take advantage of filename completion in rwx------ directories, or something like that. What I do is set the root shell prompt to display in red and my regular user's shell prompt to display in green. Works great and it's pretty too ;-) (and I do usually use sudo too) –  David Z Jul 7 '10 at 4:11
add comment

1 Answer

up vote 12 down vote accepted

There's no difference between "the super user" and "root". But the thing is, su (which actually stands for "switch user", I believe) doesn't entirely emulate the environment you would get if you logged in directly as root. For instance, usually when you run su, environment variables from your current shell are carried over to the subshell in which you're logged in as root. (Except for PATH; see the man page for details)

To get around this, you can use the -l (or --login) option to su, which will attempt to duplicate the environment you would get if you actually logged in as root.

share|improve this answer
10  
+1, right answer. I typically use just the dash instead: su -. Check your su man page to verify that su - and su -l act the same on your system. –  Doug Harris Jul 6 '10 at 20:45
    
Perfect- thanks guys –  Yarin Jul 6 '10 at 20:47
3  
+1 for switch user. Not many people remember that it can be used for any username if you're in wheel. –  AndrejaKo Jul 6 '10 at 21:14
    
@AndrejaKo: regarding /in wheel/ - does any su check that? (I know GNU version ignores wheel completely.) –  grawity Jul 7 '10 at 12:00
1  
@Yarin: actually there is: sudo -i will simulate an initial login by invoking the shell of the specified user (root by default) as a login shell. This should have mostly the same effect as su -l but it's a different mechanism, so it might not be exactly the same down to every detail. See the man page for sudo for details. –  David Z Jul 9 '10 at 0:14
show 5 more comments

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.