Operation Manual
The Linux Command Line
161
Notes:
Lesson 6.3: The superuser
The “sudo” command introduces the “superuser” or “root user”. The term “root”
is the name for the main administrator in a “Unix-like” system, such as Linux.
There are many commands that only the root user can run.
Depending on the version of Linux you are using, you will either have to log on as
the root user or prefix your command with “sudo”. The default Debian distribution
of Linux, for instance, has no root password set. So you will have to use the
“sudo” command.
By using “sudo”, you’re saying, “Do the following command as the root user.”
When you do this, you will be asked for your password and, if you have the system
permissions of a root user (commonly called “being in the admin group”), then
the command will be run. If you don’t have root permissions, you will get an
error message.
Let’s look at the example of adding a new user to your system, something that
only the root user can do. On Debian, the command would look like this:
sudo adduser brian
This will start a script allowing you to set up a new user called “brian”. If you ever
try to do something in the command line and get the error message, “Only root
can ...” then try the sudo command – it may fix your problem.
To find out more about “sudo” command, see its Wikipedia entry:
http://en.wikipedia.org/wiki/Sudo
sudo
If you have the appropriate permissions, execute the following
command as the superuser.
Becoming the admin user
There is another way of doing things as root user and that is by using the “su”
command, which stands for “substitute user” (or superuser). Invoking the “su”
command means “become the root user”.
As before, you’ll be asked to enter your password to make sure that you have
superuser rights. Once you have successfully authenticated with your password,
all commands run as the superuser.
In some systems, however, you won’t be able to use the “su” command because,
by default, the root user isn’t enabled. In this case, you will have to enable the root
user, using this command:
passwd root