Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                

Immediate download Linux pocket guide 1st Edition Daniel J Barrett ebooks 2024

Download as pdf or txt
Download as pdf or txt
You are on page 1of 57

Download the full version of the ebook at

https://ebookultra.com

Linux pocket guide 1st Edition Daniel J


Barrett

https://ebookultra.com/download/linux-pocket-
guide-1st-edition-daniel-j-barrett/

Explore and download more ebook at https://ebookultra.com


Recommended digital products (PDF, EPUB, MOBI) that
you can download immediately if you are interested.

Linux Pocket Guide 3rd Edition Daniel J. Barrett

https://ebookultra.com/download/linux-pocket-guide-3rd-edition-daniel-
j-barrett/

ebookultra.com

Linux Pocket Guide 4th Edition Daniel Barrett

https://ebookultra.com/download/linux-pocket-guide-4th-edition-daniel-
barrett/

ebookultra.com

Macintosh Terminal Pocket Guide Take Command of Your Mac


1st Edition Daniel J. Barrett

https://ebookultra.com/download/macintosh-terminal-pocket-guide-take-
command-of-your-mac-1st-edition-daniel-j-barrett/

ebookultra.com

Linux Guide to Linux Certification 2nd Edition Eckert


Schitka

https://ebookultra.com/download/linux-guide-to-linux-
certification-2nd-edition-eckert-schitka/

ebookultra.com
Understanding the Linux Kernel 3rd Edition Daniel P. Bovet

https://ebookultra.com/download/understanding-the-linux-kernel-3rd-
edition-daniel-p-bovet/

ebookultra.com

SQL Pocket Guide Pocket Guides Third Edition Jonathan


Gennick

https://ebookultra.com/download/sql-pocket-guide-pocket-guides-third-
edition-jonathan-gennick/

ebookultra.com

Pocket Guide to Reptiles and Amphibians of East Africa


Pocket Guide Stephen Spawls

https://ebookultra.com/download/pocket-guide-to-reptiles-and-
amphibians-of-east-africa-pocket-guide-stephen-spawls/

ebookultra.com

Ultimate Guide to Architectural Ceiling Treatments Neal


Barrett

https://ebookultra.com/download/ultimate-guide-to-architectural-
ceiling-treatments-neal-barrett/

ebookultra.com

The American Bird Conservancy Guide to Bird Conservation


Daniel J. Lebbin

https://ebookultra.com/download/the-american-bird-conservancy-guide-
to-bird-conservation-daniel-j-lebbin/

ebookultra.com
Linux pocket guide 1st Edition Daniel J Barrett Digital
Instant Download
Author(s): Daniel J Barrett
ISBN(s): 9780596528768, 0596528760
Edition: 1
File Details: PDF, 1.15 MB
Year: 2004
Language: english
Linux
Pocket Guide

Daniel J. Barrett

Beijing • Cambridge • Farnham • Köln • Paris • Sebastopol • Taipei • Tokyo


Linux Pocket Guide
by Daniel J. Barrett

Copyright © 2004 O’Reilly Media, Inc. All rights reserved.


Printed in the United States of America.
Published by O’Reilly Media, Inc., 1005 Gravenstein Highway North,
Sebastopol, CA 95472.
O’Reilly Media, Inc. books may be purchased for educational, business, or
sales promotional use. Online editions are also available for most titles
(safari.oreilly.com). For more information, contact our corporate/
institutional sales department: (800) 998-9938 or corporate@oreilly.com.

Editor: Mike Loukides


Production Editor: Colleen Gorman
Cover Designer: Emma Colby
Interior Designer: David Futato

Printing History:
February 2004: First Edition.

Nutshell Handbook, the Nutshell Handbook logo, and the O’Reilly logo are
registered trademarks of O’Reilly Media, Inc. The Pocket Guide series
designations, Linux Pocket Guide, the image of a roper, and related trade
dress are trademarks of O’Reilly Media, Inc.
Many of the designations used by manufacturers and sellers to distinguish
their products are claimed as trademarks. Where those designations appear
in this book, and O’Reilly Media, Inc. was aware of a trademark claim, the
designations have been printed in caps or initial caps.
While every precaution has been taken in the preparation of this book, the
publisher and author assume no responsibility for errors or omissions, or for
damages resulting from the use of the information contained herein.

0-596-00628-4
[C] [4/06]
Contents

What’s in This Book? 1


What’s Linux? 2
What’s Fedora Linux? 2
What’s a Command? 3
Users and Superusers 4
Reading This Book 5
Getting Help 7
Fedora: A First View 9
The Role of the Shell 10
How to Run a Shell 11
Logins, Logouts, and Shutdowns 11
The Filesystem 13
Home Directories 14
System Directories 15
Operating System Directories 18
File Protections 19
The Shell 20
The Shell Versus Programs 21
Selected bash Features 21
Job Control 29

v
Killing a Command in Progress 32
Terminating a Shell 33
Tailoring Shell Behavior 33
Installing Software 33
Basic File Operations 37
Directory Operations 41
File Viewing 43
File Creation and Editing 51
File Properties 56
File Location 65
File Text Manipulation 71
File Compression and Packaging 82
File Comparison 86
Disks and Filesystems 91
Backups and Remote Storage 95
File Printing 101
Spelling Operations 102
Viewing Processes 104
Controlling Processes 108
Users and Their Environment 110
Working with User Accounts 115

vi | Contents
Becoming the Superuser 118
Working with Groups 119
Basic Host Information 121
Host Location 124
Network Connections 128
Email 132
Web Browsing 136
Usenet News 140
Instant Messaging 142
Screen Output 144
Math and Calculations 149
Dates and Times 152
Scheduling Jobs 155
Graphics and Screensavers 160
Audio and Video 163
Programming with Shell Scripts 166
Whitespace and Linebreaks 166
Variables 166
Input and Output 167
Booleans and Return Codes 167
Conditionals 170
Loops 172
Break and Continue 174

Contents | vii
Creating and Running Shell Scripts 176
Command-Line Arguments 177
Exiting with a Return Code 178
Beyond Shell Scripting 178
Final Words 179
Acknowledgments 179

viii | Contents
Linux Pocket Guide

Welcome to Linux! If you’re a new user, this book can serve


as a quick introduction to Linux in general, and Fedora
Linux specifically, as well as a guide to common and practi-
cal commands. If you have Linux experience, feel free to skip
the introductory material.

What’s in This Book?


This book is a short guide, not a comprehensive reference. We
cover important, useful aspects of Linux so you can work
productively. We do not, however, present every single com-
mand and every last option (our apologies if your favorite
was omitted), nor delve into detail about operating system
internals. Short, sweet, and essential, that’s our motto.
We focus on commands, those pesky little words you type on
a command line to tell a Linux system what to do, like ls
(list files), grep (search for text in a file), xmms (play audio
files), and df (measure free disk space). We touch briefly on
graphical windowing environments like GNOME and KDE,
each of which could fill a Pocket Guide by itself.
We’ve organized the material by function to provide a con-
cise learning path. For example, to help you view the con-
tents of a file, we introduce all file-viewing commands
together: cat for short text files, less for longer ones, od for
binary files, ghostview for Postscript, and so on. Then we
explain each of these commands in turn, briefly presenting
its common uses and options.

1
We assume you have an account on a Linux system and
know how to log in with your username and password. If
not, speak with your system administrator, or if the system is
your own, use the account created when you installed Linux.

What’s Linux?
Linux is a popular, open-source computer software environ-
ment that competes with Microsoft Windows and the Apple
Macintosh. It has four major parts:
The kernel
The low-level operating system, handling files, disks, net-
working, and other necessities we take for granted.
Supplied programs
Thousands of programs for file manipulation, text edit-
ing, mathematics, typesetting, audio, video, computer
programming, web site creation, encryption, CD burn-
ing... you name it.
The shell
A user interface for typing commands, executing them,
and displaying the results. There are various shells in
existence: the Bourne shell, Korn shell, C shell, and oth-
ers. This book focuses on bash, the Bourne Again Shell,
which is often the default for user accounts. However, all
these shells have similar basic functions.
X
A graphical system that provides windows, menus, icons,
mouse support, and other familiar GUI elements. More
complex graphical environments are built on X; the most
popular are KDE and GNOME. Throughout this book, we
discuss programs that open their own X windows to run.

What’s Fedora Linux?


Fedora Linux is one particular Linux distribution or “distro,”
created by Red Hat, Inc. and the Fedora project (for more

2 | Linux Pocket Guide


information, see http://fedora.redhat.com) and formerly called
Red Hat Linux.* Our material is based on Fedora Core 1, the
first official release (November 2003). We focus on the sup-
plied programs and the shell, with brief coverage of X and
the kernel as needed.

What’s a Command?
A Linux command typically consists of a program name fol-
lowed by options and arguments, typed within a shell. The
program name refers to a program somewhere on disk
(which the shell will locate and run). Options, which usually
begin with a dash, affect the behavior of the program, and
arguments usually represent inputs and outputs. For exam-
ple, this command to count the lines in a file:
$ wc -l myfile

consists of a program (wc, the “word count” program), an


option (-l) saying to count lines, and an argument (myfile)
indicating the file to read. (The dollar sign is a prompt from
the shell, indicating that it is waiting for your command.)
Options may be given individually:
$ myprogram -a -b -c myfile Three individual options

or combined behind a single dash:


$ myprogram -abc myfile Same as -a -b -c

though some programs are quirky and do not recognize com-


bined options.
Commands can also be much more complex than running a
single program:
• They can run several programs at once, either in
sequence (one after the other) or connected into a “pipe-
line” with the output of one command becoming the
input of the next.

* Red Hat now focuses on its Enterprise Linux products for higher-end appli-
cations. Most of this book applies to Enterprise and other Linux distros.

What’s in This Book? | 3


• Options are not standardized. The same option (say, -l)
may have different meanings to different programs: in wc
-l it means “count lines of text,” but in ls -l it means
“produce longer output.” In the other direction, two pro-
grams might use different options to mean the same
thing, such as -q for “run quietly” versus -s for “run
silently.”
• Likewise, arguments are not standardized. They often rep-
resent filenames for input or output, but they can be other
things too, like directory names or regular expressions.
• The Linux command-line user interface—the shell—has
a programming language built in. So instead of a com-
mand saying “run this program,” it might say, “if today is
Tuesday, run this program, otherwise run another com-
mand six times for each file whose name ends in .txt.”

Users and Superusers


Linux is a multiuser operating system. On a given computer,
each user is identified by a unique username, like “smith” or
“funkyguy,” and owns a (reasonably) private part of the sys-
tem for doing work. There is also a specially designated user,
with username root, who has the privileges to do anything at
all on the system. Ordinary users are restricted: though they
can run most programs, in general they can modify only the
files they own. The superuser, on the other hand, can create,
modify, or delete any file and run any program.
Some commands in this book can be run successfully only by
the superuser. In this case, we use a hash mark (#) as the
shell prompt:
# command goes here

Otherwise, we will use the dollar sign prompt indicating an


ordinary user:
$ command goes here

4 | Linux Pocket Guide


To become the superuser, you needn’t log out and log back
in; just run the su command (see “Becoming the Superuser”
on page 118) and provide the superuser password:
$ su -l
Password: ********
#

Reading This Book


When we describe a command, we first present its general
usage information. For example, the wc (word count) pro-
gram has the general usage:
wc [options] [files]

which means you’d type “wc” followed, if you choose, by


options and then filenames. You wouldn’t type the square
brackets “[” and “]”: they just indicate their contents are
optional; and words in italics mean you have to fill in your
own specific values, like names of actual files. If you see a
vertical bar between options or arguments, perhaps grouped
by parentheses:
ls (file | directory)

this indicates choice: when running the ls command, you


may supply either a file or directory name as an argument.

Input and output


Most Linux programs accept data from standard input, which
is usually your keyboard, and produce output on standard
output, which is usually your screen. Additionally, error mes-
sages are usually displayed on standard error, which also is
usually your screen but kept separate from standard output.*
Later we’ll see how to redirect standard input, output, and
error to and from files or pipes. But let’s get our vocabulary
straight. When we say a command “reads,” we mean from

* For example, you can capture standard output in a file and still have stan-
dard error messages appear on screen.

What’s in This Book? | 5


standard input unless we say otherwise. And when a com-
mand “prints,” we mean on standard output, unless we’re
talking about computer printers.

Standard heading
Each command description begins with a heading like this
one for the ls (list files) command.

ls [options] [files] coreutils


/bin stdin stdout - file -- opt --help --version

The heading includes the command name (ls) and usage, the
directory in which it is located (/bin), the RPM package that
installed the command (coreutils), and six properties of the
command printed in black (supported) or gray (unsupported):
stdin
The command reads from standard input, i.e., your keyboard,
by default.
stdout
The command writes to standard output, i.e., your screen, by
default.
- file
If you supply a dash (-) argument in place of an input file-
name, the command reads from standard input; and likewise,
if the dash is supplied as an output filename, the command
writes to standard output. For example, the following wc
(word count) command line reads the files file1 and file2, then
standard input, then file3:
$ wc file1 file2 - file3
-- opt
If you supply the command-line option “--” it means “end of
options”: anything appearing later on the command line is
not an option. This is sometimes necessary to operate on a file
whose name begins with a dash, which otherwise would be
(mistakenly) treated as an option. For example, if you have a
file named -foo, the command wc -foo will fail because -foo
will be treated as an (invalid) option. wc -- -foo works. If a
command does not support “--”, you can prepend the current

6 | Linux Pocket Guide


directory path “./” to the filename so the dash is no longer the
first character:
$ wc ./-foo
--help
The option --help makes the command print a help message
explaining proper usage, then exit.
--version
The option --version makes the command print its version
number and exit.

Standard symbols
Throughout the book, we use certain symbols to indicate
keystrokes. Like many other Linux documents, we use the ^
symbol to mean “press and hold the control (Ctrl) key,” so
for example, ^D (pronounced “control D”) means “press and
hold the control key and type D.” We also write ESC to
mean “press the Escape key.” Keys like Enter and Spacebar
should be self-explanatory.

Your friend, the echo command


In many of our examples, we’ll print information to the
screen with the echo command, which we’ll formally describe
in “Screen Output” on page 144. echo is one of the simplest
commands: it merely prints its arguments on standard out-
put, once those arguments have been processed by the shell.
$ echo My dog has fleas
My dog has fleas
$ echo My name shell is $USER Shell variable USER
My name is smith

Getting Help
If you need more information than this book provides, there
are several things you can do.

Getting Help | 7
Run the man command
The man command displays an online manual page, or
manpage, for a given program. For example, to get docu-
mentation on listing files with ls, run:
$ man ls
To search for manpages by keyword for a particular
topic, use the -k option followed by the keyword:
$ man -k database

Run the info command


The info command is an extended, hypertext help sys-
tem covering many Linux programs.
$ info ls
If no documentation is found on a given program, info
displays the program’s manpage. For a listing of avail-
able documentation, type info by itself. To learn how to
navigate the info system, type info info.
Use the --help option (if any)
Many Linux commands respond to the option --help by
printing a short help message. Try:
$ ls --help

Examine the directory /usr/share/doc


This directory contains supporting documents for many
programs, usually organized by program name and ver-
sion. For example, files for the text editor Emacs, Ver-
sion 21.3, are found in /usr/share/doc/emacs-21.3.
GNOME and KDE Help
For help with GNOME or KDE, choose the Help item in
the main menu.
Fedora-specific web sites
The official site is http://fedora.redhat.com. An unofficial
FAQ has sprung up at http://fedora.artoo.net. And of
course there’s the web site for this book:
http://www.oreilly.com/catalog/linuxpg/

8 | Linux Pocket Guide


Usenet newsgroups
Usenet has dozens of newsgroups on Linux topics, such
as comp.os.linux.misc and comp.os.linux.questions. For
Red Hat-specific information, try alt.os.linux.redhat,
comp.os.linux.redhat, linux.redhat, and linux.redhat.misc.
You can search through newsgroup postings at Google
Groups, http://groups.google.com, which is a goldmine of
troubleshooting information.
Google
Search Google for further documentation and tutorials at
http://www.google.com (if you’ve been living in a closet).

Fedora: A First View


When you log into a Fedora (or other) Linux system, you’re
likely to be greeted by a graphical desktop* like Figure 1,
which contains:
• A Windows-like taskbar across the bottom, with:
— A “red hat” icon in the lower left, which when
clicked, pops up a main menu of programs
— Icons to run various programs, such as the Mozilla
web browser, Evolution email program, and Print
Manager for configuring printers
— A desktop switcher (the square with four boxes in it),
which lets you maintain and switch between multi-
ple desktops
— A blue checkmark indicating that your system soft-
ware is up to date, or a red exclamation point warn-
ing you that it isn’t
— A clock
• Other icons on the desktop, such as a trash can for delet-
ing files, a floppy disk, and your home directory (folder)
for storing personal files

* Unless you’re logging in remotely over the network, in which case you’ll
see a command line, prompting you to type a command.

Fedora: A First View | 9


Figure 1. Fedora graphical desktop

Fedora comes with several similar-looking interfaces, and the


one you’re viewing is either GNOME or KDE.* You can tell
the difference by clicking the red hat icon to bring up the
main menu, and choosing Help. The Help window that
appears will clearly indicate GNOME or KDE.

The Role of the Shell


Explore the environment of icons and menus in GNOME
and KDE. These graphical interfaces are, for some users, the
primary way to compute with Linux. Various distros, includ-
ing Fedora, simplify these interfaces so users can edit files,
read email, and browse the Web without much effort.
Nevertheless, the true power of Linux lies behind the scenes.
To get the most out of Linux, you should become proficient

* Depending on your system configuration, the interface might look differ-


ent. GNOME and KDE are very configurable, and Fedora includes a third
interface, twm, with yet another look and feel. (And Linux has other graph-
ical interfaces, too.)

10 | Linux Pocket Guide


in using the shell. It might initially be more difficult than
icons and menus, but once you’re used to it, the shell is quite
easy to use and very powerful. Most of this book discusses
Linux commands run via the shell.

How to Run a Shell


To run a shell within GNOME, KDE, or any other graphical
interface for Linux, you’ll need to open a shell window. This
is done by programs like xterm, gnome-terminal, konsole, and
uxterm. Each of these programs does the same basic thing:
open a window that is running a shell, awaiting your input.
To run a shell window using the three default windowing
interfaces for Fedora:

Interface Take this action... ...to run this shell window program
GNOME Menu : System Tools : Terminal gnome-terminal
or on the desktop:
Right Mouse Button : Open Terminal
KDE Menu : System Tools : Terminal konsole
or on the desktop:
Right Mouse Button : Open Terminal
twm On the desktop: xterm
Right Mouse Button : XTerm

Don’t confuse the window program (like konsole) with the


shell running inside it. The window is just a container—
albeit with fancy features of its own—but the shell is what
prompts you for commands and runs them.
If you’re not running a graphical interface—say, you’re log-
ging in remotely over the network, or directly over an
attached terminal—a shell will run immediately when you
log in. No shell window is required.

Logins, Logouts, and Shutdowns


We assume you know how to log into your Linux account. To
log out from GNOME or KDE, click the red hat icon in the

Logins, Logouts, and Shutdowns | 11


taskbar and choose Logout from the main menu. To log out
from a remote shell, just close the shell (type exit or logout).
Never simply turn off the power to a Linux system: it needs a
more graceful shutdown. To perform a shutdown from
GNOME, choose Logout ➝ Shut Down. From KDE, first log
out, then on the login screen, click the Shutdown icon. To
perform a shutdown from a shell, run the shutdown com-
mand as the superuser, as follows.

shutdown [options] time [message] SysVinit


/sbin stdin stdout - file -- opt --help --version

The shutdown command halts or reboots a Linux system; only the


superuser may run it. Here’s a command to halt the system in 10
minutes, broadcasting the message “scheduled maintenance” to
all users logged in:
# shutdown -h +10 "scheduled maintenance"
The time may be a number of minutes preceded by a plus sign,
like +10, an absolute time in hours and minutes, like 16:25, or the
word now to mean immediately.
With no options, shutdown puts the system into single-user mode, a
special maintenance mode in which only one person is logged in (at
the system console), and all nonessential services are off. To exit
single-user mode, either perform another shutdown to halt or reboot,
or type ^D to bring up the system in normal, multiuser mode.

Useful options
-r Reboot the system.
-h Halt the system.
-k Kidding: don’t really perform a shutdown, just broadcast warning messages
to all users as if the system were going down.
-c Cancel a shutdown in progress (omit the time argument).
-f On reboot, skip the usual filesystem check performed by the fsck program
(described in “Disks and Filesystems” on page 91).
-F On reboot, require the usual filesystem check.

12 | Linux Pocket Guide


For technical information about shutdowns, single-user
mode, and various system states, see the manpages for init
and inittab.

The Filesystem
To make use of any Linux system, you need to be comfort-
able with Linux files and their layout. Every Linux file is con-
tained in a collection called a directory. Directories are like
folders on Windows and Macintosh systems. Directories
form a hierarchy, or tree: one directory may contain other
directories, called subdirectories, which may themselves con-
tain other files and subdirectories, and so on, into infinity.
The topmost directory is called the root directory and is
denoted by a slash (/).*
We refer to files and directories using a “names and slashes”
syntax called a path. For instance, this path:
/one/two/three/four

refers to the root directory /, which contains a directory


called one, which contains a directory two, which contains a
directory three, which contains a final file or directory, four.
If a path begins with the root directory, it’s called an abso-
lute path, and if not, it’s a relative path. More on this in a
moment.
Whenever you are running a shell, that shell is “in” some direc-
tory (in an abstract sense). More technically, your shell has a
current working directory, and when you run commands in that
shell, they operate relative (there’s that word again) to the
directory. More specifically, if you refer to a relative file path in
that shell, it is relative to your current working directory. For
example, if your shell is “in” the directory /one/two/three, and
you run a command that refers to a file myfile, then it’s really

* In Linux, all files and directories descend from the root. This is unlike
Windows or DOS, in which different devices are accessed by drive letters.

The Filesystem | 13
/one/two/three/myfile. Likewise, a relative path a/b/c would
imply the true path /one/two/three/a/b/c.
Two special directories are denoted . (a single period) and ..
(two periods in a row). The former means your current direc-
tory, and the latter means your parent directory, one level
above. So if your current directory is /one/two/three, then .
refers to this directory and .. refers to /one/two.
You “move” your shell from one directory to another using
the cd command:
$ cd /one/two/three

More technically, this command changes your shell’s current


working directory to be /one/two/three. This is an absolute
change (since the directory begins with “/”); of course you
can make relative moves as well:
$ cd d Enter subdirectory d
$ cd ../mydir Go up to my parent, then into directory mydir

File and directory names may contain most characters you


expect: capital and small letters,* numbers, periods, dashes,
underscores, and most other symbols (just not “/”; it’s reserved
for separating directories). In general, however, avoid using
spaces, asterisks, parentheses, and other characters that have
special meaning to the shell. Otherwise, you’ll need to quote or
escape these characters all the time. (See “Quoting” on page 27.)

Home Directories
Users’ personal files are often found in /home (for ordinary
users) or /root (for superusers). Your home directory is typically
/home/your-username: /home/smith, /home/jones, etc. There are
several ways to locate or refer to your home directory.
cd
With no arguments, the cd command returns you (i.e., sets
the shell’s working directory) to your home directory.

* These are not equivalent, since Linux filenames are case-sensitive.

14 | Linux Pocket Guide


HOME variable
The environment variable HOME (see “Shell variables” on
page 23) contains the name of your home directory.
$ echo $HOME The echo command prints its arguments
/home/smith

~
When used in place of a directory, a lone tilde is expanded
by the shell to the name of your home directory.
$ echo ~
/home/smith
When followed by a username (as in ~smith), the shell
expands this string to be the user’s home directory:
$ cd ~smith
$ pwd The “print working directory” command
/home/smith

System Directories
A typical Linux system has tens of thousands of system direc-
tories. These directories contain operating system files, appli-
cations, documentation, and just about everything except
private user files (which typically live in /home).
Unless you’re a system administrator, you’ll rarely visit most
system directories—but with a little knowledge you can
understand or guess their purposes. Their names often con-
tain three parts, which we’ll call the scope, category, and
application. (These are not standard terms, but they’ll help
you understand things.) For example, the directory /usr/local/
share/emacs, which contains local data for the Emacs text
editor, has scope /usr/local (locally installed system files), cat-
egory share (program-specific data and documentation), and
application emacs (a text editor), shown in Figure 2. We’ll
explain these three parts, slightly out of order.

/usr/local/share/emacs
Scope Category Application

Figure 2. Directory scope, category, and application

The Filesystem | 15
Directory path part 1: category
A category tells you the types of files found in a directory. For
example, if the category is bin, you can be reasonably assured
that the directory contains programs. Common categories are
listed below.
Categories for programs
bin Programs (usually binary files)
sbin Programs (usually binary files) intended to be run by the superuser, root
lib Libraries of code used by programs
libexec Programs invoked by other programs, not usually by users; think
“library of executable programs”
Categories for documentation
doc Documentation
info Documentation files for Emacs’s built-in help system
man Documentation files (manual pages) displayed by the man program; the
files are often compressed, or sprinkled with typesetting commands for
man to interpret
share Program-specific files, such as examples and installation instructions
Categories for configuration
etc Configuration files for the system (and other miscellaneous stuff)
init.d Configuration files for booting Linux; also rc1.d, rc2.d, ...
rc.d
Categories for programming
include Header files for programming
src Source code for programs
Categories for web files
cgi-bin Scripts/programs that run on web pages
html Web pages
public_html Web pages, typically in users’ home directories
www Web pages
Categories for display
fonts Fonts (surprise!)
X11 X window system files

16 | Linux Pocket Guide


Categories for hardware
dev Device files for interfacing with disks and other hardware
mnt Mount points: directories that provide access to disks
misc
Categories for runtime files
var Files specific to this computer, created and updated as the computer runs
lock Lock files, created by programs to say, “I am running;” the existence of a
lock file may prevent another program, or another instance of the same
program, from running or performing an action
log Log files that track important system events, containing error, warning,
and informational messages
mail Mailboxes for incoming mail
run PID files, which contain the IDs of running processes; these files are
often consulted to track or kill particular processes
spool Files queued or in transit, such as outgoing email, print jobs, and
scheduled jobs
tmp Temporary storage for programs and/or people to use
proc Operating system state: see “Operating System Directories” on page 18

Directory path part 2: scope


The scope of a directory path describes, at a high level, the pur-
pose of an entire directory hierarchy. Some common ones are:
/ System files supplied with Linux (pronounced “root”)
/usr More system files supplied with Linux (pronounced “user”)
/usr/games Games (surprise!)
/usr/ Files pertaining to the Kerberos authentication system
kerberos
/usr/local System files developed “locally,” either for your organization or your
individual computer
/usr/X11R6 Files pertaining to the X window system

So for a category like lib (libraries), your Linux system might


have directories /lib, /usr/lib, /usr/local/lib, /usr/games/lib, and
/usr/X11R6/lib. You might have other scopes as suits the sys-
tem administrator: /my-company/lib, /my-division/lib, and so on.

The Filesystem | 17
There isn’t a clear distinction between / and /usr in practice,
but there is a sense that / is “lower-level” and closer to the
operating system. So /bin contains fundamental programs
like ls and cat, /usr/bin contains a wide variety of applica-
tions supplied with your Linux distribution, and /usr/local/
bin contains programs your system administrator chose to
install. These are not hard-and-fast rules but typical cases.

Directory path part 3: application


The application part of a directory path is usually the name
of a program. After the scope and category (say, /usr/local/
doc), a program may have its own subdirectory (say, /usr/
local/doc/myprogram) containing files it needs.

Operating System Directories


/boot
Files for booting the system. This is where the kernel
lives, typically named /boot/vmlinuz.
/lost+found
Damaged files that were rescued by a disk recovery tool.
/proc
Describes currently-running processes; for advanced
users.
The files in /proc provide views into the running kernel and
have special properties. They always appear to be zero sized,
read-only, and dated now:
$ ls -l /proc/version
-r--r--r-- 1 root root 0 Oct 3 22:55 /proc/version

However, their contents magically contain information about


the Linux kernel:
$ cat /proc/version
Linux version 2.4.22-1.2115.nptl ...

Mostly these files are used by programs. Go ahead and


explore. Here are some examples.

18 | Linux Pocket Guide


/proc/ioports A list of your computer’s input/output hardware.
/proc/version The operating system version. The uname command prints the same
information.
/proc/uptime System uptime, i.e., seconds elapsed since the system was last booted.
Run the uptime command for a more human-readable result.
/proc/nnn Where nnn is a positive integer, information about the Linux process
with process ID nnn.
/proc/self Information about the current process you’re running; a symbolic link
to a /proc/nnn file, automatically updated. Try ls -l /proc/
self a few times in a row: you’ll see /proc/self changing where it
points.

File Protections
A Linux system may have many users with login accounts.
To maintain privacy and security, each user can access only
some files on the system, not all. This access control is
embodied in two questions:
Who has permission? Every file and directory has an owner
who has permission to do anything with it. Typically the
user who created a file is its owner, but relationships can
get more complex.
Additionally, a predefined group of users may have per-
mission to access a file. Groups are defined by the sys-
tem administrator and are covered in “Working with
Groups” on page 119.
Finally, a file or directory can be opened to all users with
login accounts on the system. You’ll also see this set of
users called the world or simply other.
What kind of permission is granted? File owners, groups,
and the world may each have permission to read, write
(modify), and execute (run) particular files. Permissions
also extend to directories, which users may read (access
files within the directory), write (create and delete files
within the directory), and execute (enter the directory).
To see the ownership and permissions of a file, run:
$ ls -l filename

The Filesystem | 19
To see the ownership and permissions of a directory, run:
$ ls -ld directory_name

The file permissions are the 10 leftmost characters in the out-


put, a string of r (read), w (write), x (execute), and other let-
ters. For example:
drwxr-x---

Here’s what these letters and symbols mean.


Position Meaning
1 File type: - = file, d = directory, l = symbolic link, p = named pipe,
c = character device, b = block device
2–4 Read, write, and execute permissions for the file’s owner
5–7 Read, write, and execute permissions for the file’s group
8–10 Read, write, and execute permissions for all other users

We describe ls in more detail in “Basic File Operations” on


page 37. To change the owner, group ownership, or permis-
sions of a file, use the chown, chgrp, and chmod commands,
respectively, as described in “File Properties” on page 56.

The Shell
In order to run commands on a Linux system, you’ll need
somewhere to type them. That “somewhere” is called the
shell, which is Linux’s command-line user interface: you type
a command and press Enter, and the shell runs whatever pro-
gram (or programs) you’ve requested. To run a shell, see
“Fedora: A First View” on page 9.
For example, to see who’s logged in, you could execute this
command in a shell:
$ who
barrett :0 Sep 23 20:44
byrnes pts/0 Sep 15 13:51
silver pts/1 Sep 22 21:15
silver pts/2 Sep 22 21:18

20 | Linux Pocket Guide


(The dollar sign is the shell prompt, which means the shell is
ready to run a command.) A single command can also invoke
several programs at the same time, and even connect pro-
grams together so they interact. Here’s a command that redi-
rects the output of the who program to become the input of
the wc program, which counts lines of text in a file; the result
is the number of lines in the output of who:
$ who | wc -l
4

telling you how many users are logged in.* The vertical bar,
called a pipe, makes the connection between who and wc.
A shell is actually a program itself, and Linux has several. We
focus on Bash (the “Bourne-Again Shell”), located in /bin/
bash, which is the Fedora Linux default.

The Shell Versus Programs


When you run a command, it might invoke a Linux program
(like who), or instead it might be a built-in command, a fea-
ture of the shell itself. You can tell the difference with the
type command:
$ type who
who is /usr/bin/who
$ type cd
cd is a shell builtin

It is helpful to know what the shell provides versus what


Linux does. The next few sections describe features of the
shell.

Selected bash Features


A shell does much more than simply run commands. It also
provides powerful features to make this task easier. Examples

* Actually, how many interactive shells those users are running. If a user has
several shells running, like the user silver in our example, they’ll have that
many lines of output in who.

The Shell | 21
are wildcards for matching filenames, redirection of com-
mand output and input to and from files, pipes for making
the output of one command become the input of another,
aliases to run common commands quickly, variables for stor-
ing values for use by the shell, and more. We’re just scratch-
ing the surface to introduce you to a set of useful tools. Run
info bash for full documentation.

Wildcards
Wildcards provide a shorthand for specifying sets of files
with similar names. For example, a* means all files whose
names begin with lowercase “a”. Wildcards are “expanded”
by the shell into the actual set of filenames they match. So if
you type:
$ ls a*

the shell first expands a* into the filenames that begin with
“a” in your current directory, as if you had typed:
ls aardvark adamantium apple

ls never knows you used a wildcard: it sees only the final list
of filenames after the shell expansion.

Wildcard Meaning
* Any set of characters except a leading period
? Any single character
[set] Any single character in the given set, most commonly a sequence of
characters, like [aeiouAEIOU] for all vowels, or a range with a dash,
like [A-Z] for all capital letters
[^set] Any single character not in the given set (as above)
[!set]

When using sets, if you want to include a literal dash in the


set, put it first or last. To include a literal closing square
bracket in the set, put it first. To include a ^ or ! literally,
don’t put it first.

22 | Linux Pocket Guide


Brace expansion
Similar to wildcards, expressions with curly braces also
expand to become multiple arguments to a command. The
comma-separated expression:
{a,b,cc,ddd}
expands to:
a b cc dddd
Braces work with any strings, unlike wildcards which are
limited to filenames. For example, sand{X,Y,ZZZ}wich
expands to:
$ echo sand{X,Y,ZZZ}wich
sandXwich sandYwich sandZZZwich
regardless of what files are in the current directory.

Tilde expansion
The shell treats tildes (~) as special characters if they appear
alone or at the beginning of a word.
~ Your home directory
~smith User smith’s home directory

Shell variables
You can define variables and their values by assigning them:
$ MYVAR=3

To refer to a value, simply place a dollar sign in front of the


variable name:
$ echo $MYVAR
3

Some variables are standard and commonly defined by your


shell upon login.

Variable Meaning
DISPLAY The name of your X window display
HOME The name of your home directory

The Shell | 23
Variable Meaning
LOGNAME Your login name
MAIL Path to your incoming mailbox
OLDPWD Your shell's previous directory
PATH Your shell search path: directories separated by colons
PWD Your shell's current directory
SHELL The path to your shell, e.g., /bin/bash
TERM The type of your terminal, e.g., xterm or vt100
USER Your login name

To see a shell’s variables, run:


$ printenv

The scope of the variable (i.e., which programs know about


it) is, by default, the shell in which it’s defined. To make a
variable and its value available to other programs your shell
invokes (i.e., subshells), use the export command:
$ export MYVAR

or the shorthand:
$ export MYVAR=3
Your variable is now called an environment variable, since it’s
available to other programs in your shell’s “environment.”
To make a specific value available to a specific program just
once, prepend variable=value to the command line:
$ echo $HOME
/home/smith
$ HOME=/home/sally echo "My home is $HOME"
My home is /home/sally
$ echo $HOME
/home/smith The original value is unaffected

Search path
A very important variable is PATH, which instructs the shell
where to find programs. When you type any command:
$ who

24 | Linux Pocket Guide


the shell has to find the program(s) in question. It consults
the value of PATH, which is a sequence of directories sepa-
rated by colons:
$ echo $PATH
/usr/local/bin:/bin:/usr/bin:/usr/X11R6/bin:/home/smith/bin

and looks for the who command in each of these directories. If


it finds who (say, /usr/bin/who), it runs the command. Other-
wise, it reports:
bash: who: command not found

To add directories to your shell’s search path temporarily,


modify its PATH variable. For example, to append /usr/sbin to
your shell’s search path:
$ PATH=$PATH:/usr/sbin
$ echo $PATH
/usr/local/bin:/bin:/usr/bin:/usr/X11R6/bin:/home/smith/
bin:/usr/sbin

To make this change permanent, modify the PATH variable in


your startup file ~/.bash_profile, as explained in “Tailoring
Shell Behavior” on page 33. Then log out and log back in.

Aliases
The built-in command alias defines a convenient shorthand
for a longer command, to save typing. For example:
$ alias ll='ls -l'

defines a new command ll that runs ls -l:


$ ll
total 436
-rw-r--r-- 1 smith 3584 Oct 11 14:59 file1
-rwxr-xr-x 1 smith 72 Aug 6 23:04 file2
...

Define aliases in your ~/.bashrc file (see “Tailoring Shell Behav-


ior” on page 33) to be available whenever you log in. To see all
your aliases, type alias. If aliases don’t seem powerful enough
for you (since they have no parameters or branching), see

The Shell | 25
“Programming with Shell Scripts” on page 166, run info bash,
and read up on “shell functions.”

Input/output redirection
The shell can redirect standard input, standard output, and
standard error to and from files. In other words, any com-
mand that reads from standard input can have its input come
from a file instead with the shell’s < operator:
$ mycommand < infile

Likewise, any command that writes to standard output can


write to a file instead:
$ mycommand > outfile Create/overwrite outfile
$ mycommand >> outfile Append to outfile

A command that writes to standard error can have its output


redirected to a file as well:
$ mycommand 2> errorfile

To redirect both standard output and standard error to files:


$ mycommand > outfile 2> errorfile Separate files
$ mycommand > outfile 2>&1 Single file

Pipes
Using the shell, you can redirect the standard output of one
command to be the standard input of another, using the
shell’s pipe (|) operator. For example:
$ who | sort

sends the output of who into the sort program, printing an


alphabetically sorted list of logged-in users.

Combining commands
To invoke several commands in sequence on a single com-
mand line, separate them with semicolons:
$ command1 ; command2 ; command3

26 | Linux Pocket Guide


To run a sequence of commands as above, but stop execu-
tion if any of them fails, separate them with && (“and”)
symbols:
$ command1 && command2 && command3

To run a sequence of commands, stopping execution as soon


as one succeeds, separate them with || (“or”) symbols:
$ command1 || command2 || command3

Quoting
Normally, the shell treats whitespace simply as separating
the words on the command line. If you want a word to con-
tain whitespace (e.g., a filename with a space in it), surround
it with single or double quotes to make the shell treat it as a
unit. Single quotes treat their contents literally, while double
quotes let shell constructs be evaluated, such as variables:
$ echo 'The variable HOME has value $HOME'
The variable HOME has value $HOME
$ echo "The variable HOME has value $HOME"
The variable HOME has value /home/smith

Backquotes cause their contents to be evaluated as a com-


mand; the contents are then replaced by the standard output
of the command:
$ /usr/bin/whoami
smith
$ echo My name is `/usr/bin/whoami`
My name is smith

Escaping
If a character has special meaning to the shell but you want it
used literally (e.g., * as a literal asterisk rather than a wild-
card), precede the character with the backward slash “\”
character. This is called escaping the special character:
$ echo a* As a wildcard, matching “a” filenames
aardvark agnostic apple
$ echo a\* As a literal asterisk
a*

The Shell | 27
$ echo "I live in $HOME" Dollar sign means a variable value
I live in /home/smith
$ echo "I live in \$HOME" A literal dollar sign
I live in $HOME

You can also escape control characters (tabs, newlines, ^D,


and so forth) to have them used literally on the command
line, if you precede them with ^V. This is particularly useful
for tab (^I) characters, which the shell would otherwise use
for filename completion (see “Filename completion” on
page 29).
$ echo "There is a tab between here^V^Iand here"
There is a tab between here and here

Command-line editing
bash lets you edit the command line you’re working on, using
keystrokes inspired by the text editors emacs and vi (see “File
Creation and Editing” on page 51). To enable command-line
editing with emacs keys, run this command (and place it in
your ~/.bash_profile to make it permanent):
$ set -o emacs

For vi keys:
$ set -o vi

vi keystroke
emacs keystroke (first type ESC) Meaning
^P or up arrow k Previous command line
^N or down arrow j Next command line
^F or right arrow l Forward one character
^B or left arrow h Backward one character
^A 0 Beginning of line
^E $ End of line
^D x Delete next character
^U ^U Erase entire line

28 | Linux Pocket Guide


Command history
You can recall previous commands you’ve run—that is, the
shell’s history—and then edit and re-execute them. Some
useful history-related commands are listed below.

Command Meaning
history Print your history
history N Print the most recent N commands in your history
history -c Clear (delete) your history
!! Previous command
!N Command number N in your history
!-N The command you typed N commands ago
!$ The last parameter from the previous command; great for checking
that files are present before removing them:
$ ls a*
$ rm !$
!* All parameters from the previous command

Filename completion
Press the TAB key while you are in the middle of typing a
filename, and the shell will automatically complete (finish
typing) the filename for you. If several filenames match what
you’ve typed so far, the shell will beep, indicating the match
is ambiguous. Immediately press TAB again and the shell will
present the alternatives. Try this:
$ cd /usr/bin
$ ls un<TAB><TAB>

Job Control
jobs List your jobs
& Run a job in the background
^Z Suspend the current (foreground) job
suspend Suspend a shell
fg Unsuspend a job: bring it into the foreground
bg Make a suspended job run in the background

The Shell | 29
All Linux shells have job control: the ability to run programs
in the background (multitasking behind the scenes) and fore-
ground (running as the active process at your shell prompt).
A job is simply the shell’s unit of work. When you run a
command interactively, your current shell tracks it as a job.
When the command completes, the associated job disap-
pears. Jobs are at a higher level than Linux processes; the
Linux operating system knows nothing about them. They are
merely constructs of the shell. Some important vocabulary
about job control is:
foreground job
Running in a shell, occupying the shell prompt so you
cannot run another command
background job
Running in a shell, but not occupying the shell prompt,
so you can run another command in the same shell
suspend
To stop a foreground job temporarily
resume
To cause a suspended job to start running again

jobs
The built-in command jobs lists the jobs running in your current
shell.
$ jobs
[1]- Running emacs myfile &
[2]+ Stopped su
The integer on the left is the job number, and the plus sign identi-
fies the default job affected by the fg (foreground) and bg
(background) commands.

&
Placed at the end of a command-line, the ampersand causes the
given command to run as a background job.
$ emacs myfile &
[2] 28090

30 | Linux Pocket Guide


The shell’s response includes the job number (2) and the process
ID of the command (28090).

^Z
Typing ^Z in a shell, while a job is running in the foreground, will
suspend that job. It simply stops running, but its state is
remembered.
$ mybigprogram
^Z
[1]+ Stopped mybigprogram
$
Now you’re ready to type bg to put the command into the back-
ground, or fg to resume it in the foreground.

suspend
The built-in command suspend will suspend the current shell if
possible, as if you’d typed ^Z to the shell itself. For instance, if
you’ve run the su command and want to return to your original
shell:
$ whoami
smith
$ su -l
Password: *******
# whoami
root
# suspend
[1]+ Stopped su
$ whoami
smith

bg [%jobnumber]
The built-in command bg sends a suspended job to run in the
background. With no arguments, bg operates on the most recently
suspended job. To specify a particular job (shown by the jobs
command), supply the job number preceded by a percent sign:
$ bg %2

The Shell | 31
Some types of interactive jobs cannot remain in the background—
for instance, if they are waiting for input. If you try, the shell will
suspend the job and display:
[2]+ Stopped command line here
You can now resume the job (with fg) and continue.

fg [%jobnumber]
The built-in command fg brings a suspended or backgrounded
job into the foreground. With no arguments, it selects a job,
usually the most recently suspended or backgrounded one. To
specify a particular job (as shown by the jobs command), supply
the job number preceded by a percent sign:
$ fg %2

Killing a Command in Progress


If you’ve launched a command from the shell running in the
foreground, and want to kill it immediately, type ^C. The shell
recognizes ^C as meaning, “terminate the current foreground
command right now.” So if you are displaying a very long file
(say, with the cat command) and want to stop, type ^C:
$ cat bigfile
This is a very long file with many lines. Blah blah blah
blah blah blah blahblahblah ^C
$

To kill a program running in the background, you can bring


it into the foreground with fg and then type ^C, or alterna-
tively, use the kill command (see “Controlling Processes”
on page 108).
In general, ^C is not a friendly way to end a program. If the
program has its own way to exit, use that when possible. You
see, ^C kills the program immediately, not giving it any
chance to clean up after itself. Killing a foreground program
may leave your shell in an odd or unresponsive state, per-
haps not displaying the keystrokes you type. If this happens:

32 | Linux Pocket Guide


1. Press ^J to get a shell prompt. This produces the same
character as the Enter key (a newline) but will work even
if Enter does not.
2. Type the word reset (even if the letters don’t appear
while you type) and press ^J again to run this command.
This should reset your shell.
^C works only when typed into a shell. It will likely have no
effect if typed in a window that is not a shell window. Addi-
tionally, some programs are written to “catch” the ^C and
ignore it: an example is the text editor emacs.

Terminating a Shell
To terminate a shell, either run the exit command or type
^D.*
$ exit

Tailoring Shell Behavior


To configure all your shells to work in a particular way, edit
the files .bash_profile and .bashrc in your home directory.
These files execute each time you log in (~/.bash_profile) or
open a shell (~/.bashrc). They can set variables and aliases,
run programs, print your horoscope, or whatever you like.
These two files are examples of shell scripts: executable files
that contain shell commands. We’ll cover this feature in more
detail in “Programming with Shell Scripts” on page 166.

Installing Software
You will probably want to add further software to your Linux
system from time to time. The most common forms of pack-
aged software for Fedora and many other Linux distros are:

* Control-D indicates “end of file” to any program reading from standard


input. In this case, the program is the shell itself, which terminates.

Installing Software | 33
*.rpm files
Red Hat Package Manager (RPM) files. These are
installed and managed with the programs rpm (manually)
and up2date (automatically).
*.tar.gz files, *.tar.Z files, and *.tar.bz2 files
Compressed tar files. They are packaged with tar and
compressed with gzip (.gz), compress (.Z), or bzip2 (.bz2).
Most new software must be installed by the superuser, so
you’ll need to run the su command (or equivalent) before
installation. For example:
$ su -l
Password: ********
# rpm -ivh mypackage.rpm
...etc...

To locate new software, check your Linux CD-ROMs or visit


fine sites like these:
http://freshmeat.net/
http://freshrpms.net/
http://rpmfind.net/
http://sourceforge.net/

up2date [options] [packages] up2date


/usr/bin stdin stdout - file -- opt --help --version

up2date is the easiest way to keep your Fedora system... well,


up to date. As root, just run:
# up2date

and follow the prompts. This provides a graphical user inter-


face. You can also run up2date in command-line mode:
# up2date -l

to list all updated RPM packages (if any) available for your
system. To download the given packages, run:
# up2date -d packages

34 | Linux Pocket Guide


To install the given RPM packages you have already down-
loaded with up2date -d, run:
# up2date -i packages

up2date downloads RPM packages from Red Hat or Fedora-


related servers over the Internet, so you might need to regis-
ter your system with them the first time you run up2date.
Some Linux users prefer other programs to up2date, such as
yum (http://linux.duke.edu/projects/yum/) and apt (http://ayo.
freshrpms.net/).

rpm [options] [files] rpm


/bin stdin stdout - file -- opt --help --version

If you prefer to install RPM packages by hand, use rpm, the


same package-management program that up2date runs behind
the scenes. rpm not only installs the software, but also makes
sure your system has all prerequisites. For example, if pack-
age superstuff requires package otherstuff that you haven’t
installed, rpm will not install superstuff. If your system passes
the test, however, rpm completely installs the software.
RPM filenames typically have the form name-version.
architecture.rpm. For example, emacs-20.7-17.i386.rpm
indicates the emacs package, Version 20.7-17, for i386 (Intel
80386 and higher) machines. Be aware that rpm sometimes
requires a filename argument (like emacs-20.7-17.i386.rpm)
and other times just the package name (like emacs).
Common commands for manipulating RPM packages are:
rpm -q package_name
Find out if package_name is installed on your system, and
what version. Example: rpm -q textutils. If you don’t
know the name of the package (a chicken-and-egg
problem), list all packages and use grep to search for
likely names:
$ rpm -qa | grep -i likely_name

Installing Software | 35
rpm -ql package_name
List the files included in the given, installed package. Try
rpm -ql emacs.
rpm -qi package_name
Get general information about the package.
rpm -qlp package.rpm
List the contents of an RPM file, not necessarily installed
yet. Use -qip for general information about the RPM file.
rpm -qa
List all installed RPM packages. Useful for piping
through grep to locate a package name:
rpm -qa | grep -i emacs

rpm -qf filename


Print the package that installed a given file on your system.
$ rpm -qf /usr/bin/who
sh-utils-2.0-11

rpm -ivh package1.rpm package2.rpm ...


Install packages not already present on your system
rpm -Fvh package1.rpm package2.rpm ...
Update packages that are already present on your system
rpm -e package_names
Erase (delete) packages from your system. In this case, do
not include the package version number, just the pack-
age name. For example, if you install the GNU Emacs
package emacs-20.7-17.i386.rpm, you would uninstall it
with rpm -e emacs, not rpm -e emacs-20.7-17.rpm.

tar.gz and tar.bz2 files


Packaged software files with names ending .tar.gz and .tar.bz2
typically contain source code that you’ll need to compile
(build) before installation.
1. List the package contents, one file per line. Assure your-
self that each file, when extracted, won’t overwrite

36 | Linux Pocket Guide


something precious on your system, either accidentally
or maliciously:
$ tar tvzf package.tar.gz | less For gzip files
$ tar tvjf package.tar.bz2 | less For bzip2 files
2. If satisfied, extract the files into a new directory:
$ mkdir newdir
$ cd newdir
$ tar xvzf <path>/package.tar.gz For gzip files
$ tar xvjf <path>/package.tar.bz2 For bzip2 files
3. Look for an extracted file named INSTALL or README.
Read it to learn how to build the software, for example:
$ cd newdir
$ less INSTALL
4. Usually the INSTALL or README file will tell you to
run a script called configure in the current directory,
then run make, then run make install. Examine the
options you may pass to the configure script:
$ ./configure --help
Then install the software:
$ ./configure options
$ make
$ su
Password: *******
# make install

Basic File Operations


ls List files in a directory
cp Copy a file
mv Rename (“move”) a file
rm Delete (“remove”) a file
ln Create links (alternative names) to a file

One of the first things you’ll need to do on a Linux system is


manipulate files: copying, renaming, deleting, and so forth.

Basic File Operations | 37


Exploring the Variety of Random
Documents with Different Content
about donations to the Project Gutenberg Literary Archive
Foundation.”

• You provide a full refund of any money paid by a user who


notifies you in writing (or by e-mail) within 30 days of receipt that
s/he does not agree to the terms of the full Project Gutenberg™
License. You must require such a user to return or destroy all
copies of the works possessed in a physical medium and
discontinue all use of and all access to other copies of Project
Gutenberg™ works.

• You provide, in accordance with paragraph 1.F.3, a full refund of


any money paid for a work or a replacement copy, if a defect in
the electronic work is discovered and reported to you within 90
days of receipt of the work.

• You comply with all other terms of this agreement for free
distribution of Project Gutenberg™ works.

1.E.9. If you wish to charge a fee or distribute a Project


Gutenberg™ electronic work or group of works on different
terms than are set forth in this agreement, you must obtain
permission in writing from the Project Gutenberg Literary
Archive Foundation, the manager of the Project Gutenberg™
trademark. Contact the Foundation as set forth in Section 3
below.

1.F.

1.F.1. Project Gutenberg volunteers and employees expend


considerable effort to identify, do copyright research on,
transcribe and proofread works not protected by U.S. copyright
law in creating the Project Gutenberg™ collection. Despite
these efforts, Project Gutenberg™ electronic works, and the
medium on which they may be stored, may contain “Defects,”
such as, but not limited to, incomplete, inaccurate or corrupt
data, transcription errors, a copyright or other intellectual
property infringement, a defective or damaged disk or other
medium, a computer virus, or computer codes that damage or
cannot be read by your equipment.

1.F.2. LIMITED WARRANTY, DISCLAIMER OF DAMAGES -


Except for the “Right of Replacement or Refund” described in
paragraph 1.F.3, the Project Gutenberg Literary Archive
Foundation, the owner of the Project Gutenberg™ trademark,
and any other party distributing a Project Gutenberg™ electronic
work under this agreement, disclaim all liability to you for
damages, costs and expenses, including legal fees. YOU
AGREE THAT YOU HAVE NO REMEDIES FOR NEGLIGENCE,
STRICT LIABILITY, BREACH OF WARRANTY OR BREACH
OF CONTRACT EXCEPT THOSE PROVIDED IN PARAGRAPH
1.F.3. YOU AGREE THAT THE FOUNDATION, THE
TRADEMARK OWNER, AND ANY DISTRIBUTOR UNDER
THIS AGREEMENT WILL NOT BE LIABLE TO YOU FOR
ACTUAL, DIRECT, INDIRECT, CONSEQUENTIAL, PUNITIVE
OR INCIDENTAL DAMAGES EVEN IF YOU GIVE NOTICE OF
THE POSSIBILITY OF SUCH DAMAGE.

1.F.3. LIMITED RIGHT OF REPLACEMENT OR REFUND - If


you discover a defect in this electronic work within 90 days of
receiving it, you can receive a refund of the money (if any) you
paid for it by sending a written explanation to the person you
received the work from. If you received the work on a physical
medium, you must return the medium with your written
explanation. The person or entity that provided you with the
defective work may elect to provide a replacement copy in lieu
of a refund. If you received the work electronically, the person or
entity providing it to you may choose to give you a second
opportunity to receive the work electronically in lieu of a refund.
If the second copy is also defective, you may demand a refund
in writing without further opportunities to fix the problem.

1.F.4. Except for the limited right of replacement or refund set


forth in paragraph 1.F.3, this work is provided to you ‘AS-IS’,
WITH NO OTHER WARRANTIES OF ANY KIND, EXPRESS
OR IMPLIED, INCLUDING BUT NOT LIMITED TO
WARRANTIES OF MERCHANTABILITY OR FITNESS FOR
ANY PURPOSE.

1.F.5. Some states do not allow disclaimers of certain implied


warranties or the exclusion or limitation of certain types of
damages. If any disclaimer or limitation set forth in this
agreement violates the law of the state applicable to this
agreement, the agreement shall be interpreted to make the
maximum disclaimer or limitation permitted by the applicable
state law. The invalidity or unenforceability of any provision of
this agreement shall not void the remaining provisions.

1.F.6. INDEMNITY - You agree to indemnify and hold the


Foundation, the trademark owner, any agent or employee of the
Foundation, anyone providing copies of Project Gutenberg™
electronic works in accordance with this agreement, and any
volunteers associated with the production, promotion and
distribution of Project Gutenberg™ electronic works, harmless
from all liability, costs and expenses, including legal fees, that
arise directly or indirectly from any of the following which you do
or cause to occur: (a) distribution of this or any Project
Gutenberg™ work, (b) alteration, modification, or additions or
deletions to any Project Gutenberg™ work, and (c) any Defect
you cause.

Section 2. Information about the Mission of


Project Gutenberg™
Project Gutenberg™ is synonymous with the free distribution of
electronic works in formats readable by the widest variety of
computers including obsolete, old, middle-aged and new
computers. It exists because of the efforts of hundreds of
volunteers and donations from people in all walks of life.

Volunteers and financial support to provide volunteers with the


assistance they need are critical to reaching Project
Gutenberg™’s goals and ensuring that the Project Gutenberg™
collection will remain freely available for generations to come. In
2001, the Project Gutenberg Literary Archive Foundation was
created to provide a secure and permanent future for Project
Gutenberg™ and future generations. To learn more about the
Project Gutenberg Literary Archive Foundation and how your
efforts and donations can help, see Sections 3 and 4 and the
Foundation information page at www.gutenberg.org.

Section 3. Information about the Project


Gutenberg Literary Archive Foundation
The Project Gutenberg Literary Archive Foundation is a non-
profit 501(c)(3) educational corporation organized under the
laws of the state of Mississippi and granted tax exempt status by
the Internal Revenue Service. The Foundation’s EIN or federal
tax identification number is 64-6221541. Contributions to the
Project Gutenberg Literary Archive Foundation are tax
deductible to the full extent permitted by U.S. federal laws and
your state’s laws.

The Foundation’s business office is located at 809 North 1500


West, Salt Lake City, UT 84116, (801) 596-1887. Email contact
links and up to date contact information can be found at the
Foundation’s website and official page at
www.gutenberg.org/contact

Section 4. Information about Donations to


the Project Gutenberg Literary Archive
Foundation
Project Gutenberg™ depends upon and cannot survive without
widespread public support and donations to carry out its mission
of increasing the number of public domain and licensed works
that can be freely distributed in machine-readable form
accessible by the widest array of equipment including outdated
equipment. Many small donations ($1 to $5,000) are particularly
important to maintaining tax exempt status with the IRS.

The Foundation is committed to complying with the laws


regulating charities and charitable donations in all 50 states of
the United States. Compliance requirements are not uniform
and it takes a considerable effort, much paperwork and many
fees to meet and keep up with these requirements. We do not
solicit donations in locations where we have not received written
confirmation of compliance. To SEND DONATIONS or
determine the status of compliance for any particular state visit
www.gutenberg.org/donate.

While we cannot and do not solicit contributions from states


where we have not met the solicitation requirements, we know
of no prohibition against accepting unsolicited donations from
donors in such states who approach us with offers to donate.

International donations are gratefully accepted, but we cannot


make any statements concerning tax treatment of donations
received from outside the United States. U.S. laws alone swamp
our small staff.

Please check the Project Gutenberg web pages for current


donation methods and addresses. Donations are accepted in a
number of other ways including checks, online payments and
credit card donations. To donate, please visit:
www.gutenberg.org/donate.

Section 5. General Information About Project


Gutenberg™ electronic works
Professor Michael S. Hart was the originator of the Project
Gutenberg™ concept of a library of electronic works that could
be freely shared with anyone. For forty years, he produced and
distributed Project Gutenberg™ eBooks with only a loose
network of volunteer support.

Project Gutenberg™ eBooks are often created from several


printed editions, all of which are confirmed as not protected by
copyright in the U.S. unless a copyright notice is included. Thus,
we do not necessarily keep eBooks in compliance with any
particular paper edition.

Most people start at our website which has the main PG search
facility: www.gutenberg.org.

This website includes information about Project Gutenberg™,


including how to make donations to the Project Gutenberg
Literary Archive Foundation, how to help produce our new
eBooks, and how to subscribe to our email newsletter to hear
about new eBooks.

You might also like