Skip to Main Content
Linux Pocket Guide
book

Linux Pocket Guide

by Daniel J. Barrett
February 2004
Beginner content levelBeginner
200 pages
5h 40m
English
O'Reilly Media, Inc.
Content preview from Linux Pocket Guide

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. To become the superuser, log in as yourself and type:

$ su -l
Password: ********
#

You will be prompted for the superuser password (which we presume you know, if it’s your computer). Your shell prompt will change to a hash mark (#) to indicate you are the superuser. When finished executing commands as the superuser, type ^D or run exit to end the superuser shell and become yourself again.

This is the simplest way to obtain superuser privileges on the system. There are other programs for doing so which offer more control, such as sudo, but they are beyond the scope of this book.

If you provide a username to su:

$ su -l jones
Password: ********

you can become that user (provided you know her password).

Useful options

-l

Run a login shell. You almost always want this option, so root’s proper search path is set.

-m

Preserve your current environment variables in the new shell.

-c command

Run just this command (as the other user) and exit. If you need to do this a lot, read the sudo manpage.

-s shell

Run the given shell (e.g., /bin/bash).

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Linux Pocket Guide, 2nd Edition

Linux Pocket Guide, 2nd Edition

Daniel J. Barrett
Linux in a Nutshell, 6th Edition

Linux in a Nutshell, 6th Edition

Ellen Siever, Stephen Figgins, Robert Love, Arnold Robbins

Publisher Resources

ISBN: 9780596806347Errata Page