CONTENTS AT A GLANCEPart I: Welcome to Linux Part II: Installing Linux Part III: Using Desktop Environments in Linux Chapter 7: Installing and Configuring X Windows 109 Chapter 9: Using
Trang 1Arman Danesh
Michael Jang
SYBEX®
Trang 2mdeltree msdosdirectory [msdosdirectory ]
The mdeltree command deletes one or more MS-DOS
directo-ries It is similar to the DOS DELTREE command.
mkdir
mkdir [-p] [-m mode] [ parents] [ mode=mode]
➥ [ help] [ version] directory
The mkdir command creates one or more directories.
more
more [-dlfs] [ number] [+number] [file ]
The more command displays one or more files,
screen-by-screen, and allows for searching and jumping to an arbitrary
location in the file.
mount
mount -a [-rvw] [-t vfstype]
mount [-rvw] [-o options [, ]] device | dir
mount [-rvw] [-t vfstype] [-o options] device dir
The mount command mounts a file system to a specified directory.
nslookup
nslookup [host | - [server]]
The nslookup command queries a DNS name server It can be
run in interactive mode If no host name is provided, then the
program enters interactive mode By default, the DNS server, as
specified in /etc/resolv.conf, is used unless otherwise
speci-fied If you want to specify a server but not look up a specified
host, you must provide a - in place of the host.
passwd
passwd [-S] [-d delim-list] [file ]
The passwd command changes a user’s password When run by
the root user, it can be used to change a specific user’s password
by providing the username as an argument.
ping
ping [-fR] [-c number] [-i seconds]
➥ [-s packetsize] host
The ping command sends echo request packets to a network
host to see if it is accessible on the network.
ps
ps [lumaxwr] [txx] [pid ]
The ps command displays status reports for currently running
processes Given a specific process ID as an argument, ps
dis-plays information about that particular process Without
options or arguments, ps displays the current user’s processes.
rmdir [-p] [ parents] directory
The rmdir command deletes empty directories.
rsh
rsh [-Knx] [-l username] host [command]
The rsh command opens a shell on a remote system If a mand is provided, the command is executed on the remote host, the results are returned, and the connection is terminated.
tar
tar [-crtuxz] [-f file] [ file file] [ create]
➥ [ delete] [ preserve] [ append] [ same-owner]
➥ [ list] [ update] [ extract] [ get] [ gzip]
➥ [ ungzip] [file | directory ]
The tar command creates an archive file of one or more files or directories.
unzip [-cflptuz] file[.zip]
The unzip command manipulates and extracts ZIP archives.
zcat
zcat [-f] [file ]
The zcat command uncompresses one or more compressed files and displays the results to the standard output If no files are specified, then the standard input is uncompressed and displayed.
zip
zip [-efFgmrSu@] [ zipfile [ file1 file2 ]]
The zip command creates a ZIP archive from one or more files and directories.
zmore
zmore [file ]
The zmore command displays the contents of compressed text files, one screen at a time, allowing searching in much the same way as the more command If no files are specified, the standard input will be used.
Trang 3This page intentionally left blank
Trang 4Mastering Linux
Second Edition
Trang 5This page intentionally left blank
Trang 6Mastering™ Linux
Second Edition
Arman Danesh
and Michael Jang
San Francisco • Paris • Düsseldorf • Soest • London
Trang 7Associate Publisher: Dick Staron
Contracts and Licensing Manager: Kristine O’Callaghan
Acquisitions and Developmental Editor: Ellen L Dendy
Editor: Linda Recktenwald
Production Editor: Leslie E.H Light
Technical Editor: Baruch A Mettler
Book Designer: Kris Warrenburg
Graphic Illustrator: Tony Jonick
Electronic Publishing Specialist: Judy Fung
Proofreaders: Nanette Duffy, Emily Hsuan, Laurie O’Connell, Yariv Rabinovich, Nancy Riddiough
Indexer: Ted Laux
Cover Designer: Design Site
Cover Photographer: Jack D Myers, Design Site
Copyright ©2001 SYBEX Inc., 1151 Marina Village Parkway, Alameda, CA 94501 World rights reserved No part of this publication may be stored in a retrieval system, transmitted, or reproduced in any way, including but not limited to photocopy, photograph, magnetic or other record, without the prior agreement and written permission of the publisher.
Library of Congress Card Number: 2001088247
ISBN: 0-7821-2915-3
Screen reproductions produced with either The GIMP (a graphics package included with Red Hat Linux 7) or Capture Express 2000 Capture Express 2000 is a trademark of Insight Software Solutions Inc.
SYBEX is a registered trademark of SYBEX Inc.
Mastering is a trademark of SYBEX Inc.
Netscape Communications, the Netscape Communications logo, Netscape, and Netscape Navigator are trademarks of Netscape cations Corporation.
Communi-Netscape Communications Corporation has not authorized, sponsored, endorsed, or approved this publication and is not responsible for its content Netscape and the Netscape Communications Corporate Logos are trademarks and trade names of Netscape Communications Cor- poration All other product names and/or logos are trademarks of their respective owners.
TRADEMARKS: SYBEX has attempted throughout this book to distinguish proprietary trademarks from descriptive terms by following the capitalization style used by the manufacturer.
The author and publisher have made their best efforts to prepare this book, and the content is based upon final-release software whenever possible Portions of the manuscript may be based upon pre-release versions supplied by software manufacturer(s) The author and the publisher make no representation or warranties of any kind with regard to the completeness or accuracy of the contents herein and accept
no liability of any kind including but not limited to performance, merchantability, fitness for any particular purpose, or any losses or ages of any kind caused or alleged to be caused directly or indirectly from this book.
dam-Photographs and illustrations used in this book have been downloaded from publicly accessible file archives and are used in this book for news reportage purposes only to demonstrate the variety of graphics resources available via electronic access Text and images available over the Internet may be subject to copyright and other rights owned by third parties Online availability of text and images does not imply that they may be reused without the permission of rights holders, although the Copyright Act does permit certain unauthorized reuse as fair use under 17 U.S.C Section 107.
Manufactured in the United States of America
10 9 8 7 6 5 4 3 2 1
Trang 8Software License Agreement: Terms and Conditions
The media and/or any online materials accompanying this book
that are available now or in the future contain programs and/or
text files (the “Software”) to be used in connection with the book.
SYBEX hereby grants to you a license to use the Software, subject
to the terms that follow Your purchase, acceptance, or use of the
Software will constitute your acceptance of such terms.
The Software compilation is the property of SYBEX unless
other-wise indicated and is protected by copyright to SYBEX or other
copyright owner(s) as indicated in the media files (the “Owner(s)”).
You are hereby granted a single-user license to use the Software for
your personal, noncommercial use only You may not reproduce,
sell, distribute, publish, circulate, or commercially exploit the
Soft-ware, or any portion thereof, without the written consent of SYBEX
and the specific copyright owner(s) of any component software
included on this media.
In the event that the Software or components include specific
license requirements or end-user agreements, statements of
condi-tion, disclaimers, limitations, or warranties (“End-User License”),
those End-User Licenses supersede the terms and conditions
herein as to that particular Software component Your purchase,
acceptance, or use of the Software will constitute your acceptance
of such End-User Licenses
By purchase, use, or acceptance of the Software you further agree
to comply with all export laws and regulations of the United
States as such laws and regulations may exist from time to time.
Software Support
Components of the supplemental Software and any offers
associ-ated with them may be supported by the specific Owner(s) of that
material but they are not supported by SYBEX Information
regard-ing any available support may be obtained from the Owner(s)
using the information provided in the appropriate read.me files or
listed elsewhere on the media.
Should the manufacturer(s) or other Owner(s) cease to offer
sup-port or decline to honor any offer, SYBEX bears no responsibility.
This notice concerning support for the Software is provided for
your information only SYBEX is not the agent or principal of the
Owner(s), and SYBEX is in no way responsible for providing any
support for the Software, nor is it liable or responsible for any
sup-port provided, or not provided, by the Owner(s).
Warranty
SYBEX warrants the enclosed media to be free of physical defects
for a period of ninety (90) days after purchase The Software is
not available from SYBEX in any other form or media than that
enclosed herein or posted to www.sybex.com If you discover a
defect in the media during this warranty period, you may obtain
a replacement of identical format at no charge by sending the defective media, postage prepaid, with proof of purchase to: SYBEX Inc.
Customer Service Department
1151 Marina Village Parkway Alameda, CA 94501 (510) 523-8233 Fax: (510) 523-2373 E-mail: info@sybex.com Web: HTTP://WWW.SYBEX.COM After the 90-day period, you can obtain replacement media of identical format by sending us the defective disk, proof of pur- chase, and a check or money order for $10, payable to SYBEX.
Disclaimer
SYBEX makes no warranty or representation, either expressed or implied, with respect to the Software or its contents, quality, per- formance, merchantability, or fitness for a particular purpose In
no event will SYBEX, its distributors, or dealers be liable to you or any other party for direct, indirect, special, incidental, consequen- tial, or other damages arising out of the use of or inability to use the Software or its contents even if advised of the possibility of such damage In the event that the Software includes an online update feature, SYBEX further disclaims any obligation to pro- vide this feature for any specific duration other than the initial posting.
The exclusion of implied warranties is not permitted by some states Therefore, the above exclusion may not apply to you This warranty provides you with specific legal rights; there may be other rights that you may have that vary from state to state The pricing of the book with the Software by SYBEX reflects the allo- cation of risk and limitations on liability contained in this agree- ment of Terms and Conditions.
Shareware Distribution
This Software may contain various programs that are distributed
as shareware Copyright laws apply to both shareware and nary commercial software, and the copyright Owner(s) retains all rights If you try a shareware program and continue using it, you are expected to register it Individual programs differ on details of trial periods, registration, and payment Please observe the requirements stated in appropriate files.
ordi-Copy Protection
The Software in whole or in part may or may not be copy-protected
or encrypted However, in all cases, reselling or redistributing these files without authorization is expressly forbidden except as specifi- cally provided for by the Owner(s) therein
Trang 9This page intentionally left blank
Trang 10Many thanks to the GNU and Linux community
of developers, who are constantly proving that a group of volunteers can compete with
the biggest software companies.
Trang 11Computer books, even revisions, are a group effort As an author, I am only asmall part of this First, let me thank the original author, Arman Danesh, for listen-ing to my input during the development of this revision The people whom Sybexbrought together on this book are a well-oiled team Leslie Light made sure that theproject stayed on track in every detail Linda Recktenwald brought diverse inputstogether and added her own common sense to the final product Baruch Mettlerthoroughly tested everything in the book, helping to make sure that everything will work for you The book could not go to press without the gracious efforts ofthe other members of the team, including Dick Staron, Kristine O’Callaghan, JudyFung, Nanette Duffy, Emily Hsuan, Laurie O’Connell, Yariv Rabinovich, NancyRiddiough, and Ted Laux
Thanks especially goes to Ellen Dendy, for bringing us together on this venture,making sure that everything went smoothly with the rest of the team
On the home front, thank you, Nancy, for your constant love and support
Trang 12CONTENTS AT A GLANCE
Part I: Welcome to Linux
Part II: Installing Linux
Part III: Using Desktop Environments in Linux
Chapter 7: Installing and Configuring X Windows 109
Chapter 9: Using Applications with GNOME and X Windows 161
Chapter 12: Advanced X Windows Configuration 259
Trang 13Part IV: Mastering the Essentials
Chapter 15: Using LinuxConf and Other Tools for System
Configuration 333
Part V: Basic Connectivity
Chapter 22: Connecting Linux to the Internet 495
Part VI: Using Linux in the Small Office/Home Office (SOHO)
Chapter 28: Configuring Linux for an Ethernet Network 615Chapter 29: Integrating Linux in Windows and Novell Networks 643
Chapter 31: Security and Linux As an Inexpensive Router 685
Trang 14Part VII: Using Linux As a Web and E-Mail Server
Chapter 33: Linux As a Mail Server: The Power of Sendmail 787
Appendices
Appendix A: Linux around the World (Non-English Linux
Trang 15This page intentionally left blank
Trang 16Checking Your Hardware for Compatibility 32
Trang 17Sound Cards 34Monitors 34Mice 35
A Sample Partition Scheme for a Windows 98 System 40
Trang 185 Special Installations 69
X Servers, Window Managers, and
Contents xvii
Trang 19Preparing to Configure X Windows 116
8 Using GNOME and X Windows 137
9 Using Applications with GNOME and X Windows 161
Running an Application in an Xterm Window 171
Trang 2010 Advanced GNOME Configuration 193
Desktop 196
Multimedia 204Peripherals 205
Session 209
Contents xix
Trang 21Using Multiple Desktops 233
12 Advanced X Windows Configuration 259
The XF86Config File 260
The xinitrc File 279 The Xclients File 282
Trang 22PART IV: Mastering the Essentials 289
13 Introducing Linux Commands 291
pwd, cd, and ls 295
find, locate, and grep 300
14 Working with Files 315
Moving and Renaming 326
A Quick Introduction to Filename Expansion 330
Trang 23The Tests Menu 337
Trang 24Changing useradd Defaults 386
The init Program 392 Using the rc.local File 395
How crond Works 397
PCI 411External 411USB 412Printers 412
The printcap File 414
Modems 425
Contents xxiii
Trang 2520 Recompiling the Linux Kernel 455
Trang 26PART V: Basic Connectivity 481
21 Understanding Linux Networking 483
23 Using the World Wide Web 517
Amaya 519Lynx 520Opera 521Mosaic 522
Contents xxv
Trang 27Installing from the Web 524
25 Faxing from Linux 571
PART VI: Using Linux in the Small Office/Home Office (SOHO) 587
26 Where to Use Linux in the SOHO 589
Trang 28Linux As an Intranet Server 593
27 Installing Linux for the SOHO 601
28 Configuring Linux for an Ethernet Network 615
Contents xxvii
Trang 2929 Integrating Linux in Windows and Novell Networks 643
Sharing Linux Files and Printers with Windows Networks 644
30 Linux and DOS/Windows 663
31 Security and Linux As an Inexpensive Router 685
Trang 30Configuring Basic Network Settings 697
Part VII: Using Linux As a Web and E-Mail Server 703
32 Building Your Own Web Server 705
Apache 710NCSA httpd 710W3C/Jigsaw 711
WN 712Boa 712Stronghold 713FastTrack/iPlanet 713AOLserver 714
Zeus 715
Contents xxix
Trang 3133 Linux As a Mail Server: The Power of Sendmail 787
Smail 789Qmail 790
Trang 32C Linux Command Reference 817
D GNU General Public License 893
Terms and Conditions for Copying, Distribution, and Modification 895
Appendix: How to Apply These Terms to Your New Programs 900
E Linux on Non-Intel Hardware 903
Contents xxxi
Trang 33Thank you for buying this book, and welcome to the world of Linux As one
of the few alternatives to Microsoft operating systems on affordable desktop-classpersonal computers, Linux has gained notoriety and, more recently, acclaim as anexample of what can be done by a group of motivated people without any fiscalincentive
Linux is a freely distributable, efficient, fast operating system that offers thepower of Unix—once the domain of expensive servers and workstations—onhardware affordable to the budget-conscious home computer user This hassparked a mini-revolution in the computer world leading to acceptance of freesoftware for a wide range of tasks—from mission-critical Web sites to corporateinformation systems infrastructure to education applications
This book is designed as an introduction to the installation and use of Linuxbased on Red Hat Linux 7 Red Hat Linux 7 is a widely used version of Linuxthat is well suited to use on server systems, as well as Linux workstations anddesktop computers Any operating system with the breadth of features andcapabilities offered by Linux cannot be covered completely in a single book Still,this book provides the sound knowledge of Linux, and Red Hat in particular,needed for users to move on and learn more on their own as they use Linux intheir everyday work
Who Should Read This Book?
This book is really designed for anyone who uses a PC Although Linux may notyet have all the ease-of-use refinements found in commercial desktop operatingsystems such as Windows 95/98/Me and the Mac OS, Linux can be used byalmost anyone and mastered by anyone who can master Windows
Having said that, learning to use any operating system is always easier if youalready possess some basic computer knowledge, including an understanding ofthe difference between a hard disk and RAM, an understanding of the basic con-figuration (in Windows) of peripherals such as video cards and sound cards, and
Trang 34If you are already comfortable using a Windows or Macintosh system and youhaven’t experimented with the DOS prompt, it would be helpful to do so beforediving into the world of Linux, where the command line is more powerful, andtherefore more heavily used, than in the Windows arena.
If you are already a power user of Windows, then you are more than ready tobecome a power user of Linux Just as this book will make the everyday com-puter user proficient at getting their work done using Linux, it will help youbecome an advanced Linux user
This book also has something to offer for the SOHO (Small Office/Home Office)user or manager of a small network You will learn how to use Linux in many situ-ations in your office environment, in roles that include file server, intranet Webserver, and router
What You Need to Use This Book
To use this book, you will need access to a personal computer with the followingminimum specifications:
• A Pentium CPU or higher (In theory, you can run Linux on a 386 system, butthe performance will likely be poor enough that it isn’t worthwhile for mostusers.)
• 32MB of RAM or more (You will notice a significant performance gain ifLinux has 64MB or more of memory.)
• A hard disk with at least 1GB of free disk space (If you can afford 2GB ormore, this will greatly enhance your freedom to experiment with Linux andLinux applications.)
Trang 35• A CD-ROM drive (preferably an ATAPI/IDE CD-ROM or SCSI CD-ROMdrive)
• A backup of your current system in case you need to recover existing data
or applications
• A video card and VGA or better monitor
• A keyboard and mouseYou may also want to have the following options:
• A printer (Opt for a PCL or PostScript printer if you have a choice.)
• A sound card and speakers
• A telephone modem, ISDN modem, or other high-speed connection
How This Book Is Organized
This book is divided into seven sections:
Welcome to Linux This section introduces you to Linux as an operatingsystem and as the foundation of the GNU General Public License softwaremodel It looks at the most popular distributions (versions) of Linux andhelps you make preparations to install Linux on your system
Installing Linux This section covers the installation of a stand-alone Linuxsystem It includes a discussion of how to prepare to install Linux and spe-cial installations (such as on systems with no CD-ROM drive)
Using Desktop Environments in Linux This section looks at the use
of X Windows with the GNOME desktop manager (the standard Red HatLinux GUI) This discussion includes an overview of some common X Win-dows applications
Mastering the Essentials This section describes a range of essential skillsneeded to truly master Linux Topics covered include file management, sys-tem configuration, and printers and peripherals
Basic Connectivity This section explains how to connect a Linux system
to the Internet using a dial-up connection Topics covered include accessingthe World Wide Web and working with e-mail
Trang 36Introduction
Using Linux in the SOHO As an inexpensive but powerful computingenvironment, Linux is well-suited to many small or home office tasks Thissection looks at the installation of Red Hat Linux 7 in a networked officeenvironment and the use of Linux as a file or print server for Unix and Win-dows networks and will give you an awareness of basic security issues whenusing Linux in a networked environment Finally, this section examines DOSand Windows compatibility and integration in Linux, which allows manyorganizations to migrate from their current Windows environments to Linuxwithout sacrificing their current investment in software and applications
Using Linux As a Web and E-Mail Server In addition to being an ideal fileand print server for the SOHO, Linux can be used to create robust enterpriseWeb and mail servers This section describes how to set up Linux-based Weband mail servers
If you already have some experience with Linux, you probably can skip straight
to the second section of the book, “Installing Linux,” and begin installing a Linuxsystem If you have never used Linux before, start at the beginning with “Welcome
to Linux” to get your feet wet and become comfortable with the world of Linuxand its dynamic nature Whatever your background, though, always rememberthat computers are tools that bring added power to your work, and Linux is agreat way to enhance that role
Trang 37P A R T I
Trang 38■ CHAPTER 1: What Is Linux?
■ CHAPTER 2: Choosing a Distribution
Welcome to Linux
Trang 39This page intentionally left blank
Trang 40C H A P T E R
O N E
What Is Linux?
■ Linux History
■ Linux as an Operating System
■ Linux as Free Software
■ Commercial Applications for Linux
1