Chapter 3. System Administration Basics

Becoming the Superuser

Normal users, for the most part, can modify only the files they own. One special user, called the superuser or root, has full access to the machine and can do anything on it. Superuser privileges are mainly for system administration tasks; use them only when absolutely necessary so you don’t accidentally harm your Linux system. And don’t log in as root unless you must (e.g., when rescuing a broken boot process).

Warning

Superuser commands can destroy a Linux system if you’re not careful.

You can become the superuser in several ways. One is to use the sudo command to gain superuser abilities for the duration of a single command. Simply type “sudo” followed by the command. You may be prompted for your password, depending on how sudo is configured on your machine:

sudo rm some_protected_file
[sudo] password: xxxxxxxx       Your own password

To maintain your superuser powers without constantly running sudo, launch a superuser shell with either of the following commands:

sudo -ssudo bash

A superuser shell is convenient, say, for browsing through many protected directories with cd. When finished executing commands as the superuser, press ^D or run exit to end the superuser shell and become yourself again. If you forget whether your shell is a superuser shell or just a normal one, check your identity with the whoami command. If you’re the superuser, it displays root.

Another way to become the superuser is the su command, ...

Get Linux Pocket Guide, 4th Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.