Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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
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
@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
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
+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
+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
@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

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .