Contents xiiiGraphical Partitioners 53gparted: the GNOME Partition Editor 53 ubiquity: Setting Up Partitions 56 Upgrading to a New Release 59 Installing KDE 60 Setting Up a Dual-Boot Sys
Trang 2Praise for A Practical Guide to Ubuntu Linux
“I am so impressed by how Mark Sobell can approach a complex topic
in such an understandable manner His command examples are cially useful in providing a novice (or even advanced) administratorwith a cookbook on how to accomplish real-world tasks on Linux He
espe-is truly an inspired technical writer!”
—George Vish II Senior Education Consultant Hewlett-Packard Company
“Overall, I think it’s a great, comprehensive Ubuntu book that’ll be avaluable resource for people of all technical levels.”
—John Dong Ubuntu Forum Council Member Backports Team Leader
“The JumpStart sections really offer a quick way to get things up andrunning, allowing you to dig into the details of his books later.”
—Scott Mann Aztek Networks
“Ubuntu is gaining popularity at the rate alcohol did during prohibition,and it’s great to see a well-known author write a book on the latest andgreatest version Not only does it contain Ubuntu-specific information,but it also touches on general computer-related topics, which will helpthe average computer user to better understand what’s going on in thebackground Great work, Mark!”
—Daniel R Arfsten Pro/ENGINEER Drafter/Designer
“I read a lot of Linux technical information every day, but I’m rarelyimpressed by tech books I usually prefer online information sourcesinstead Mark Sobell’s books are a notable exception They’re clearlywritten, technically accurate, comprehensive-and actually enjoyable
to read.”
—Matthew Miller Senior Systems Analyst/Administrator
BU Linux Project Boston University Office
of Information Technology
Trang 3“I would so love to be able to use this book to teach a class about notjust Ubuntu or Linux but about computers in general It is thoroughand well written with good illustrations that explain important con-cepts for computer usage.”
—Nathan Eckenrode New York Local Community Team
Praise for Other Books by Mark Sobell
“I currently own one of your books, A Practical Guide to Linux ® Ibelieve this book is one of the most comprehensive and, as the titlesays, practical guides to Linux I have ever read I consider myself anovice and I come back to this book over and over again.”
—Albert J Nguyen
“Thank you for writing a book to help me get away from Windows XPand to never touch Windows Vista The book is great; I am learning alot of new concepts and commands Linux is definitely getting easier
to use.”
—James Moritz
“I have been wanting to make the jump to Linux but did not have the
guts to do so-until I saw your familiarly titled A Practical Guide to Red Hat ® Linux ® at the bookstore I picked up a copy and am eagerly look-ing forward to regaining my freedom.”
—Carmine Stoffo Machine and Process Designer
to pharmaceutical industry
“I am currently reading A Practical Guide to Red Hat ® Linux ® and amfinally understanding the true power of the command line I am new toLinux and your book is a treasure.”
—Juan Gonzalez
Trang 4A Practical Guide to Ubuntu Linux
Trang 5This page intentionally left blank
Trang 6A Practical Guide to Ubuntu Linux
Mark G Sobell
Upper Saddle River, NJ • Boston • Indianapolis • San Francisco
New York • Toronto • Montreal • London • Munich • Paris • Madrid
Capetown • Sydney • Tokyo • Singapore • Mexico City
Trang 7Many of the designations used by manufacturers and sellers to distinguish their products are claimed as trademarks Where those designations appear in this book, and the publisher was aware of a trademark claim, the designations have been printed with initial capital letters or in all capitals.
Ubuntu is a registered trademark of Canonical Ltd.
The author and publisher have taken care in the preparation of this book, but make no expressed or implied warranty of any kind and assume no responsibility for errors or omissions No liability is assumed for incidental or consequential damages in connection with or arising out of the use of the information or programs contained herein.
The publisher offers excellent discounts on this book when ordered in quantity for bulk purchases or special sales, which may include electronic versions and/or custom covers and content particular to your business, training goals, marketing focus, and branding interests For more information, please contact:
U.S Corporate and Government Sales
Visit us on the Web: www.prenhallprofessional.com
Library of Congress Cataloging-in-Publication Data
Sobell, Mark G.
A practical guide Ubuntu Linux / Mark G Sobell.
p cm.
Includes index.
ISBN-13: 978-0-13-236039-5 (pbk : alk paper)
1 Linux 2 Operating systems (Computers) I Title.
QA76.76.O63S59497 2008
005.4'32—dc22
2007043244
Copyright © 2008 Mark G Sobell
All rights reserved Printed in the United States of America This publication is protected by copyright, and permission must be obtained from the publisher prior to any prohibited reproduction, storage in a retrieval system, or transmission in any form or
by any means, electronic, mechanical, photocopying, recording, or likewise For information regarding permissions, write to: Pearson Education, Inc.
Rights and Permissions
501 Boylston Street, Suite 900
Boston, MA 02116
Fax (617) 671-3447
ISBN-13: 978-0-13-236039-5
ISBN-10: 0-13-236039-X
Text printed in the United States on recycled paper at Courier in Stoughton, Massachusetts.
First printing, December 2007
Trang 8For my dad,
Morton Sobell,
who taught me to examine the world very carefully.
Trang 9This page intentionally left blank
Trang 10PART II Getting Started with Ubuntu Linux 85
4 Introduction to Ubuntu Linux 87
5 The Linux Utilities 145
6 The Linux Filesystem 183
7 The Shell 219
PART III Digging into Ubuntu Linux 249
8 Linux GUIs: X and GNOME 251
9 The Bourne Again Shell 275
10 Networking and the Internet 353
11 Programming the Bourne Again Shell 395
Trang 11x Brief Contents
PART IV System Administration 483
12 System Administration: Core Concepts 485
13 Files, Directories, and Filesystems 553
14 Downloading and Installing Software 583
15 Printing with CUPS 611
16 Building a Linux Kernel 635
17 Administration Tasks 657
18 Configuring a LAN 693
PART V Using Clients and Setting Up Servers 705
19 OpenSSH: Secure Network Communication 707
20 F TP: Transferring Files Across a Network 729
21 exim4: Setting Up Mail Servers, Clients, and More 755
22 NIS: Network Information Service 781
23 NFS: Sharing Filesystems 799
24 Samba: Linux and Windows File and Printer Sharing 823
25 DNS/BIND: Tracking Domain Names and Addresses 845
26 firestarter and iptables: Setting Up a Firewall 885
27 Apache: Setting Up a Web Server 915
PART VI Appendixes 969
A Regular Expressions 971
B Help 981
C Security 991
D The Free Software Definition 1011
E The Linux 2.6 Kernel 1015
Glossary 1021Index 1071
Trang 12Contents
Preface xxxvi
Chapter 1: Welcome to Linux 1
The GNU–Linux Connection 2
The History of GNU–Linux 2
The Code Is Free 4
Have Fun! 5
The Linux 2.6 Kernel 5
The Heritage of Linux: UNIX 5
What Is So Good About Linux? 6
Why Linux Is Popular with Hardware Companies and Developers 7
Linux Has a Kernel Programming Interface 10
Linux Can Support Many Users 11
Linux Can Run Many Tasks 11
Linux Provides a Secure Hierarchical Filesystem 12
The Shell: Command Interpreter and Programming Language 12
A Large Collection of Useful Utilities 14
Interprocess Communication 14
System Administration 15
Trang 13xii Contents
Additional Features of Linux 15GUIs: Graphical User Interfaces 15(Inter)Networking Utilities 16Software Development 17Conventions Used in This Book 17Chapter Summary 20
Exercises 20
Chapter 2: Installation Overview 23
The Live/Install Desktop CD/DVD 24More Information 24
Planning the Installation 25Considerations 25Requirements 25Processor Architecture 26Interfaces: Installer and Installed System 27Ubuntu Releases 28
Ubuntu Editions 28Installing a Fresh Copy or Upgrading an Existing Ubuntu System? 29Setting Up the Hard Disk 30
Burning the CD/DVD 40Gathering Information About the System 41Chapter Summary 42
Exercises 43Advanced Exercises 43
Chapter 3: Step-by-Step Installation 45
Basic Installation from the Live/Install Desktop CD/DVD 46Booting the System 46
Checking the CD/DVD for Defects 47Live Session 47
Trang 14Contents xiiiGraphical Partitioners 53
gparted: the GNOME Partition Editor 53
ubiquity: Setting Up Partitions 56
Upgrading to a New Release 59
Installing KDE 60
Setting Up a Dual-Boot System 61
Creating Free Space on a Windows System 61
Installing Ubuntu Linux as the Second Operating System 61
Advanced Installation 62
The Live/Install Desktop CD: The Initial Install Screen 62
The Alternate CD Initial Install Screen Menu 65
The Server CD Initial Install Screen Menu 66
The DVD 67
The Ubuntu Textual Installer 67
The X Window System 74
displayconfig-gtk: Configures the Display 75
The xorg.conf File 77
gdm: Displays a Graphical Login 82
Chapter Summary 83
Exercises 83
Advanced Exercises 84
Chapter 4: Introduction to Ubuntu Linux 87
Curbing Your Power: root Privileges/sudo 88
A Tour of the Ubuntu Linux Desktop 89
Logging In on the System 89
Working with Windows 96
Using Nautilus to Work with Files 96
The Update Notifier 100
Changing Appearances (Themes) 102
Session Management 104
Getting Help 104
Feel Free to Experiment 105
Logging Out 105
Trang 15xiv Contents
Getting the Most out of the Desktop 105GNOME Desktop Terminology 105Opening Files 106
Panels 107The Main Menu 110Windows 111The Object Context Menu 115Updating, Installing, and Removing Software Packages 119Software Sources Window 119
Add/Remove Applications 120Synaptic: Finds, Installs, and Removes Software 121Where to Find Documentation 124
Ubuntu Help Center 124
man: Displays the System Manual 124
info: Displays Information About Utilities 126
The ––help Option 129
HOWTOs: Finding Out How Things Work 129Getting Help with the System 130
More About Logging In 132The Login Screen 132What to Do if You Cannot Log In 133Logging In Remotely: Terminal Emulators, ssh, and Dial-Up Connections 133Logging In from a Terminal (Emulator) 134
Changing Your Password 135Using Virtual Consoles 136Working from the Command Line 136Correcting Mistakes 137
Repeating/Editing Command Lines 139Controlling Windows: Advanced Operations 139Changing the Input Focus 139
Changing the Resolution of the Display 140The Window Manager 141
Chapter Summary 142Exercises 143
Advanced Exercises 144
Chapter 5: The Linux Utilities 145
Special Characters 146Basic Utilities 147
ls: Lists the Names of Files 147
cat: Displays a Text File 147
rm: Deletes a File 148
less Is more: Display a Text File One Screen at a Time 148
hostname: Displays the System Name 149
Trang 16Contents xvWorking with Files 149
cp: Copies a File 149
mv: Changes the Name of a File 150
lpr: Prints a File 151
grep: Searches for a String 151
head: Displays the Beginning of a File 152
tail: Displays the End of a File 152
sort: Displays a File in Order 153
uniq: Removes Duplicate Lines from a File 154
diff: Compares Two Files 154
file: Tests the Contents of a File 155
| (Pipe): Communicates Between Processes 156
Four More Utilities 157
echo: Displays Text 157
date: Displays the Time and Date 157
script: Records a Shell Session 158
unix2dos: Converts Linux and Macintosh Files to Windows Format 159Compressing and Archiving Files 159
bzip2: Compresses a File 160
bunzip2 and bzcat: Decompress a File 160
gzip: Compresses a File 161
tar: Packs and Unpacks Archives 161
Locating Commands 164
which and whereis: Locate a Utility 164
apropos: Searches for a Keyword 165
slocate: Searches for a File 166
Obtaining User and System Information 166
who: Lists Users on the System 167
finger: Lists Users on the System 167
w: Lists Users on the System 169
Communicating with Other Users 170
write: Sends a Message 170
mesg: Denies or Accepts Messages 171
Ending the Editing Session 178
The compatible Parameter 179
Chapter Summary 179
Exercises 181
Advanced Exercises 182
Trang 17xvi Contents
Chapter 6: The Linux Filesystem 183
The Hierarchical Filesystem 184Directory Files and Ordinary Files 184Filenames 185
The Working Directory 188Your Home Directory 188Pathnames 189
Absolute Pathnames 189Relative Pathnames 190Directory Commands 191
mkdir: Creates a Directory 191Important Standard Directories and Files 194Working with Directories 196
rmdir: Deletes a Directory 196Using Pathnames 197
mv,cp: Move or Copy Files 197
mv: Moves a Directory 198Access Permissions 199
ls –l: Displays Permissions 199
chmod: Changes Access Permissions 200Setuid and Setgid Permissions 201Directory Access Permissions 202ACLs: Access Control Lists 203Enabling ACLs 204
Working with Access Rules 204Setting Default Rules for a Directory 207Links 209
Hard Links 210Symbolic Links 212
rm: Removes a Link 214Chapter Summary 214Exercises 216
Advanced Exercises 218
Chapter 7: The Shell 219
The Command Line 220Syntax 220
Processing the Command Line 223Executing the Command Line 225Editing the Command Line 225Standard Input and Standard Output 226The Screen as a File 226
The Keyboard and Screen as Standard Input and Standard Output 227Redirection 228
Pipes 234
Trang 18Contents xviiRunning a Program in the Background 237
Filename Generation/Pathname Expansion 239
The ? Special Character 239
The * Special Character 240
The [ ] Special Characters 241
Chapter 8: Linux GUIs: X and GNOME 251
X Window System 252
Using X 254
Window Managers 259
The Nautilus File Browser Window 260
The View Pane 261
The Side Pane 261
Pick a Font Window 268
Pick a Color Window 268
Run Application Window 269
Searching for Files 269
GNOME Terminal Emulator/Shell 270
Commands That Are Symbols 280
Redirecting Standard Error 280
Writing a Simple Shell Script 282
Separating and Grouping Commands 286
Job Control 290
Manipulating the Directory Stack 292
Trang 19xviii Contents
Parameters and Variables 295User-Created Variables 296Variable Attributes 299Keyword Variables 301Special Characters 309Processes 310
Process Structure 310Process Identification 310Executing a Command 312History 312
Variables That Control History 312Reexecuting and Editing Commands 314The Readline Library 322
Aliases 328Single Versus Double Quotation Marks in Aliases 329Examples of Aliases 330
Functions 331Controlling bash Features and Options 334Command Line Options 334
Shell Features 334Processing the Command Line 338History Expansion 338Alias Substitution 338Parsing and Scanning the Command Line 338Command Line Expansion 339
Chapter Summary 347Exercises 349
Advanced Exercises 351
Chapter 10: Networking and the Internet 353
Types of Networks and How They Work 355Broadcast Networks 356
Point-to-Point Networks 356Switched Networks 356LAN: Local Area Network 357WAN: Wide Area Network 358Internetworking Through Gateways and Routers 358Network Protocols 361
Host Address 363CIDR: Classless Inter-Domain Routing 367Hostnames 368
Communicate Over a Network 370
finger: Displays Information About Remote Users 370Sending Mail to a Remote User 371
Mailing List Servers 372
Trang 20Contents xix
Network Utilities 372
Trusted Hosts 372
OpenSSH Tools 373
telnet: Logs In on a Remote System 373
ftp: Transfers Files Over a Network 375
ping: Tests a Network Connection 375
traceroute: Traces a Route Over the Internet 376
host and dig: Query Internet Nameservers 378
jwhois: Looks Up Information About an Internet Site 378
Distributed Computing 379
The Client/Server Model 380
DNS: Domain Name Service 381
WWW: World Wide Web 390
URL: Uniform Resource Locator 391
Trang 21xx Contents
Builtin Commands 444
type: Displays Information About a Command 445
read: Accepts User Input 445
exec: Executes a Command 448
trap: Catches a Signal 451
kill: Aborts a Process 454
getopts: Parses Options 454
A Partial List of Builtins 457Expressions 458
Arithmetic Evaluation 458Logical Evaluation (Conditional Expressions) 459String Pattern Matching 460
Operators 461Shell Programs 466
A Recursive Shell Script 467
The quiz Shell Script 470Chapter Summary 476Exercises 478
Advanced Exercises 480
Chapter 12: System Administration:
Core Concepts 485
Running Commands with root Privileges 487
sudo: Running a Command with root Privileges 490
sudoers: Configuring sudo 494
Unlocking the root Account (Assigning a Password to root) 499
su: Gives You Another User’s Privileges 499
The Upstart Event-Based init Daemon 500Software Packages 501
Definitions 501Jobs 503
SysVinit (rc) Scripts: Start and Stop System Services 507
System Operation 510Runlevels 510Booting the System 511Recovery (Single-User) Mode 512Going to Multiuser Mode 515Logging In 516
Trang 22Contents xxiLogging Out 517
Bringing the System Down 518
Crash 519
Avoiding a Trojan Horse 520
Getting Help 522
Textual System Administration Utilities 522
kill: Sends a Signal to a Process 522
Other Textual Utilities 525
Setting Up a Server 527
Standard Rules in Configuration Files 528
rpcinfo: Displays Information About portmap 530
The inetd and xinetd Superservers 531
Securing a Server 532
DHCP: Configures Network Interfaces 538
nsswitch.conf: Which Service to Look at First 542
How nsswitch.conf Works 542
Chapter 13: Files, Directories, and Filesystems 553
Important Files and Directories 554
File Types 566
Ordinary Files, Directories, Links, and Inodes 566
Special Files 567
Filesystems 570
mount: Mounts a Filesystem 572
umount: Unmounts a Filesystem 575
fstab: Keeps Track of Filesystems 576
fsck: Checks Filesystem Integrity 577
tune2fs: Changes Filesystem Parameters 578
RAID Filesystem 580
Chapter Summary 580
Exercises 580
Advanced Exercises 581
Trang 23xxii Contents
Chapter 14: Downloading and Installing Software 583
JumpStart: Installing and Removing Packages Using aptitude 585
Finding the Package That Holds a File You Need 587APT: Keeps the System Up-to-Date 588
Repositories 588
sources.list: Specifies Repositories for APT to Search 589The APT Local Package Indexes and the APT Cache 590
The apt cron Script and APT Configuration Files 590
aptitude: Works with Packages and the Local Package Index 592
apt-cache: Displays Package Information 596
apt-get source: Downloads Source Files 598
dpkg: The Debian Package Management System 598
wget: Downloads Files Noninteractively 609Chapter Summary 610
Exercises 610Advanced Exercises 610
Chapter 15: Printing with CUPS 611
Introduction 612Prerequisites 612More Information 613Notes 613
JumpStart I: Configuring a Local Printer 614
system-config-printer: Configuring a Printer 614
Configuration Tabs 614Setting Up a Remote Printer 616JumpStart II: Configuring a Remote Printer Using the CUPS Web Interface 618Traditional UNIX Printing 622
Configuring Printers 624The CUPS Web Interface 624CUPS on the Command Line 626Sharing CUPS Printers 629Printing from Windows 630Printing Using CUPS 631Printing Using Samba 631
Trang 24Contents xxiiiPrinting to Windows 632
Downloading the Kernel Source Code 637
aptitude: Downloading and Installing the Kernel Source Code 637
git: Obtaining the Latest Kernel Source Code 637
Read the Documentation 638
Configuring and Compiling the Linux Kernel 639
.config: Configures the Kernel 639
Customizing a Kernel 640
Cleaning the Source Tree 642
Compiling a Kernel Image File and Loadable Modules 643
Using Loadable Kernel Modules 643
Installing the Kernel, Modules, and Associated Files 646
Rebooting 647
grub: The Linux Boot Loader 647
menu.lst: Configures grub 648
update-grub: Updates the menu.lst file 651
grub-install: Installs the MBR and grub Files 653
dmesg: Displays Kernel Messages 654
Chapter Summary 655
Exercises 656
Advanced Exercises 656
Chapter 17: Administration Tasks 657
Configuring User and Group Accounts 658
users-admin: Manages User Accounts 658
useradd: Adds a User Account 660
userdel: Removes a User Account 661
usermod: Modifies a User Account 661
groupadd: Adds a Group 661
groupdel: Removes a Group 661
Backing Up Files 662
Choosing a Backup Medium 663
Backup Utilities 663
Performing a Simple Backup 665
dump,restore: Back Up and Restore Filesystems 666
Trang 25xxiv Contents
Scheduling Tasks 668
cron and anacron: Schedule Routine Tasks 668
at: Runs Occasional Tasks 671System Reports 671
vmstat: Reports Virtual Memory Statistics 671
top: Lists Processes Using the Most Resources 672
parted: Reports on and Partitions a Hard Disk 673Keeping Users Informed 677
Creating Problems 678Solving Problems 679Helping When a User Cannot Log In 679Speeding Up the System 680
lsof: Finds Open Files 681Keeping a Machine Log 681Keeping the System Secure 682
Log Files and Mail for root 683Monitoring Disk Usage 683
logrotate: Manages Log Files 684Removing Unused Space from Directories 686Disk Quota System 687
syslogd: Logs System Messages 688
Chapter Summary 690Exercises 690
Advanced Exercises 691
Chapter 18: Configuring a LAN 693
Setting Up the Hardware 694Connecting the Computers 694Routers 695
NIC: Network Interface Card 695Tools 695
Configuring the Systems 697
network-admin: Configures Network Connections 698 nm-applet: Configures Network Connections Automatically 700
iwconfig: Configures a Wireless NIC 700Setting Up Servers 702
More Information 703Chapter Summary 703Exercises 704
Advanced Exercises 704
Trang 26Contents xxv
Chapter 19: OpenSSH: Secure Network
ssh: Connects to or Executes Commands on a Remote System 714
scp: Copies Files to and from a Remote System 716
JumpStart: Starting the sshd Daemon 720
Authorized Keys: Automatic Login 721
Command Line Options 722
/etc/ssh/sshd_config Configuration File 722
Trang 27xxvi Contents
FTP Server (vsftpd) 740Prerequisites 740Notes 740
JumpStart II: Starting a vsftpd Server 741Testing the Setup 741
vsftpd.conf: The vsftpd Configuration File 742
Chapter Summary 753Exercises 753
Advanced Exercises 754
Chapter 21: exim4: Setting Up Mail Servers, Clients, and More 755
Introduction to exim4 756Prerequisites 757Notes 757More Information 758
JumpStart I: Configuring exim4 to Use a Smarthost 758
JumpStart II: Configuring exim4 to Send and Receive Email 760 How exim4 Works 761
Mail Logs 762Working with Messages 763Aliases and Forwarding 763Related Programs 765
Configuring exim4 765 Using a Text Editor to Configure exim4 766 The update-exim4.conf.conf Configuration File 766
dpkg-reconfigure: Configures exim4 768SpamAssassin 768
Prerequisites 769How SpamAssassin Works 769Testing SpamAssassin 770Configuring SpamAssassin 771Additional Email Tools 772Webmail 772
Mailing Lists 774Setting Up an IMAP or POP3 Server 776Authenticated Relaying 777
Alternatives to exim4 779
Chapter Summary 779Exercises 780
Advanced Exercises 780
Trang 28Testing the Setup 787
yppasswd: Changes NIS Passwords 788
Setting Up an NIS Server 790
JumpStart I: Mounting a Remote Directory Hierarchy 803
mount: Mounts a Directory Hierarchy 804
JumpStart II: Configuring an NFS Server Using shares-admin 809
Manually Exporting a Directory Hierarchy 811
Where the System Keeps NFS Mount Information 815
exportfs: Maintains the List of Exported Directory Hierarchies 817
Testing the Server Setup 818
automount: Mounts Directory Hierarchies on Demand 818
Chapter Summary 821
Exercises 822
Advanced Exercises 822
Trang 29xxviii Contents
Chapter 24: Samba: Linux and Windows File and Printer Sharing 823
Introduction 824About Samba 825Prerequisites 825More Information 825Notes 825
Samba Users, User Maps, and Passwords 826JumpStart: Configuring a Samba Server Using shares-admin 826
swat: Configures a Samba Server 828
smb.conf: Manually Configuring a Samba Server 832
Parameters in the smbd.conf File 832The [homes] Share: Sharing Users’ Home Directories 838Accessing Linux Shares from Windows 838
Browsing Shares 838Mapping a Share 839Accessing Windows Shares from Linux 839
smbtree: Displays Windows Shares 839
smbclient: Connects to Windows Shares 840Browsing Windows Networks 840
Mounting Windows Shares 841Troubleshooting 841
Chapter Summary 844Exercises 844
Advanced Exercises 844
Chapter 25: DNS/BIND: Tracking Domain Names and Addresses 845
Introduction to DNS 846Nodes, Domains, and Subdomains 846Zones 848
Queries 849Servers 850Resource Records 851DNS Query and Response 854Reverse Name Resolution 855About DNS 857
How DNS Works 857Prerequisites 857More Information 858Notes 858
Trang 30Contents xxixJumpStart I: Setting Up a DNS Cache 858
TSIGs: Transaction Signatures 868
Running BIND in a chroot Jail 870
JumpStart: Building a Firewall Using the firestarter Firewall Wizard 888
firestarter: Maintains a Firewall 890
The Status Tab 890
The Events Tab 892
The Policy Tab 894
How iptables Works 896
About iptables 899
More Information 899
Prerequisites 899
Notes 899
Anatomy of an iptables Command 900
Building a Set of Rules 901
Trang 31xxx Contents
Sharing an Internet Connection Using NAT 908Connecting Several Clients to a Single Internet Connection 910Connecting Several Servers to a Single Internet Connection 912Chapter Summary 912
Exercises 913Advanced Exercises 913
Chapter 27: Apache: Setting Up a Web Server 915
Introduction 916About Apache 917Prerequisites 917More Information 918Notes 918
JumpStart: Getting Apache Up and Running 919Modifying the Configuration Files 919Testing Apache 920
Putting Your Content in Place 920Configuring Apache 921
Configuration Tools 921Include Directives 922Filesystem Layout 923Configuration Directives 925Directives I: Directives You May Want to Modify as You Get Started 926Contexts and Containers 931
Directives II: Advanced Directives 935
The Ubuntu apache2.conf File 948
The Ubuntu default Configuration File 950
Redirects 951Content Negotiation 951Type Maps 951MultiViews 952Server-Generated Directory Listings (Indexing) 953Virtual Hosts 953
Setting Up a Virtual Host 954Types of Virtual Hosts 954
The default Virtual Host 954Examples 954
Troubleshooting 956Modules 957
mod_cgi and CGI Scripts 958 mod_ssl 959
Authentication Modules and htaccess 961Scripting Modules 962
Multiprocessing Modules (MPMs) 963
Trang 32Contents xxxi
webalizer: Analyzes Web Traffic 964
MRTG: Monitors Traffic Loads 964
Carets and Dollar Signs 974
Quoting Special Characters 975
Rules 975
Longest Match Possible 975
Empty Regular Expressions 976
Trang 33xxxii Contents
Appendix C: Security 991
Encryption 992Public Key Encryption 993Symmetric Key Encryption 994Encryption Implementation 995GnuPG/PGP 995
File Security 997Email Security 997MTAs (Mail Transfer Agents) 997MUAs (Mail User Agents) 998Network Security 998
Network Security Solutions 999Network Security Guidelines 999Host Security 1001
Login Security 1002Remote Access Security 1003Viruses and Worms 1004Physical Security 1004Security Resources 1006Appendix Summary 1009
Appendix D: The Free Software Definition 1011
Appendix E: The Linux 2.6 Kernel 1015
Native Posix Thread Library (NPTL) 1016IPSecurity (IPSec) 1016
Asynchronous I/O (AIO) 1016O(1) Scheduler 1017
OProfile 1017
kksymoops 1017Reverse Map Virtual Memory (rmap VM) 1017HugeTLBFS: Translation Look-Aside Buffer Filesystem 1018
remap_file_pages 10182.6 Network Stack Features (IGMPv3, IPv6, and Others) 1018Internet Protocol Virtual Server (IPVS) 1019
Access Control Lists (ACLs) 10194GB-4GB Memory Split: Physical Address Extension (PAE) 1019Scheduler Support for HyperThreaded CPUs 1019
Trang 34Contents xxxiiiBlock I/O (BIO) Block Layer 1019
Support for Filesystems Larger Than 2 Terabytes 1020
New I/O Elevators 1020
Interactive Scheduler Response Tuning 1020
Glossary 1021
Index 1071
Trang 35This page intentionally left blank
Trang 36Preface
The book Whether you are an end user, a system administrator, or a little of both, this book
explains with step-by-step examples how to get the most out of an Ubuntu Linuxsystem In 27 chapters, this book takes you from installing an Ubuntu systemthrough understanding its inner workings to setting up secure servers that run onthe system
The audience This book is designed for a wide range of readers It does not require you to have
programming experience, although having some experience using a general-purposecomputer, such as a Windows, Macintosh, UNIX, or another Linux system is cer-tainly helpful This book is appropriate for
• Students who are taking a class in which they use Linux
• Home users who want to set up and/or run Linux
• Professionals who use Linux at work
• System administrators who need an understanding of Linux and the tools
that are available to them
• Computer science students who are studying the Linux operating system
• Technical executives who want to get a grounding in Linux
Benefits A Practical Guide to Ubuntu Linux®gives you a broad understanding of many ets of Linux, from installing Ubuntu Linux through using and customizing it Nomatter what your background, this book provides the knowledge you need to get
fac-on with your work You will come away from this book understanding how to useLinux, and this book will remain a valuable reference for years to come
Trang 37not appear in A Practical Guide to Linux® Commands, Editors, and Shell ming include Chapters 2 and 3 (installation), Chapters 4 and 8 (Ubuntu Linux and
Program-the GUI), Chapter 10 (networking), all of Program-the chapters in Part IV (system tration) and Part V (servers), and Appendix C (security)
adminis-Differences While this book explains how to use Linux from a graphical interface and from the
command line (a textual interface), A Practical Guide to Linux® Commands, tors, and Shell Programming works exclusively with the command line It includes
Edi-full chapters on the vi and emacs editors, as well as chapters on the gawk patternprocessing language and the sed stream editor In addition, it has a command refer-ence section that provides extensive examples of the use of more than 80 of themost important Linux utilities You can use these utilities to solve problems withoutresorting to programming in C
This Book Includes Ubuntu Gutsy Gibbon (7.10)
on a Live/Install DVD
This book includes a live/install DVD that holds the Gutsy Gibbon (7.10) release ofUbuntu Linux You can use this DVD to run a live Ubuntu session that displays theGNOME desktop without making any changes to your computer: Boot from theDVD, run an Ubuntu live session, and log off Your system remains untouched:When you reboot, it is exactly as it was before you ran the Ubuntu live session.Alternatively, you can install Ubuntu from the live session Chapter 2 helps you getready to install Ubuntu Chapter 3 provides step-by-step instructions for installingUbuntu from this DVD This book guides you through learning about, using, andadministrating an Ubuntu Linux session
DVD features The included DVD incorporates all the features of the live/install Desktop CD as
well as the Alternate and Server CDs It also includes all software packages ported by Ubuntu You can use it to perform a graphical or textual (command line)installation of either a graphical or a textual Ubuntu system If you do not have anInternet connection, you can use the DVD as a software repository and install anysupported software packages from it
sup-Features of This Book
This book is designed and organized so you can get the most out of it in the shortestamount of time You do not have to read this book straight through in page order.Instead, once you are comfortable using Linux, you can use this book as a reference:
Trang 38Features of This Book xxxviiLook up a topic of interest in the table of contents or index and read about it Orthink of the book as a catalog of Linux topics: Flip through the pages until a topiccatches your eye The book includes many pointers to Web sites where you can getadditional information: Consider the Internet an extension of this book.
A Practical Guide to Ubuntu Linux®is structured with the following features:
• Optional sections enable you to read the book at different levels, returning
to more difficult material when you are ready to delve into it
• Caution boxes highlight procedures that can easily go wrong, giving you
guidance before you run into trouble.
• Tip boxes highlight ways you can save time by doing something differently
or situations when it may be useful or just interesting to have additional information
• Security boxes point out places where you can make a system more secure The security appendix presents a quick background in system security
issues
• Concepts are illustrated by practical examples throughout the book.
• Chapter summaries review the important points covered in each chapter.
• Review exercises are included at the end of each chapter for readers who
want to further hone their skills Answers to even-numbered exercises are available at www.sobell.com
• The glossary defines more than 500 common terms.
• The chapters that cover servers include JumpStart sections that get you off
to a quick start using clients and setting up servers Once a server is up and running, you can test and modify its configuration as explained in the rest
• This book describes in detail many important GNU tools, including the
GNOME desktop, the Nautilus File Browser, the parted and gparted tion editors, the gzip compression utility, and many command line utilities that come from the GNU project
parti-• Pointers throughout the text provide help in obtaining online
documenta-tion from many sources, including the local system, the Ubuntu Web site,
and other locations on the Internet
• Many useful URLs point to Web sites where you can obtain software,
security programs and information, and more
• The comprehensive index helps you locate topics quickly and easily.
Trang 39xxxviii Preface
Key Topics Covered in This Book
This book contains a lot of information This section distills and summarizes itscontents In addition, “Details” (starting on page xli) describes what each chaptercovers Finally, the table of contents provides more detail This book:
Installation • Describes how to download Ubuntu Linux ISO images from the Internet
and burn the Ubuntu live/install Desktop CD, the DVD, or the Ubuntu Alternate or Server installation CD
• Helps you plan the layout of the system’s hard disk It includes a sion of partitions, partition tables, and mount points, and assists you in using the ubiquity or gparted graphical partitioner or the Ubuntu textual partitioner to partition the hard disk
discus-• Explains how to set up a dual-boot system so you can install Ubuntu Linux on a Windows system and boot either operating system
• Describes in detail how to install Ubuntu Linux from a live/install Desktop
CD or the live/install DVD using the ubiquity graphical installer It also explains how to use the textual installer found on the Alternate CD, the Server CD, and the DVD The graphical installer is fast and easy to use The textual installer gives you more options and works on systems with less RAM (system memory)
• Covers testing an Ubuntu CD/DVD for defects, setting boot command line parameters (boot options), and creating a RAID array
• Covers the details of installing and customizing the X.org version of the
X Window System either graphically using the Screen and Graphics Preferences window or manually with a text editor
Working with
Ubuntu Linux
• Introduces the GNOME desktop (GUI) and explains how to use desktop tools, including the Top and Bottom panels, panel objects, the Main menu, object context menus, the Workspace Switcher, the Nautilus File Browser, and the GNOME Terminal emulator
• Explains how to use the Appearance Preferences window to add and ify themes to customize your desktop to please your senses and help you work more efficiently
mod-• Details how to set up 3D desktop visual effects that take advantage of Compiz Fusion
• Covers the Bourne Again Shell (bash) in three chapters, including an entire chapter on shell programming that includes many sample shell scripts
These chapters provide clear explanations and extensive examples of how
bash works both from the command line in day-to-day work and as a gramming language to write shell scripts
Trang 40pro-Key Topics Covered in This Book xxxix
• Explains the textual (command line) interface and introduces more than
30 command line utilities
• Presents a tutorial on the vim textual editor
• Covers types of networks, network protocols, and network utilities
• Explains hostnames, IP addresses, and subnets, and explores how to use
host and dig to look up domain names and IP addresses on the Internet
• Covers distributed computing and the client/server model
• Explains how to use ACLs (Access Control Lists) to fine-tune user access permissions
System
administration
• Explains how to use the Ubuntu graphical and textual (command line)
tools to configure the display, DNS, NFS, Samba, Apache, a firewall, a network interface, and more You can also use these tools to add users and manage local and remote printers
• Goes into detail about using sudo to allow specific users to work with root
privileges (become Superuser) and customizing the way sudo works by
editing the sudoers configuration file It also explains how you can unlock the root account if necessary.
• Describes how to use the following tools to download and install software
to keep a system up-to-date and to install new software:
◆The Software Sources window controls which Ubuntu and third-party
software repositories Ubuntu downloads software packages from and whether Ubuntu downloads updates automatically You can also use this window to cause Ubuntu to download and install security updates automatically
◆If you do not have an Internet connection, you can use the Software
Sources window to set up the DVD included with this book as a
soft-ware repository You can then install any softsoft-ware packages that Ubuntu supports from this repository
◆Based on how you set up updates in the Software Sources window, the
Update Notifier pops up on the desktop to let you know when
soft-ware updates are available Click the Update Notifier to open the Update Manager window, from which you can download and install updates
◆The Add/Remove Applications window provides an easy way to
select, download, and install a wide range of software packages
◆Synaptic allows you to search for, install, and remove software
pack-ages It gives you more ways to search for packages than does the Add/Remove Applications window