Linux:
The Complete Reference,
Sixth Edition
About the Author
Richard Petersen, MLIS, teaches Unix and C/C++
courses at the University of California at Berkeley. He
is the author of Linux: The Complete Reference (all six
editions), Red Hat Enterprise and Fedora Linux: The
Complete Reference, Red Hat Linux, Linux Programming,
Red Hat Linux Administrator's Reference, Linux
Programmer's Reference, Introductory C with C++,
Introductory Command Line Unix for Users, and many
other books. He is a contributor to linux.sys-con.com
(Linux World Magazine) with articles on IPv6, the
Fedora operating system, Yum, Fedora repositories,
the Global File System (GFS), udev device
management, and the Hardware Abstraction Layer
(HAL).
About the Technical Editor
Dean Henrichsmeyer has served as technical editor
for a previous edition of Linux: The Complete Reference
and for several editions of another book, Red Hat
Linux: The Complete Reference. He holds a B.S. in
Computer Science and has been working with Linux
for more than a decade. He is currently a site director
for SourceForge, Inc., the media group responsible for
websites such as SourceForge.net, Linux.com,
Slashdot.org, freshmeat.net, and ThinkGeek.com.
Linux:
The Complete
Reference,
Sixth Edition
Richard Petersen
New York Chicago San Francisco
Lisbon London Madrid Mexico City
Milan New Delhi San Juan
Seoul Singapore Sydney Toronto
Copyright © 2008 by The McGraw-Hill Companies. All rights reserved. Manufactured in the United States of America. Except as
permitted under the United States Copyright Act of 1976, no part of this publication may be reproduced or distributed in any form or by
any means, or stored in a database or retrieval system, without the prior written permission of the publisher.
0-07-159664-X
The material in this eBook also appears in the print version of this title: 0-07-149247-X.
All trademarks are trademarks of their respective owners. Rather than put a trademark symbol after every occurrence of a trademarked
name, we use names in an editorial fashion only, and to the benefit of the trademark owner, with no intention of infringement of the
trademark. Where such designations appear in this book, they have been printed with initial caps.
McGraw-Hill eBooks are available at special quantity discounts to use as premiums and sales promotions, or for use in corporate
training programs. For more information, please contact George Hoare, Special Sales, at or (212)
904-4069.
TERMS OF USE
This is a copyrighted work and The McGraw-Hill Companies, Inc. (“McGraw-Hill”) and its licensors reserve all rights in and to the work.
Use of this work is subject to these terms. Except as permitted under the Copyright Act of 1976 and the right to store and retrieve one copy
of the work, you may not decompile, disassemble, reverse engineer, reproduce, modify, create derivative works based upon, transmit, dis-
tribute, disseminate, sell, publish or sublicense the work or any part of it without McGraw-Hill’s prior consent. You may use the work for
your own noncommercial and personal use; any other use of the work is strictly prohibited. Your right to use the work may be terminated
if you fail to comply with these terms.
THE WORK IS PROVIDED “AS IS.” McGRAW-HILL AND ITS LICENSORS MAKE NO GUARANTEES OR WARRANTIES AS TO
THE ACCURACY, ADEQUACY OR COMPLETENESS OF OR RESULTS TO BE OBTAINED FROM USING THE WORK, INCLUD-
ING ANY INFORMATION THAT CAN BE ACCESSED THROUGH THE WORK VIA HYPERLINK OR OTHERWISE, AND
EXPRESSLY DISCLAIM ANY WARRANTY, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO IMPLIED
WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. McGraw-Hill and its licensors do not war-
rant or guarantee that the functions contained in the work will meet your requirements or that its operation will be uninterrupted or error
free. Neither McGraw-Hill nor its licensors shall be liable to you or anyone else for any inaccuracy, error or omission, regardless of cause,
in the work or for any damages resulting therefrom. McGraw-Hill has no responsibility for the content of any information accessed through
the work. Under no circumstances shall McGraw-Hill and/or its licensors be liable for any indirect, incidental, special, punitive, conse-
quential or similar damages that result from the use of or inability to use the work, even if any of them has been advised of the
possibility of such damages. This limitation of liability shall apply to any claim or cause whatsoever whether such claim or cause arises in
contract, tort or otherwise.
We hope you enjoy this
McGraw-Hill eBook! If
you’d like more information about this book,
its author, or related books and websites,
please click here.
Professional
Want to learn more?
To my nieces,
Aleina and Larisa
This page intentionally left blank
Contents at a Glance
Part I Introduction
1 Introduction to Linux . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
2 Getting Started . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
Part II The Linux Shell and File Structure
3 The Shell . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35
4 The Shell Scripts and Programming . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 65
5 Shell Confi guration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 89
6 Linux Files, Directories, and Archives . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 115
Part III Desktop
7 The X Window System, Xorg, and Display Managers . . . . . . . . . . . . . . . . . 145
8 GNOME . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 169
9 KDE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 197
Part IV Linux Software
10 Software Management . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 219
11 Offi ce and Database Applications . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 237
12 Graphics Tools and Multimedia . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 255
13 Mail and News Clients . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 265
14 Web, FTP, and Java Clients . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 281
15 Network Tools . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 301
Part V Security
16 Encryption, Integrity Checks, and Signatures . . . . . . . . . . . . . . . . . . . . . . . . 313
17 Security-Enhanced Linux . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 327
18 IPsec and Virtual Private Networks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 349
19 Secure Shell and Kerberos . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 359
20 Firewalls . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 373
vii
viii
Linux: The Complete Reference
Part VI Internet and Network Services
21 Managing Services . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 401
22 FTP Servers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 423
23 Web Servers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 443
24 Proxy Servers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 467
25 Mail Servers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 477
26 Print, News, Search, and Database Servers . . . . . . . . . . . . . . . . . . . . . . . . . . 503
Part VII System Administration
27 Basic System Administration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 523
28 Managing Users . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 551
29 File Systems . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 583
30 RAID and LVM . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 615
31 Devices and Modules . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 639
32 Kernel Administration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 671
33 Backup Management . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 693
Part VIII Network Administration Services
34 Administering TCP/IP Networks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 707
35 Network Autoconfi guration with IPv6, DHCPv6, and DHCP . . . . . . . . . . 745
36 NFS and NIS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 761
37 Distributed Network File Systems . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 777
A Where to Obtain Linux Distributions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 785
Index . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 787
Contents
Acknowledgments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xxix
Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xxxi
Part I Introduction
1 Introduction to Linux . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
Linux Distributions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
Operating Systems and Linux . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
History of Linux and Unix . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
Unix . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
Linux . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
Linux Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
Open Source Software . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
Linux Software . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
Software Repositories . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
Third-Party Linux Software Repositories . . . . . . . . . . . . . . . . . . . . . . . 11
Linux Offi ce and Database Software . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
Internet Servers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
Development Resources . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
Online Linux Information Sources . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
Linux Documentation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
2 Getting Started . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
Install Issues . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
Accessing Your Linux System . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
The Display Managers: GDM and KDM . . . . . . . . . . . . . . . . . . . . . . . 19
Switching Users . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20
Accessing Linux from the Command Line Interface . . . . . . . . . . . . . . 20
The GNOME and KDE Desktops . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22
KDE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22
XFce4 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22
GNOME . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22
GNOME and KDE Applets . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23
Starting a GUI from the Command Line . . . . . . . . . . . . . . . . . . . . . . . . 24
Desktop Operations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24
Desktop Themes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24
Fonts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
Confi guring Your Personal Information . . . . . . . . . . . . . . . . . . . . . . . . 26
Sessions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27
Using Removable Devices and Media . . . . . . . . . . . . . . . . . . . . . . . . . . 27
Installing Multimedia Support: MP3, DVD, and DivX . . . . . . . . . . . . 27
Command Line Interface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27
ix
For more information about this title, click here
x
Linux: The Complete Reference
Help Resources . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28
Context-Sensitive Help . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29
Application Documentation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29
The Man Pages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29
The Info Pages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29
Software Repositories . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30
Windows Access and Applications . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30
Setting Up Windows Network Access: Samba . . . . . . . . . . . . . . . . . . . 30
Running Windows Software on Linux: Wine . . . . . . . . . . . . . . . . . . . . 31
Part II The Linux Shell and File Structure
3 The Shell . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35
The Command Line . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35
Command Line Editing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37
Command and Filename Completion . . . . . . . . . . . . . . . . . . . . . . . . . . 38
History . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40
History Events . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40
History Event Editing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42
Confi guring History: HISTFILE and HISTSAVE . . . . . . . . . . . . . . . . . 43
Filename Expansion: *, ?, [ ] . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43
Matching Multiple Characters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45
Matching Single Characters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45
Matching a Range of Characters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 46
Matching Shell Symbols . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 46
Generating Patterns . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47
Standard Input/Output and Redirection . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47
Redirecting the Standard Output: > and >> . . . . . . . . . . . . . . . . . . . . . 48
The Standard Input . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 50
Pipes | . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 50
Redirecting and Piping the Standard Error: >&, 2> . . . . . . . . . . . . . . . . . . . . 51
Jobs: Background, Kills, and Interruptions . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52
Running Jobs in the Background . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53
Referencing Jobs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 54
Job Notifi cation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 54
Bringing Jobs to the Foreground . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 54
Canceling Jobs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 55
Suspending and Stopping Jobs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 55
Ending Processes: ps and kill . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 55
The C Shell: Command Line Editing and History . . . . . . . . . . . . . . . . . . . . . . 56
C Shell Command Line Editing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 57
C Shell History . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 57
The TCSH Shell . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 62
TCSH Command Line Completion . . . . . . . . . . . . . . . . . . . . . . . . . . . . 62
TCSH History Editing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 62
The Z-shell . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 63
4 The Shell Scripts and Programming . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 65
Shell Variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 66
Defi nition and Evaluation of Variables: =, $, set, unset . . . . . . . . . . . 66
Variable Values: Strings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 67
Values from Linux Commands: Back Quotes . . . . . . . . . . . . . . . . . . . . 70
Shell Scripts: User-Defi ned Commands . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 70
Executing Scripts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 71
Script Arguments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 71
Environment Variables and Subshells: export and setenv . . . . . . . . . . . . . . . 73
Shell Environment Variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 75
TCSH/C Shell Environment Variables . . . . . . . . . . . . . . . . . . . . . . . . . 76
Control Structures . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 77
Test Operations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 77
Conditional Control Structures . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 78
Loop Control Structures . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 81
TCSH/C Shell Control Structures . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 81
Test Expressions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 82
TCSH Shell Conditions: if-then, if-then-else, switch . . . . . . . . . . . . . . 82
TCSH Shell Loops: while and foreach . . . . . . . . . . . . . . . . . . . . . . . . . . 86
5 Shell Confi guration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 89
Shell Initialization and Confi guration Files . . . . . . . . . . . . . . . . . . . . . . . . . . . 90
Confi guration Directories and Files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 90
Aliases . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 91
Aliasing Commands and Options . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 92
Aliasing Commands and Arguments . . . . . . . . . . . . . . . . . . . . . . . . . . 92
Aliasing Commands . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 93
Controlling Shell Operations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 93
Environment Variables and Subshells: export . . . . . . . . . . . . . . . . . . . . . . . . . 94
Confi guring Your Shell with Shell Parameters . . . . . . . . . . . . . . . . . . . . . . . . 94
Shell Parameter Variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 95
Confi guring Your Login Shell: .bash_profi le . . . . . . . . . . . . . . . . . . . . 101
Confi guring the BASH Shell: .bashrc . . . . . . . . . . . . . . . . . . . . . . . . . . . 105
The BASH Shell Logout File: .bash_logout . . . . . . . . . . . . . . . . . . . . . . 106
The TCSH Shell Confi guration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 107
TCSH/C Aliases . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 107
TCSH/C Shell Feature Variables: Shell Features . . . . . . . . . . . . . . . . . 108
TCSH/C Special Shell Variables for Confi guring Your System . . . . . 109
TCSH/C Shell Initialization Files: .login, .tcshrc, .logout . . . . . . . . . . 111
6 Linux Files, Directories, and Archives . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 115
Linux Files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 116
The File Structure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 117
Home Directories . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 118
Pathnames . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 118
System Directories . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 119
Listing, Displaying, and Printing Files: ls, cat, more, less, and lpr . . . . . . . . 119
Displaying Files: cat, less, and more . . . . . . . . . . . . . . . . . . . . . . . . . . . 120
Printing Files: lpr, lpq, and lprm . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 121
Managing Directories: mkdir, rmdir, ls, cd, and pwd . . . . . . . . . . . . . . . . . . . 121
Creating and Deleting Directories . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 122
Displaying Directory Contents . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 123
Moving Through Directories . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 123
Referencing the Parent Directory . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 124
Contents
xi
xii
Linux: The Complete Reference
File and Directory Operations: fi nd, cp, mv, rm, and ln . . . . . . . . . . . . . . . . . 124
Searching Directories: fi nd . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 124
Copying Files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 126
Moving Files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 129
Copying and Moving Directories . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 129
Erasing Files and Directories: The rm Command . . . . . . . . . . . . . . . . 130
Links: The ln Command . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 130
The mtools Utilities: msdos . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 132
Archiving and Compressing Files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 133
Archiving and Compressing Files with File Roller . . . . . . . . . . . . . . . 133
Archive Files and Devices: tar . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 134
File Compression: gzip, bzip2, and zip . . . . . . . . . . . . . . . . . . . . . . . . . 138
Part III Desktop
7 The X Window System, Xorg, and Display Managers . . . . . . . . . . . . . . . . . 145
The X Protocol . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 146
Xorg . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 147
Xorg Confi guration: /etc/X11/xorg.conf . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 149
Screen . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 150
Files, Modules, and ServerFlags . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 151
Input Device . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 152
Monitor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 153
Device . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 154
ServerLayout . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 154
Multiple Monitors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 155
X Window System Command Line Arguments . . . . . . . . . . . . . . . . . . . . . . . . 155
X Window System Commands and Confi guration Files . . . . . . . . . . . . . . . . 156
XFS Fonts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 158
X Resources . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 158
X Commands . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 160
Display Managers: XDM, GDM, and KDM . . . . . . . . . . . . . . . . . . . . . . . . . . . 160
Xsession . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 162
The X Display Manager (XDM) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 163
The GNOME Display Manager . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 164
The K Display Manager (KDM) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 166
X Window System Command Line Startup: startx, xinit, and xinitrc . . . . . 167
8 GNOME . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 169
GNOME 2.
x
Features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 170
GTK+ . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 171
The GNOME Interface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 171
GNOME Components . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 173
Quitting GNOME . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 173
GNOME Help . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 173
The GNOME Desktop . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 174
Drag and Drop Files to the Desktop . . . . . . . . . . . . . . . . . . . . . . . . . . . 174
Applications on the Desktop . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 175
GNOME Desktop Menu . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 175
Window Manager . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 175
The GNOME Volume Manager . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 176
The GNOME File Manager: Nautilus . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 178
Nautilus Window . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 178
Nautilus Sidebar: Tree, History, and Notes . . . . . . . . . . . . . . . . . . . . . 180
Displaying Files and Folders . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 180
Nautilus Menu . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 181
Navigating Directories . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 181
Managing Files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 182
Application Launcher . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 184
File and Directory Properties . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 184
Nautilus Preferences . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 186
Nautilus as a FTP Browser . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 186
The GNOME Panel . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 187
Panel Properties . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 187
Panel Objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 189
Special Panel Objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 191
GNOME Applets . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 191
Workspace Switcher . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 192
GNOME Window List . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 192
GNOME Confi guration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 193
GNOME Directories and Files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 193
GNOME User Directories . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 194
The GConf Confi guration Editor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 194
9 KDE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 197
The Qt Library . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 198
Confi guration and Administration Access with KDE . . . . . . . . . . . . . . . . . . . 199
The KDE Desktop . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 199
KDE Menus . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 200
Quitting KDE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 201
KDE Desktop Operations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 201
Accessing System Resources from the File Manager . . . . . . . . . . . . . 202
Confi guring Your Desktop . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 203
Desktop Link Files and URL Locations . . . . . . . . . . . . . . . . . . . . . . . . . 203
KDE Windows . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 204
Virtual Desktops: The KDE Desktop Pager . . . . . . . . . . . . . . . . . . . . . 205
KDE Panel: Kicker . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 205
The KDE Help Center . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 206
Applications . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 207
Mounting Devices from the Desktop . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 208
KDE File Manager and Internet Client: Konqueror . . . . . . . . . . . . . . . . . . . . 208
Konqueror Window . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 209
Navigation Panel . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 210
Search . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 211
Navigating Directories . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 211
Copy, Move, Delete, Rename, and Link Operations . . . . . . . . . . . . . . 212
Web and FTP Access . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 213
Confi guring Konqueror . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 213
KDE Confi guration: KDE Control Center . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 214
.kde and Desktop User Directories . . . . . . . . . . . . . . . . . . . . . . . . . . . . 215
Contents
xiii
xiv
Linux: The Complete Reference
MIME Types and Associated Applications . . . . . . . . . . . . . . . . . . . . . . 215
KDE Directories and Files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 216
Part IV Linux Software
10 Software Management . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 219
Software Package Types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 219
Downloading ISO and DVD Distribution Images with BitTorrent . . . . . . . . 220
Red Hat Package Manager (RPM) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 221
The rpm Command . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 222
Querying Information from RPM Packages and Installed Software 224
Installing and Updating Packages with rpm . . . . . . . . . . . . . . . . . . . . 226
Removing RPM Software Packages . . . . . . . . . . . . . . . . . . . . . . . . . . . . 226
RPM: Verifying an RPM Installation . . . . . . . . . . . . . . . . . . . . . . . . . . . 226
Rebuilding the RPM Database . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 227
Debian . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 227
Installing Software from Compressed Archives: .tar.gz . . . . . . . . . . . . . . . . . 228
Decompressing and Extracting Software in One Step . . . . . . . . . . . . 228
Decompressing Software Separately . . . . . . . . . . . . . . . . . . . . . . . . . . . 229
Selecting an Install Directory . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 230
Extracting Software . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 230
Compiling Software . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 231
Confi gure Command Options . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 232
Development Libraries . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 232
Shared and Static Libraries . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 232
Makefi le File . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 233
Command and Program Directories: PATH . . . . . . . . . . . . . . . . . . . . . . . . . . . 233
/etc/profi le . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 234
.bash_profi le . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 234
Subversion and CVS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 235
Packaging Your Software with RPM . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 235
11 Offi ce and Database Applications . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 237
Running Microsoft Offi ce on Linux: CrossOver . . . . . . . . . . . . . . . . . . . . . . . 238
OpenOffi ce.org . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 239
KOffi ce . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 241
KOffi ce Applications . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 241
KParts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 242
GNOME Offi ce . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 243
Document Viewers (PostScript, PDF, and DVI) . . . . . . . . . . . . . . . . . . . . . . . . 244
PDA Access . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 245
Database Management Systems . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 245
SQL Databases (RDMS) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 245
Xbase Databases . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 248
Editors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 248
GNOME Editor: Gedit . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 248
K Desktop Editors: Kate, KEdit, and KJots . . . . . . . . . . . . . . . . . . . . . . 248
The Emacs Editor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 249
The Vi Editor: Vim and Gvim . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 250
12 Graphics Tools and Multimedia . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 255
Graphics Tools . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 255
Photo Management Tools: F-Spot and digiKam . . . . . . . . . . . . . . . . . 256
KDE Graphics Tools . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 257
GNOME Graphics Tools . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 257
X Window System Graphic Programs . . . . . . . . . . . . . . . . . . . . . . . . . . 257
Multimedia . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 258
GStreamer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 259
Sound Applications . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 260
CD Burners and Rippers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 261
Video Applications . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 262
13 Mail and News Clients . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 265
Mail Clients . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 265
MIME . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 266
Evolution . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 267
Thunderbird . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 268
GNOME Mail Clients: Evolution, Balsa, and Others . . . . . . . . . . . . . 269
The K Desktop Mail Client: KMail . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 270
SquirrelMail Web Mail Client . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 270
Emacs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 271
Command Line Mail Clients . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 271
Notifi cations of Received Mail . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 273
Accessing Mail on Remote POP Mail Servers . . . . . . . . . . . . . . . . . . . 274
Mailing Lists . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 275
Usenet News . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 275
Newsreaders . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 277
News Transport Agents . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 278
14 Web, FTP, and Java Clients . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 281
Web Clients . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 281
URL Addresses . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 282
Web Browsers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 282
Creating Your Own Website . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 286
Java for Linux . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 287
Sun, Java-like, JPackage, and Blackdown . . . . . . . . . . . . . . . . . . . . . . . 287
Installing the Java Runtime Environment: JRE . . . . . . . . . . . . . . . . . . 289
Enabling the Java Runtime Environment for Mozilla/Firefox . . . . . 289
The Java Applications . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 289
The Java 2 Software Development Kit . . . . . . . . . . . . . . . . . . . . . . . . . . 289
FTP Clients . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 290
Network File Transfer: FTP . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 290
Web Browser–Based FTP: Firefox . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 291
The K Desktop File Manager: Konqueror . . . . . . . . . . . . . . . . . . . . . . . 292
GNOME Desktop FTP: Nautilus . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 292
gFTP . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 292
wget . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 293
curl . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 293
ftp . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 293
Automatic Login and Macros: .netrc . . . . . . . . . . . . . . . . . . . . . . . . . . . 297
Contents
xv
xvi
Linux: The Complete Reference
lftp . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 298
NcFTP . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 299
15 Network Tools . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 301
Network Information: ping, fi nger, traceroute, and host . . . . . . . . . . . . . . . . 301
GNOME Network Tools: gnome-nettool . . . . . . . . . . . . . . . . . . . . . . . 301
ping . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 302
fi nger and who . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 303
host . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 303
traceroute . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 303
Network Talk and Messenger Clients: VoIP, ICQ, IRC, AIM, and Talk . . . . 304
Ekiga . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 304
ICQ . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 305
Instant Messenger . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 305
Telnet . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 306
RSH, Kerberos, and SSH Remote Access Commands . . . . . . . . . . . . . . . . . . . 307
Remote Access Information . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 308
Remote Access Permission: .k5login . . . . . . . . . . . . . . . . . . . . . . . . . . . 308
rlogin, slogin, rcp, scp, rsh, and ssh . . . . . . . . . . . . . . . . . . . . . . . . . . . . 309
Part V Security
16 Encryption, Integrity Checks, and Signatures . . . . . . . . . . . . . . . . . . . . . . . . 313
Public Key Encryption, Integrity Checks, and Digital Signatures . . . . . . . . 313
Public-Key Encryption . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 314
Digital Signatures . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 314
Integrity Checks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 314
Combining Encryption and Signatures . . . . . . . . . . . . . . . . . . . . . . . . . 315
GNU Privacy Guard . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 316
GnuPG Setup: gpg . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 318
Using GnuPG . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 321
Checking Software Package Digital Signatures . . . . . . . . . . . . . . . . . . . . . . . . 323
Importing Public Keys . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 323
Validating Public Keys . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 324
Checking RPM Packages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 324
Intrusion Detection: Tripwire and AIDE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 325
Encrypted File Systems . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 326
17 Security-Enhanced Linux . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 327
Flask Architecture . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 327
System Administration Access . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 328
Terminology . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 329
Identity . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 329
Domains . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 330
Types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 330
Roles . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 330
Security Context . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 331
Transition: Labeling . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 331
Policies . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 331
Multi-Level Security (MLS) and Multi-Category Security (MCS) . . . . . . . . . 331
Management Operations for SELinux . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 332
Turning Off SELinux . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 332
Checking Status and Statistics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 332
Checking Security Context . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 333
SELinux Management Tools . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 333
semanage . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 334
The Security Policy Analysis Tool: apol . . . . . . . . . . . . . . . . . . . . . . . . 334
Checking SELinux Messages: seaudit . . . . . . . . . . . . . . . . . . . . . . . . . . 334
Allowing Access: chcon and audit2allow . . . . . . . . . . . . . . . . . . . . . . . 334
The SELinux Reference Policy . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 335
Multi-Level Security (MLS) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 336
Multi-Category Security (MCS) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 336
Policy Methods . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 336
Type Enforcement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 336
Role-Based Access Control . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 336
SELinux Users . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 336
Policy Files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 337
SELinux Confi guration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 337
SELinux Policy Rules . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 337
Type and Role Declarations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 338
File Contexts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 339
User Roles . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 339
Access Vector Rules: allow . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 339
Role Allow Rules . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 340
Transition and Vector Rule Macros . . . . . . . . . . . . . . . . . . . . . . . . . . . . 340
Constraint Rules . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 340
SELinux Policy Confi guration Files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 340
Compiling SELinux Modules . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 341
Using SELinux Source Confi guration . . . . . . . . . . . . . . . . . . . . . . . . . . 341
Interface Files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 342
Types Files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 343
Module Files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 343
Security Context Files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 343
User Confi guration: Roles . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 343
Policy Module Tools . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 343
Application Confi guration: appconfi g . . . . . . . . . . . . . . . . . . . . . . . . . 344
Creating an SELinux Policy: make and checkpolicy . . . . . . . . . . . . . . . . . . . . 344
SELinux: Administrative Operations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 345
Using Security Contexts: fi xfi les, setfi les, restorecon, and chcon . . . 345
Adding New Users . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 345
Runtime Security Contexts and Types: contexts . . . . . . . . . . . . . . . . . 346
18 IPsec and Virtual Private Networks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 349
IPsec Protocols . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 349
IPsec Modes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 350
IPsec Security Databases . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 350
IPsec Tools . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 351
Confi guring Connections with setkey . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 351
Security Associations: SA . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 351
Security Policy: SP . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 352
Receiving Hosts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 352
Two-Way Transmissions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 353
Contents
xvii
xviii
Linux: The Complete Reference
Confi guring IPsec with racoon: IKE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 354
Certifi cates . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 355
Connection Confi guration with racoon . . . . . . . . . . . . . . . . . . . . . . . . 355
IPsec and IP Tables: Net Traversal . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 355
IPsec Tunnel Mode: Virtual Private Networks . . . . . . . . . . . . . . . . . . . . . . . . . 356
19 Secure Shell and Kerberos . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 359
The Secure Shell: OpenSSH . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 359
SSH Encryption and Authentication . . . . . . . . . . . . . . . . . . . . . . . . . . . 360
SSH Tools . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 361
SSH Setup . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 362
SSH Clients . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 365
Port Forwarding (Tunneling) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 367
SSH Confi guration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 368
Kerberos . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 368
Kerberos Servers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 369
Authentication Process . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 369
Kerberized Services . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 371
Confi guring Kerberos Servers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 371
20 Firewalls . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 373
Firewalls: IPtables, NAT, and ip6tables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 373
IPtables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 374
ip6tables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 374
Modules . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 375
Packet Filtering . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 375
Chains . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 375
Targets . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 376
Firewall and NAT Chains . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 376
Adding and Changing Rules . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 376
IPtables Options . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 379
Accepting and Denying Packets: DROP and ACCEPT . . . . . . . . . . . . 379
User-Defi ned Chains . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 380
ICMP Packets . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 381
Controlling Port Access . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 382
Packet States: Connection Tracking . . . . . . . . . . . . . . . . . . . . . . . . . . . . 383
Specialized Connection Tracking: ftp, irc, Amanda, tftp . . . . . . . . . . 384
Network Address Translation (NAT) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 384
Adding NAT Rules . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 384
NAT Targets and Chains . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 385
NAT Redirection: Transparent Proxies . . . . . . . . . . . . . . . . . . . . . . . . . 386
Packet Mangling: The Mangle Table . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 386
IPtables Scripts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 387
An IPtables Script Example: IPv4 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 387
IP Masquerading . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 395
Masquerading Local Networks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 395
Masquerading NAT Rules . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 396
IP Forwarding . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 396
Masquerading Selected Hosts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 396
Part VI Internet and Network Services
21 Managing Services . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 401
System Startup Files: /etc/rc.d . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 401
rc.sysinit and rc.local . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 401
/etc//init.d . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 402
SysV Init: init.d Scripts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 403
Starting Services: Standalone and xinetd . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 404
Starting Services Directly . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 405
Starting and Stopping Services with Service Scripts . . . . . . . . . . . . . . 406
Starting Services Automatically . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 406
Service Management: chkconfi g, services-admin, rrconf, sysv-rc-conf,
and update-rc.d . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 407
chkconfi g . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 407
rcconf, services-admin, sysv-rc-conf, and update-rc.d . . . . . . . . . . . . 410
Service Scripts: /etc/init.d . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 412
Service Script Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 412
Service Script Tags . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 413
Service Script Example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 414
Installing Service Scripts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 415
Extended Internet Services Daemon (xinetd) . . . . . . . . . . . . . . . . . . . . . . . . . . 415
Starting and Stopping xinetd Services . . . . . . . . . . . . . . . . . . . . . . . . . 416
xinetd Confi guration: xinetd.conf . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 416
xinetd Service Confi guration Files: /etc/xinetd.d Directory . . . . . . . 417
Confi guring Services: xinetd Attributes . . . . . . . . . . . . . . . . . . . . . . . . 418
Disabling and Enabling xinetd Services . . . . . . . . . . . . . . . . . . . . . . . . 418
TCP Wrappers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 421
22 FTP Servers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 423
FTP Servers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 423
Available Servers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 424
FTP Users . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 424
Anonymous FTP: vsftpd . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 425
The FTP User Account: anonymous . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 425
FTP Group . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 425
Creating New FTP Users . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 426
Anonymous FTP Server Directories . . . . . . . . . . . . . . . . . . . . . . . . . . . 426
Anonymous FTP Files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 427
Using FTP with rsync . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 427
Accessing FTP Sites with rsync . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 427
Confi guring an rsync Server . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 428
rsync Mirroring . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 429
The Very Secure FTP Server . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 429
Running vsftpd . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 429
Confi guring vsftpd . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 430
vsftpd Access Controls . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 433
vsftpd Virtual Hosts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 434
vsftpd Virtual Users . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 435
Professional FTP Daemon: ProFTPD . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 436
Install and Startup . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 436
Contents
xix
xx
Linux: The Complete Reference
Authentication . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 436
proftpd.confi g and .ftpaccess . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 436
Anonymous Access . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 438
Virtual FTP Servers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 440
23 Web Servers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 443
Tux . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 443
Alternate Web Servers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 444
Apache Web Server . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 444
Java: Apache Jakarta Project . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 445
Linux Apache Installations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 446
Apache Multiprocessing Modules: MPM . . . . . . . . . . . . . . . . . . . . . . . 447
Starting and Stopping the Web Server . . . . . . . . . . . . . . . . . . . . . . . . . 447
Apache Confi guration Files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 448
Apache Confi guration and Directives . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 448
Global Confi guration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 449
Server Confi guration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 451
Directory-Level Confi guration: .htaccess and <Directory> . . . . . . . . 452
Access Control . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 453
URL Pathnames . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 453
MIME Types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 454
CGI Files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 455
Automatic Directory Indexing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 455
Authentication . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 456
Log Files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 457
Virtual Hosting on Apache . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 458
IP-Based Virtual Hosting . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 459
Name-Based Virtual Hosting . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 459
Dynamic Virtual Hosting . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 459
Server-Side Includes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 462
PHP . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 463
Apache Confi guration Tool . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 463
Web Server Security: SSL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 464
24 Proxy Servers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 467
Confi guring Client Browsers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 468
The squid.conf File . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 469
Security . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 470
Caches . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 473
Connecting to Caches . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 473
Memory and Disk Confi guration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 474
Administrative Settings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 474
Logs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 474
Web Server Acceleration: Reverse Proxy Cache . . . . . . . . . . . . . . . . . . . . . . . . 474
25 Mail Servers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 477
Mail Transport Agents . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 477
Received Mail: MX Records . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 478
Postfi x . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 479
Postfi x Commands . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 479
Postfi x Confi guration: main.cf . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 480
Postfi x Greylisting Policy Server . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 482
Controlling User and Host Access . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 483
Sendmail . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 484
Aliases and LDAP . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 485
Sendmail Confi guration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 487
Sendmail Masquerading . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 491
Confi guring Mail Servers and Mail Clients . . . . . . . . . . . . . . . . . . . . . 493
Confi guring Sendmail for a Simple Network Confi guration . . . . . . 494
Confi guring Sendmail for a Centralized Mail Server . . . . . . . . . . . . . 494
Confi guring a Workstation with Direct ISP Connection . . . . . . . . . . . 495
The Mailer Table . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 495
Virtual Domains: virtusertable . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 496
Security . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 496
POP and IMAP Server: Dovecot . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 498
Dovecot . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 499
Other POP and IMAP Servers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 499
Spam: SpamAssassin . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 500
26 Print, News, Search, and Database Servers . . . . . . . . . . . . . . . . . . . . . . . . . . 503
Printer Servers: CUPS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 503
Printer Devices and Confi guration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 504
Printer Device Files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 504
Spool Directories . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 505
Installing Printers with CUPS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 505
Confi guring CUPS on GNOME . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 505
Confi guring CUPS on KDE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 505
CUPS Web Browser-Based Confi guration Tool . . . . . . . . . . . . . . . . . . 506
Confi guring Remote Printers on CUPS . . . . . . . . . . . . . . . . . . . . . . . . . 507
CUPS Printer Classes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 507
CUPS Confi guration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 508
cupsd.conf . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 508
CUPS Directives . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 508
CUPS Command Line Print Clients . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 509
lpr . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 509
lpc . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 510
lpq and lpstat . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 510
lprm . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 510
CUPS Command Line Administrative Tools . . . . . . . . . . . . . . . . . . . . . . . . . . 510
lpadmin . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 511
lpoptions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 511
enable and disable . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 512
accept and reject . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 512
lpinfo . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 512
News Servers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 512
News Servers: INN . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 513
Newsreader Access . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 514
Overviews . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 514
INN Implementation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 515
Database Servers: MySQL and PostgreSQL . . . . . . . . . . . . . . . . . . . . . . . . . . . 515
Relational Database Structure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 516
SQL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 516
Contents
xxi
xxii
Linux: The Complete Reference
MySQL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 517
PostgreSQL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 520
Part VII System Administration
27 Basic System Administration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 523
Superuser Control: The Root User . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 523
Root User Password . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 524
Root User Access: su . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 524
Controlled Administrative Access: sudo . . . . . . . . . . . . . . . . . . . . . . . . 525
System Time and Date . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 526
Scheduling Tasks: cron . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 527
crontab Entries . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 527
Environment Variables for cron . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 528
The cron.d Directory . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 528
The crontab Command . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 529
Editing in cron . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 529
Organizing Scheduled Tasks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 529
Running cron Directory Scripts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 530
cron Directory Names . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 531
Anacron . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 531
System Runlevels: telinit, initab, and shutdown . . . . . . . . . . . . . . . . . . . . . . . 531
Runlevels . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 531
Runlevels in initab . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 533
Changing Runlevels with telinit . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 533
The runlevel Command . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 534
Shutdown . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 534
System Directories . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 536
Program Directories . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 537
Confi guration Directories and Files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 537
Confi guration Files: /etc . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 537
System Logs: /var/log and syslogd . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 537
syslogd and syslog.conf . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 537
Entries in syslog.conf . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 539
Priorities . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 540
Actions and Users . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 540
An Example for /etc/syslog.conf . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 541
The Linux Auditing System: auditd . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 541
Performance Analysis Tools and Processes . . . . . . . . . . . . . . . . . . . . . . . . . . . 542
GNOME System Monitor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 543
The ps Command . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 543
vmstat, top, free, Xload, iostat, and sar . . . . . . . . . . . . . . . . . . . . . . . . . 544
System Tap . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 544
Frysk . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 544
GNOME Power Manager . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 545
GKrellM . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 545
KDE Task Manager and Performance Monitor (KSysguard) . . . . . . . 546
Grand Unifi ed Bootloader (GRUB) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 547
28 Managing Users . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 551
GUI User Managment Tools: users-admin and KUser . . . . . . . . . . . . . . . . . . 551
User Confi guration Files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 552
The Password Files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 553
/etc/passwd . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 553
/etc/shadow and /etc/gshadow . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 554
Password Tools . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 554
Managing User Environments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 554
Profi le Scripts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 554
/etc/skel . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 555
/etc/login.defs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 555
/etc/login.access . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 555
Controlling User Passwords . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 556
Adding and Removing Users with useradd, usermod, and userdel . . . . . . 557
useradd . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 558
usermod . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 559
userdel . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 559
Managing Groups . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 559
/etc/group and /etc/gshadow . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 559
User Private Groups . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 560
Group Directories . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 560
Managing Groups Using groupadd, groupmod, and groupdel . . . . 561
Controlling Access to Directories and Files: chmod . . . . . . . . . . . . . . . . . . . . 561
Permissions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 561
chmod . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 563
Ownership . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 563
Changing a File’s Owner or Group: chown and chgrp . . . . . . . . . . . . 565
Setting Permissions: Permission Symbols . . . . . . . . . . . . . . . . . . . . . . 566
Absolute Permissions: Binary Masks . . . . . . . . . . . . . . . . . . . . . . . . . . 566
Directory Permissions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 568
Ownership Permissions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 569
Sticky Bit Permissions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 569
Permission Defaults: umask . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 570
Disk Quotas . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 571
Quota Tools . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 571
edquota . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 571
quotacheck, quotaon, and quotaoff . . . . . . . . . . . . . . . . . . . . . . . . . . . . 572
repquota and quota . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 572
Lightweight Directory Access Protocol . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 573
LDAP Clients and Servers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 573
LDAP Confi guration Files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 574
Confi guring the LDAP server: /etc/slapd.conf . . . . . . . . . . . . . . . . . . 574
LDAP Directory Database: ldif . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 575
LDAP Tools . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 579
LDAP and PAM . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 580
LDAP and the Name Service Switch Service . . . . . . . . . . . . . . . . . . . . 580
Pluggable Authentication Modules . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 580
PAM Confi guration Files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 581
PAM Modules . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 581
Contents
xxiii