Becoming the superuser

In order to do most administrative tasks, you'll need root or superuser privilege, and there are primarily two ways to get that:

  1. log in as the root account directly (a good application for one of the unused virtual consoles), or

  2. switch to root from a non-root account with the su command.


As much as possible, you should avoid using the root account unless it's absolutely necessary for system administration. Even if you're the administrator, make sure you have a regular, non-root account for personal activity, and leave the root account for work that requires real privilege.

If you're already logged in as a regular user, you can switch to having root privilege using the su command in one of two ways (both of which require you to know the root password, of course). The first variation:

$ su
simply gives you root power, but leaves you with your non-root, regular user account environment, such as current working directory, search path and so on.

The second variation:

$ su -
switches to the root account and simulates the actual login process, which means you end up in root's home directory, with root's search path and so on. In either case, you can return to your regular account by typing exit.

So which is the preferred method? It depends on what you're trying to do. If you plan on hanging out in the root account for a while, you're best off switching to have root's entire environment, including root's standard search path, with su -.

On the other hand, if you just need root power to, say, list a protected file, you might as well use the simpler su, since you really have no need for root's entire environment. It's entirely up to you.


In order to truly appreciate the difference between these two techniques, after you switch to root, run any of the following commands to see clearly the difference in your new identity and environment:

$ id
$ groups
$ echo $PATH