Master Linux systemadministration Discover the power of Debian’s package management system Build a network and set up Linux servers Steve Hunger Foreword by Ian Murdock, Founder of Debia
Trang 1Master Linux system
administration
Discover the power
of Debian’s package
management system
Build a network and
set up Linux servers
Steve Hunger Foreword by Ian Murdock, Founder of Debian and now Cofounder of Progeny Linux Systems
—Branden Robinson, Debian Developer
Trang 2If Debian GNU/Linux can do it, you can do it too
Whether you’re a Linux newcomer looking for foolproof installation tips or a Debian GNU/ veteran who wants
the scoop on the latest security enhancements, this authoritative guide delivers all the information you need to
make the most of the Debian GNU/ “potato” release From customizing a desktop system to troubleshooting a
network or setting up an e-commerce server, it’s the only reference you’ll ever need to become a Debian GNU/
• Learn your way around the Linux shell, file
system, and X Window System
• Discover how easy it is to set up a LAN
in Debian and connect to the Internet
• Make the most of Linux desktop applications,
games, and multimedia features
• Master Linux administration, from automating
system tasks to locking in security
• Find guidance on how to keep Debian current
and bug-free
• Get the scoop on configuring servers, from
Apache and FTP to NIS and Sendmail
Master Linux system administration
Discover the power
of Debian’s package management system
Build a network and set up Linux servers
Steve Hunger Foreword by Ian Murdock, Founder of Debian and now Cofounder of Progeny Linux Systems
Trang 4Debian GNU/Linux
Bible
Steve Hunger
Hungry Minds, Inc
Indianapolis, IN ✦ Cleveland, OH ✦ New York, NY
Trang 5New York, NY 10022
www.hungryminds.com
Copyright 2001 Hungry Minds, Inc All rights
reserved No part of this book, including interior
design, cover design, and icons, may be reproduced
or transmitted in any form, by any means (electronic,
photocopying, recording, or otherwise) without the
prior written permission of the publisher.
Library of Congress Catalog Card No.: 2001089113
ISBN: 0-7645-4710-0
Printed in the United States of America
10 9 8 7 6 5 4 3 2 1
1B/SW/QU/QR/IN
Distributed in the United States by
Hungry Minds, Inc.
Distributed by CDG Books Canada Inc for Canada; by
Transworld Publishers Limited in the United
Kingdom; by IDG Norge Books for Norway; by IDG
Sweden Books for Sweden; by IDG Books Australia
Publishing Corporation Pty Ltd for Australia and
New Zealand; by TransQuest Publishers Pte Ltd for
Singapore, Malaysia, Thailand, Indonesia, and Hong
Kong; by Gotop Information Inc for Taiwan; by ICG
Muse, Inc for Japan; by Intersoft for South Africa; by
Eyrolles for France; by International Thomson
Publishing for Germany, Austria, and Switzerland; by
Distribuidora Cuspide for Argentina; by LR
International for Brazil; by Galileo Libros for Chile; by
Ediciones ZETA S.C.R Ltda for Peru; by WS
Computadoras S.A de C.V for Mexico; by Editorial Norma de Panama S.A for Panama; by American Bookshops for Finland.
For general information on Hungry Minds’ products and services please contact our Customer Care department within the U.S at 800-762-2974, outside the U.S at 317-572-3993 or fax 317-572-4002.
For sales inquiries and reseller information, including discounts, premium and bulk quantity sales, and foreign-language translations, please contact our Customer Care department at 800-434-3422, fax 317-572-4002 or write to Hungry Minds, Inc., Attn: Customer Care Department, 10475 Crosspoint Boulevard, Indianapolis, IN 46256.
For information on licensing foreign or domestic rights, please contact our Sub-Rights Customer Care department at 212-884-5000.
For information on using Hungry Minds’ products and services in the classroom or for ordering examination copies, please contact our Educational Sales department at 800-434-2086 or fax 317-572-4005 For press review copies, author interviews, or other publicity information, please contact our Public Relations department at 650-653-7000 or fax 650-653-7500.
For authorization to photocopy items for corporate, personal, or educational use, please contact Copyright Clearance Center, 222 Rosewood Drive, Danvers, MA 01923, or fax 978-750-4470.
LIMIT OF LIABILITY/DISCLAIMER OF WARRANTY: THE PUBLISHER AND AUTHOR HAVE USED THEIR BEST EFFORTS IN PREPARING THIS BOOK THE PUBLISHER AND AUTHOR MAKE NO REPRESENTATIONS OR WARRANTIES WITH RESPECT TO THE ACCURACY OR COMPLETENESS OF THE CONTENTS OF THIS BOOK AND SPECIFICALLY DISCLAIM ANY IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE THERE ARE NO WARRANTIES WHICH EXTEND BEYOND THE DESCRIPTIONS CONTAINED IN THIS PARAGRAPH NO WARRANTY MAY BE CREATED OR EXTENDED BY SALES REPRESENTATIVES OR WRITTEN SALES MATERIALS THE ACCURACY AND COMPLETENESS OF THE INFORMATION PROVIDED HEREIN AND THE OPINIONS STATED HEREIN ARE NOT GUARANTEED OR WARRANTED TO PRODUCE ANY PARTICULAR RESULTS, AND THE ADVICE AND STRATEGIES CONTAINED HEREIN MAY NOT BE SUITABLE FOR EVERY INDIVIDUAL NEITHER THE PUBLISHER NOR AUTHOR SHALL BE LIABLE FOR ANY LOSS OF PROFIT OR ANY OTHER COMMERCIAL DAMAGES, INCLUDING BUT NOT LIMITED TO SPECIAL, INCIDENTAL, CONSEQUENTIAL, OR OTHER DAMAGES
Trademarks: All brand names and product names used in this book are trade names, service marks,
trademarks, or registered trademarks of their respective owners All other trademarks are the property of their respective owners Hungry Minds, Inc., is not associated with any product or vendor mentioned in this book.
is a trademark of Hungry Minds, Inc.
Trang 6supporting and integrating multiple platforms for a Fortune 500 Company Havingbeen introduced to UNIX while attending Purdue University, he quickly latched ontoLinux as the primary platform for his startup Web hosting and development busi-ness in 1996 He continues operating his Web business, consulting with local busi-nesses, and freelance writing When not conquering the world with Linux, he hasco-written and contributed to several books for Macmillan USA and Brady Games,including work on the line of Mandrake Linux products His latest work has been for
AOL Press called Powering Up the Internet
In his spare time he enjoys relaxing with his wife, riding bicycles, and tinkering with
an R/C model that is evolving into something that looks amazing like a plane He isalso on the Board of Directors for the Central Indiana Linux Users Group
(www.cinlug.org) Steve can be reached at steve@rhinoworld.com
Trang 7Proofreading and Indexing
York Production Services, Inc
Trang 9In January 1993, while browsing USENET news one evening after work, I ran
across a thread with a subject line that read, simply, “LINUX.” I’m not sure what
it was about the word “LINUX” that made me hit Enter, but I did, and within a fewminutes, it was clear to me that I had to have it
Unfortunately, that’s about where I hit a brick wall I had just enough informationabout Linux to whet my appetite, but there was precious little more of it to befound Over the course of the next few weeks, I hunted down and pieced togetherthe rest of what I needed to know: where to find it, how to download it, how toinstall it, and what I could do with it once I had installed it
It was a tedious process, because only scraps of information were available, andthose scraps were scattered about all over the place — a bit on a USENET grouphere, a bit more on an FTP site there And even when found and pieced together,the scraps did not form a complete picture — I had to fill in large gaps for myself All
in all, it was a tremendous learning experience, but it was also a tremendously trating and time-consuming experience, and if presented with the same obstaclestoday, I likely would not have had the time or the inclination to overcome them.Fortunately, becoming a Linux user is much easier today than it was in 1993 Thesoftware itself has come a long way, and a wide range of books on the subject areavailable, from installation and use to programming to administration and manage-ment These days, the local bookstore has all the information you need to getstarted and become productive as a Linux user
frus-One subject that has not been covered as extensively as others, a subject near anddear to my heart, is Debian, a project I founded not long after discovering Linux.Debian has much to offer the Linux user — a huge selection of software, an opendevelopment process that leads to rapid bug fixes and improvements, an unparal-leled software management facility that allows software to be installed easily andsystems to be upgraded non-disruptively, and much more — but it has long
remained a daunting prospect to piece together the information you need to getthere
Trang 10And, so, I am extremely pleased to see books such as my friend Steve Hunger’s
Debian GNU/Linux Bible Debian GNU/Linux Bible contains all the information you
need to know to get the most out of Debian, from installing it to using its powerfulpackage management system to install software and upgrade your system to setting
up a Web server and other advanced topics With Debian GNU/Linux Bible by your
side, you will be well prepared to join the large and growing group of users that callDebian home I hope this book serves you well
Ian Murdock
Founder of Debian and Co-founder of Progeny Linux Systems, Inc
Trang 11As Linux becomes more and more popular, resources to learn and use Linux
become more important These resources help to guide, direct, and inform anindividual to make the best use of the tools available, just as a stack of boards,nails, and a hammer don’t make a house — it takes the skilled craftsmanship of a
carpenter to turn the parts into a whole house Debian GNU/Linux Bible gives you
the skilled guidance to help you turn the individual parts into a system
Whom This Book Is For
This book covers the many aspects of the Debian GNU/Linux system, from the tial install of this reputable operating system to the more advanced functions likeWeb servers or file servers You do not need to have any special programming expe-rience to use this book You may just want to learn how to use Debian as a work-station environment
ini-This book does assume some level of general computer knowledge, even thoughnot specifically related to Linux or UNIX Many people get introduced to Linux afterbecoming familiar with another operating system You may be someone who wants
to learn something new, someone who wants to know what all the buzz is aboutLinux, or someone who just likes the idea that the software and upgrades are free.Whatever the reason you are reading this book, I’m sure that you will find assis-tance in the pages of this book You will find everything from installation to admin-istration to server setup This book will give you the boost needed to set up a home
or office network and to maintain that network of computers
How This Book Is Organized
This book is organized in a progression of skill as well as function The beginning ofthe book starts out with an overview of Linux It then progresses to the conceptsneeded for average use Then, it concludes with the concepts needed for moreintense use
For those who are fairly new to Linux, this book will help them get their feet wet.Some of the basic concepts, commands and tools are explained in the beginningchapters of this book As you become more experienced with Linux and specifically
Trang 12Debian GNU/Linux, you move into the intermediate areas of the book, namely themiddle sections Lastly, the experienced administrator who will from time to timeneed instruction on specific services can find this information in “Part III:
Administering Linux.”
Now that you have an idea of the overall layout of the book, let’s look over the bookchapter by chapter The following will describe the contents of the book in slightlymore detail
Part I: Getting Started
Part I provides the basic introduction to Debian GNU/Linux The chapters in thispart start with background on Linux in general and the beginnings of the Debiandistribution; walk you through the important steps on getting Debian GNU/Linuxinstalled on your system; cover the essential base set of commands used to navi-gate through the newly installed system; cover the differences between desktopmanagers, desktop environments, and window managers; explain the requirementsand configuration of setting up a network and describe tools used to test, diagnose,and evaluate the network once installed; and help you connect your system to theInternet and explain some of the applications you’ll need for such things as e-mail,news, and Web browsing
Part II: Working with Debian
Chapters in Part II explain how to install additional applications on the system,cover the features and functions of the popular Office-like application suites avail-able to Linux, describe the intermediate commands found on the system (useful tothose interested in going on to the next step), provide examples of applications thatappeal to the senses — sight and sound alike, and list the multitude of games avail-able for Linux (no computer user is complete with out at least trying some of thegames)
Part III: Administering Linux
The chapters in Part II cover the concerns that administrators face when managingone system or many, deal with the programming environment found with Linux(including the most common environments, like Perl, Tk/Tcl, and C), explain themost amazing environment that makes Linux so powerful and how to mix the envi-ronment with the programming of scripts, detail the core part of the Linux
system — the kernel, and explain how to modify and create new versions of the kernel specifically designed for your needs
Trang 13Part IV: Maintenance and Upgrade
Chapters in this part direct you on keeping the system updated and current to
pre-vent problems from creeping in, describe some of the hardware and how to make
changes to the system to accommodate additions, and explain why backups are
important
Part V: Linux Server
In Part V, chapters detail how to lock down the security of a Linux system to
pre-vent intrusion; cover how Debian can be used as the first line of defense to protect
a home or office network; show you how to publish Web pages on the network or
Internet; explain how to set up a server to allow the transfer of files from any
num-ber of clients using the File Transfer Protocol; provide information on setting up a
central Network Information Server to manage a medium-sized to large network or
account; describe how to create a central point from which to share, store, and
archive files in one place; and list the servers used to handle electronic mail, one of
the most-used forms of communication among most medium-sized to large
companies
Appendixes
The book concludes with three appendixes
✦Appendix A, “What’s On the CD-ROM,” provides you with information on the
contents of the CD-ROM that accompanies this book
✦Appendix B, “Linux Commands,” covers many of the commands found in the
common areas on the Linux filesystem
✦Appendix C, “Debian Packages,” presents a list of commonly used Debian
packages with a short description of each
System Requirements
Nearly all software has some level of requirements when referring to hardware that
it is run on Debian GNU/Linux is no different Even though Debian is available for
different platforms, the one used in this book is the i386-based platform This
includes processors ranging from the Intel series (386, 486, Pentium class, and
other variations), AMD, and any of the other “Intel clone” processors Other
proces-sor platforms will operate similarly, so this book can still operate as a reference
even though they may not be specifically referred to
Trang 14Beyond the core processor, the other components will be supported to varying els For each of those, I will redirect you back to the manufacturers or to one of themany Web site where the information about using hardware with Linux is available.One such site is www.linuxdoc.com.
lev-At the minimum, your systems should include at least a i486 class processor with8MB of RAM, a 500MB hard disk and either a bootable floppy drive with CD-ROMdrive or a bootable CD-ROM drive However, this distribution of Debian GNU/Linuxwill work on systems with less If you intend on using the i486 class processor as aworkstation, I recommend a higher standard for better response
Conventions
There are several conventions used within this book that will help you to get moreout of it The first is the use of special fonts or font styles to emphasize a specialkind of text; the second is the use of icons to emphasize special information
✦There are some situations when I’ll ask you to type something This
informa-tion always appears in bold type like this: Type Hello World.
✦Code normally appears on separate lines from the rest of the text However,there are some special situations when small amounts of code appear right inthe paragraph for explanation purposes This code will appear in a
monospaced font like this: Some Special Code URLs for Web sites are alsopresented in monospaced font like this: http://www.microsoft.com
✦Definitions are always handy to have I use italics to differentiate definitions
from the rest of the text like this: A CPU is the central processing unit for your
machine
✦In some code examples, I won’t have an exact value to provide so I’ll give you
an idea of what you should type by using italics and monospaced font likethis: Provide a Machine Namevalue for the Namefield
The following icons identify useful and important asides from the main text
Notes help you to understand some principle or provide amplifying information Inmany cases, a Note is used to emphasize a piece of critical information that youneed
Any time that you see a Caution, make sure that you take special care to read it.This information is vital I always uses the Caution to designate information thatwill help you to avoid damage to your application, data, machine, or self Neverskip the Cautions in a chapter and always follow their advice
Caution
Note
Trang 15All of us like to know special bits of information that will make our job easier,
more fun, or faster to perform Tips help you to get the job done faster and more
safely In many cases, the information found in a Tip is drawn from experience,
rather than from experimentation or from the documentation
There are times when information in another area of the book will help you to
bet-ter understand the current discussion I always include the Cross-Reference icon to
indicate additional material that you might need
Cross-Reference
Tip
Trang 16Iwould first like to thank the Debian development community Without their hard
work, high standards, and volunteer efforts, this Linux distribution would nothave the reputation it does today So these thanks goes out to the hundreds ofthose volunteers
I would also like to thanks the two contributors to this book, John Goerzen andShawn Voss John wrote the chapter on the available programming environments inDebian Shawn wrote the chapter on the shell environments and shell scripts
I would also like to thank everyone who has worked to produce this book —specifically, Terri Varveris for her efforts in planning, scheduling, and the otherdetails involved with getting a book like this to the shelves and Gus Miklos for allhis work making sure that what I wrote down could actually be read and under-stood by others I’d also like to thank Steve Schafer for his efforts editing the technical aspects of the book content And a thanks go out to all the other involved
at differing levels on this book
Thanks to all those who has had to listen to me get on my soap box about Linuxover the years — especially my wife for her patience while I spent the hours
chained to the computer working on some project or other
Trang 17Foreword ix
Preface xi
Acknowledgments xvi
Part I: Getting Started 1
Chapter 1: Introduction to Linux 3
Chapter 2: Installing Debian 13
Chapter 3: First Steps as a Linux User 41
Chapter 4: Choosing a GUI 63
Chapter 5: Networking 91
Chapter 6: Setting Up for the Internet 113
Part II: Working with Debian 131
Chapter 7: Applications 133
Chapter 8: Productivity Applications 157
Chapter 9: Essential Tools 179
Chapter 10: Multimedia 203
Chapter 11: Games 217
Part III: Administering Linux 235
Chapter 12: System Administration 237
Chapter 13: Scripting 265
Chapter 14: Shells 293
Chapter 15: Linux Kernel 313
Part IV: Maintenance and Upgrade 335
Chapter 16: Finding Updated Files 337
Chapter 17: Hardware 347
Chapter 18: Backups 371
Trang 18Part V: Linux Server 395
Chapter 19: Security 397
Chapter 20: Firewall 415
Chapter 21: Web Server 431
Chapter 22: FTP Server 463
Chapter 23: Network Information System 485
Chapter 24: File Server 495
Chapter 25: Mail 517
Appendix A: What’s On the CD-ROM 539
Appendix B: Linux Commands 543
Appendix C: Debian Packages 557
Index 625
GNU General Public License 659
CD-ROM Installation Instructions 664
Trang 19Foreword ix
Preface xi
Acknowledgments xvi
Part I: Getting Started 1 Chapter 1: Introduction to Linux 3
Understanding the Role of the Operating System 3
History of GNU/Linux 5
Linux versus Other Operating Systems 6
The Word on Free Software and Open Source 8
What’s So Special about GNU/Linux? 8
Understanding the Debian Distribution 10
Chapter 2: Installing Debian 13
Preparing Your System 13
Basic Debian Installation 15
Booting off the CD 16
The main menu 16
Configuring the keyboard 17
Partitioning a hard disk 17
Initializing and activating a swap partition 18
Initializing a Linux partition 18
Initializing the operating system kernel and modules 19
Configuring device driver modules 20
Configuring the network 21
Installing the base system 22
Configuring the base system 23
Booting Linux directly from the hard drive 24
Making a boot floppy 24
Rebooting the system 25
Trang 20Configuring the Debian system 25
Apt configuration 27
Using the Debian Package-Management System 31
What are deb packages? 32
Adding deb packages 32
Changing the package archive source 35
Gnome-apt 36
Installing Non-Debian Software 37
RPM packages 37
tar packages 38
Chapter 3: First Steps as a Linux User 41
Logging In and Out of Linux 41
Basic Navigation with Linux 43
Finding special file locations 43
Finding ready-reference documentation 45
Maneuvering through the files 48
Stopping the System 56
Using the reboot, halt, and poweroff commands 56
Using the shutdown command 57
Working with the Filesystem and Related Commands 58
Mounting drives 59
Chapter 4: Choosing a GUI 63
Linux’s Graphical User Interface 63
Deciding on a Graphical Interface 65
Installing and Configuring the X Environment 66
X system requirements 67
Installing fonts 68
Installing the Display Manager 69
XF86Setup 69
Starting the X server 76
Starting X remotely 76
Managing the X server 77
Installing and Using Window Managers 79
FVWM 79
Enlightenment 81
Window Maker 83
Trang 21Installing and Using Desktop Environments 84
GNOME 84
KDE 86
Troubleshooting Your New Components 88
Chapter 5: Networking 91
Components of the Linux Network 91
TCP/IP Network Protocols 92
IP addresses 93
Network classes 94
Ports and services 95
Netmasks 95
Understanding Host Names 96
Understanding Domain Names and the DNS 97
Setting Up the Physical Network 100
Ethernet cards 100
Hubs and switches 101
Cables 101
Setting Up the Network 103
Making Changes to the Network 104
Making manual changes 104
Adding IP addresses to one Ethernet card 105
Troubleshooting the Network 105
Using dmesg to troubleshoot 106
Using ifconfig to troubleshoot 106
Using ping to troubleshoot 108
Using traceroute to troubleshoot 109
Using route to troubleshoot 110
Chapter 6: Setting Up for the Internet 113
Connecting to an ISP 113
Using wvdial to connect 114
Using diald to connect 115
Web Browsers 118
E-Mail Clients 118
Balsa 119
Netscape 120
mutt 121
Trang 22mail 122Mail utilities 122News Clients 125PAN 125Netscape 126tin newsreader 126FTP Clients 127Telnet 128Dial-in PPP Server Setup 129
Chapter 7: Applications 133
Installing Applications 133Using the Windows Application with Linux 134DOSEMU 134Wine 136VMware 140Plex86 142Graphics Programs 143Gimp 143ImageMagick 146Browsers 148Lynx 148Mozilla 151Opera 152Netscape 153
Chapter 8: Productivity Applications 157
StarOffice 157Installation 158The StarOffice desktop 160Applixware 166Installation 166Navigating Applixware 167
Trang 23Chapter 9: Essential Tools 179
Using Text Editors in Debian GNU 179
Learning to use vi 180
Learning to use Emacs 186
Using Commands and Programs 188
The more program 194
The less program 195
Automating Tasks 196
The at command 197
The batch command 198
The cron command 198
The anacron command 200
Chapter 10: Multimedia 203
Listening to Audio Files 203
Audio file formats 206
Trang 24Chapter 11: Games 217
System Considerations for Gaming 217Graphical interfaces 217Sound system requirements 218Other system demands 219Playing Debian-Packaged Games 219Adventure games 220Arcade games 221Board games 222Card games 223Simulation games 224Strategy games 225Multi-player games 226GNOME games 228Playing Commercial Games 229SimCity 3000 Unlimited 231Unreal Tournament 232
Chapter 12: System Administration 237
The Roles of the System Administrator 237The System Administrator and the Root Account 239Using the su command 240Using the sudo command 241Administering and Setting up Accounts 242The passwd file 242The purpose of shadow passwords 243The group file 243Employing adduser to add a user account 244The new user template — skel 245Using userdel to remove a user 246Restricting access to the root account 246Setting File and Directory Permissions 246Access with chmod 247Changing user ownership with chown 249Changing group membership with chgrp 250
Trang 25Using Quotas for Accounts 251
Installing quotas 251
Using edquota 252
Quota reporting 253
Using System Monitoring Tools 255
Monitoring system log files 255
Disk monitoring 258
User monitoring 260
Automated monitoring 263
Chapter 13: Scripting 265
Working with Perl 265
Finding documentation for Perl 265
Using modules 267
Using Java 272
Using Kaffe and the Sun JDK 273
Using gcj 273
Finding documentation for Java 274
Using Java libraries 274
Troubleshooting 275
Using Tcl/Tk 276
Finding documentation for Tcl/Tk 277
Adding Tcl/Tk libraries 277
Programming With Python 278
Finding documentation for Python 278
Installing Python libraries 279
Using the shell 294
The Command Line 294
Standard input and output 295
Command substitution 298
Trang 26Jobs and job control 300Escaping — special characters 303Shell variables 303The Shell Variants 306Bourne shell 306
C shell 308Korn shell 309Special shell characters 310Shell Scripts 311
Chapter 15: Linux Kernel 313
Configuring the Linux Kernel 313Kernel code and versions 315Kernel modules 316Adding modules on the fly 317Upgrading and updating the kernel 318Making changes to the kernel 319Compiling and installing a new kernel 322Using the Linux Boot Loader 324Configuring LILO 325Adding the new kernel to LILO 326Booting to other operating systems 327Testing and installing a new LILO configuration 327System Initialization 328Run levels 330Initialization scripts 331Adding and removing daemon programs 334
Chapter 16: Finding Updated Files 337
Defining System Bugs 337Bugless software 338Stable versus secure 339Bugs versus features 339Getting help and reporting bugs 340Patches that fix bugs 341
Trang 27Updating Debian Files with the Package-Management System 341
Upgrading from an older Debian version 343
Upgrading over the Internet 343
Upgrading from installation CD-ROMs 345
Chapter 17: Hardware 347
Finding Linux-Compatible Hardware 347
Finding Linux-Compatible Laptops 353
Adding Hardware to Your Linux System 356
Hard drives and CD-ROM drives 357
Changing video cards 358
Adding and changing network cards 359
Adding Peripheral Devices 361
Iomega drives (Zip, Jaz, and so on) 361
Scanners 362
Printing 362
Offline printing 365
Setting up printer queues 367
Apsfilter configuration tool 368
Chapter 18: Backups 371
Planning for Failure 371
Choosing a Backup Technique 372
Knowing what to back up 373
Knowing what to back up with caution 374
Choosing adequate media 375
Choosing a backup method 377
Selecting Your Backup and Restore Tools 378
Trang 28Recovering from a Crashed System 392Rescue disk boot options 393Fixing disk problems 393
Chapter 19: Security 397
Understanding the Need for Security 397Avoiding crackers 398Tools of the Trade 399Authentication tools 399Network monitoring tools 401Service and integrity tools 402Diagnostic tools 402Other helpful tools 404Limiting the Available Services 405Viruses, worms, and other creepy things 407Setting secure permissions 407
A word about passwords 408Tips for Securing Your System 409The compromised system 412Sources for additional information 413
Chapter 20: Firewall 415
Protecting a Network 415Hardware Requirements and Preparations 416Adding a Second Network Card 417Using ipchains 419Masquerading a Private Network 422Configuring a Firewall with PMFirewall 423Locking Down the Firewall 425Squid Proxy Service 426Accessing the Internet through a Firewall/Proxy 428
Trang 29Chapter 21: Web Server 431
Introduction to Apache Web Server 431
Installing the Apache Server 432
Configuration files 434
The httpd.conf configuration file 434
The srm.conf configuration file 444
The access.conf configuration file 453
Controlling the daemon 456
Monitoring the Web server 456
Setting Controls for Web Pages 457
The wu-ftpd server 466
The proftpd server 472
Chapter 23: Network Information System 485
The Network Information System 485
An overview of NIS 486
Configuring a Master NIS Server 487
Configuring a NIS Client 489
Configuring a NIS Slave Server 490
Using NIS Tools 491
Administering NIS 492
Trang 30Chapter 24: File Server 495
Using the Network File System 496Installing and running NFS 496Setting up the NFS shares in /etc/exports 497Mounting an NFS share automatically 499Mounting an NFS file system manually 501Unmounting an NFS filesystem 502Sharing Files Using Samba 502Installing Samba 503Configuring Samba 503Testing the Samba server 511Configuring Samba with SWAT 512Configuring Samba with gnosamba 513Checking the network with smb-nat 514Connecting to a Samba server from Linux 514Connecting to a Samba server from Windows 515Sharing files between Linux and Windows machines 515
Chapter 25: Mail 517
Understanding Internet E-Mail Protocols and Standards 517exim 519Using Sendmail 525Questions during installation 525Alternatively configuring sendmail 528Testing and using sendmail 529General Mail Considerations 530E-mail aliases 530Forwarding your mail 531Virtual mail server 532DNS and Internet mail 533Using mailing lists 534Setting Up POP 534Installing and configuring POP 534Testing POP 535Setting Up IMAP 536Installation and configuration 536Testing IMAP 536Getting Help 537
Trang 31Appendix A: What’s On the CD-ROM 539
Using the CD with Linux 539
GNU General Public License 659
CD-ROM Installation Instructions 664
Trang 33Introduction to
Linux
Welcome to the Debian GNU/Linux Bible where you
can find hints, tips, and helpful instructions on most
areas of this robust operating system As you begin to learn
more about this distribution of the Linux operating system,
I’m sure you will find that you have made an excellent choice
Debian GNU/Linux is one of the best-kept secrets from the
general public
In case you were wondering, GNU stands for GNU’s Not
UNIX, which still doesn’t answer the question of the
defini-tion of GNU That’s the best I can come up with
This chapter covers the background of Linux, what makes it
special, and how Debian compares to other operating
sys-tems You will discover the true meaning behind free software
and why it is so important to Debian
Before you begin to read about the origins of this great
operat-ing system, I open with a definition of the operatoperat-ing system
This helps to define how you look at the accomplishments
described later
Understanding the Role of the
Operating System
The operating system controls the interaction between
hard-ware and the softhard-ware applications The hardhard-ware consists of
the processor, hard drives, video cards, sound cards, and more
Each processor has built into it a language that only it
under-stands, plus each manufacturer creates a different language for
its processor For instance, an Intel x86 processor uses a
differ-ent internal language than, say, a Motorola 68000 processor
Therefore, any software must be complied (converted into the
Understanding thehistory of LinuxConsidering the storybehind Open SourceComparing Linux toother operatingsystemsUsing the DebianDistribution
✦ ✦ ✦ ✦
Trang 34processor language) or customized for the processor (often referred to as the
com-puter platform) Some of the platforms include:
✦x86 (Intel [386, 486, Pentium, Pentium II, Pentium III, Celeron], AMD [K6-2,Athlon, or others equivalent to the Intel line])
✦Alpha (Was DEC, Now Compaq)
✦Power PC, also known as PPC (Motorola/IBM Power PC)
✦M68k (Motorola 68000 series)
✦Sparc (Sun Microsystems’s SPARCstation)
The core component to the operating system is called the kernel in UNIX and
UNIX-like operating systems The kernel communicates with the basic computer ware like the microprocessor, memory, and device controllers All interactionbetween the hardware and any programs must be negotiated through the kernel.The kernel takes care of translating the requests into the form the particular devicespeaks This includes everything from drawing a picture to saving a file to a floppy
hard-to printing a document In addition hard-to the kernel, the user interface, device drivers,file system, and system services complete the whole operating system and make itfunctional for someone to use
✦The user interface makes it possible for the individual to interact with thecomputer to issue commands, launch programs, and generally control thecomputer This usually starts as a command-line interface and later becomessome kind of graphical interface One example of the interface is the shellwhich allows commands to be typed in and the output gets displayed to thescreen in text form Chapters 4 and 14 cover the graphical interface and shellinterface respectively
✦The device drivers allow the kernel to talk to the various devices, such ashard drives and modems, which are connected to the computer Each hard-ware device speaks its own language, and the operating system must be capa-ble of interacting with it In order for a specific piece of hardware to be used,like the mouse, hard drive or sound card, the corresponding driver must beinstalled for it to get used See Chapter 17 for more information about hard-ware or Chapter 15 for the kernel details
✦The information for the operating system — such as programs, data, andsuch — gets stored to a disk The filesystem sets the method that the informa-tion gets stored Different operating systems use different methods of storingtheir data For instance Windows 3.1 uses File Allocation Tables (FAT) fir itsfilesystem Newer versions of Windows like 95 and 98 use a more advancedversion called FAT32 And Windows NT uses NTFS for its filesystem Not all ofthese filesystems are compatible with all operating systems, even among theWindows family Windows NT can read FAT and NTFS, but not FAT32 Likewise, Windows 95 and 98 can read FAT and FAT32, but not NTFS Linux usesEXT2, but can read FAT and FAT32 using the VFAT driver You can learn moreabout this scattered through the book
Trang 35✦When the computer starts up, some functions, features, or services start to
manage the system For instance, when Linux first starts, it loads the
filesys-tems, network interfaces, and any background services known as daemons.
When the filesystem loads, it assigns what drives get used The network
inter-face gets initialized and configured to communicate on the network
A daemon is a program that runs in the background without anyone being aware
of it until it is needed (This is referred to as services in the Windows NT world.) For
instance, a Web server (Chapter 21) runs in the background because it was
designed to work with out human intervention
Now that you have a better understanding of what an operating system is, you can
move on to see what Linux is all about
History of GNU/Linux
Free operating systems are not a new concept in the computer world, (The
aca-demic versions of UNIX, Slackware, and FreeBSD come to mind.) Then a student of
the University of Helsinki, Linus Torvalds announced in 1991 that he had created a
very experimental operating system core called a kernel, based on a clone of UNIX
called Minux This new operating system kernel later became known as Linux
Torvolds chose this UNIX variant because of the well-respected stability, design and
functionality of the UNIX operating system developed by Bell Laboratories
This new operating system kernel was refined for maximum performance on the Intel
386 microprocessor, which made this new Linux kernel platform specific This
gener-ated criticism from some corners of the UNIX software world Traditionally, UNIX was
independent of platform, meaning that you could use the softeware with different
computer processors without much trouble This didn’t stop Torvalds from
continu-ing to develop his kernel His efforts eventually led him to the free software
commu-nity where programmers got behind his efforts and contributed to the new kernel
However, long before Torvalds started work on his Linux kernel, Richard M
Stallman left his job at the MIT Artificial Intelligence Lab to develop a UNIX-like
operating system He formed the Free Software Foundation and developed the GNU
General Public License (GPL) Stallman began working on various software
pro-grams for his GNU operating system project (By the way, GNU is pronounced with
a hard G, ga-nu) By 1991, he had most of the software pieces of the GNU operating
system complete with the exception of the kernel In 1990, he started working on
the kernel and named it HURD (Hird of UNIX-Replacing Daemons) Hird stands for
Hurd of Interfaces Representing Depth According to an interview with Stallman,
people interested in the GNU project began to put Torvald’s Linux kernel with
Stallman’s GNU operating system to form the GNU/Linux operating system
The HURD project is a rewrite of the UNIX kernel The difference between this
ker-nel and others is that it has an object-oriented structure that enables you to
change, add, or remove components without major rewrites of the entire kernel
Currently, HURD only works with the Intel i386 and the last official release was
Note
Note
Trang 36back in 1997 However, it remains an active project Had the Linux kernel beenavailable in 1990, Stallman says they would not have started their own.
In truth, from its adoption as an operating system, the rightful name of Linux isreally GNU/Linux Linux is really only the kernel (the core component) and GNUcontains the supporting applications around the kernel that make it functional.These supporting applications include the user interface and all other applications(editors, Most refer to GNU/Linux as simply Linux, which you may even see in thisbook from time to time for the sake of brevity Please understand I mean no disre-spect to the developers
Linux versus Other Operating Systems
When Bill Gates, founder of Microsoft, made his deal with IBM to include his disk ating system (DOS) with IBM personal computers, his goal was to put a computer inevery home Today many homes do have personal computers (PCs), and most usesome type of Microsoft operating system Until recently, a Microsoft operating systemwas your only preinstalled choice when purchasing a new personal computer Now,many name brand PC manufacturers — such as Dell, Compaq, and others — offer otheroperating systems Table 1-1 shows a list of many of the operating systems
oper-Table 1-1 Popular PC operating systems and platforms
Operating System Platform
Linux (Debian) Intel x86, PowerPC, M68k, Alpha, Sparc, ARM
Windows NT/2000 Intel x86, PPC
As you can see from Table 1-1, no other operating system can be used with nearly
as many platforms as Linux can Plans are in the works by Linux developers toinclude others, such as sparc64, MIPS, and PS-RISK Development teams of program-mers from all around the world are credited for this outstanding growth
Even though the Windows 95/98 operating system gained vast popularity due to itsprofessed user friendliness, GNU/Linux has made steady improvements to reachthe same level of user friendliness In 1999, the growth rate seen by Linux exceeded
Note
Trang 37the growth of Windows NT Despite the strong marketing power, available
resources, and influence of the big boys, the cheap (by price only) operating
sys-tem called Linux is taking the world by storm
Table 1-2 lists some significant differences between Linux and the other operating
systems:
Table 1-2 Benefits of Linux
Benefit Description
Costs nothing Linux is the only operating system that costs nothing All others listed
have some purchasing fee ranging from just under $100 to several hundred dollars For a business with several servers and
workstations, this can add up fast.
Downloadable With a fast Internet connection, you can have your operating system
available in a short period of time No need to order it, have it shipped, or visit a local computer dealer to get the copies you need.
Freely distributed Make as many copies of Debian GNU/Linux as you want or need
There is no copyright with GPL software except that the source code must be included Other operating systems require a purchased license for each installation.
Built by volunteers Other operating systems are company creations in which all the
work is either contracted or programmed in-house Volunteers make
up the primary programming body of Linux Some companies contribute to the cause for the benefit of the whole This volunteer principle contributes to its overall stability.
Source code available When you buy an operating system off the shelf, you only get the
compiled version ready to run straight out of the box If there is a problem or a minor change you want to make, you have no chance
to make it because of no available source code Linux encourages individual adjustments, modifications, and fixes because the source
is always available As a result of the available source code, fixes to problems can take place literally overnight.
Reliable Though this may not be unique to Linux, it is important nonetheless
Linux is very stable as are some of the other operating systems I have known Linux servers to run without needing to be restarted for months at a time (and then only for hardware maintenance) In contrast, some Windows NT servers need to be restarted every day
to ensure their reliability.
Flexible With the vast numbers of programs available for Linux, its uses can
range from a single task as a monitor, to uses as a workstation for calculating advanced mathematical formulas or graphics You can use Linux as an Internet router, firewall, proxy, Web server, or mail server that is as powerful as any on the open market.
Trang 38The Word on Free Software and Open Source
The Free Software Foundation believes, of course, that software should be free Thisincludes the source code for the executable programs When they say free, theymean it
The foundation, which developed the GNU General Public License (GPL), promotessharing of free software (including the source code) The purpose of this is to allowthe programming community to make changes to the code According to the GPL,
no software that claims this license can be distributed without the source code.When source code is included, the programming community can respond to
defects, bugs, and cracks faster A fix for a commercial operating system can take
up to six months to be released, compared to a few days in the Linux world
Just because software is free and the source gets included doesn’t mean that it’s afree-for-all on the program Once a developer releases GPL software, any licensingchanges made to that software must be made with the consent of the author.However, you can freely distribute, modify, and use it Although most softwarereleased with Debian uses the GPL and is free, some software discussed in thisbook and found elsewhere is not free as it is sold commercially However, most soft-ware for Linux is free
The Open Source community differs slightly from the Free Software movement,although both desire to see freely available software The Open Source movement isless concerned with whether anyone makes a profit along the way, but more con-cerned with the distribution of free software Eric Raymond cofounded the OpenSource Software Group out of a concern that businesses weren’t getting the word As aresult of his efforts, some companies have adopted the Open Source philosophy Onesuch company, Cygnus Solutions, produced the GNUPro Developers Kit as an OpenSource product Red Hat acquired this product, which is now called GNUPro ETS Having corporations involved in the development and promotion of Linux helpseveryone Companies bring training, certification, and support to an otherwise hobbyoperating system Without this kind of support, many people (and companies) stayaway from a product to avoid its potential failure of an unknown future As morecompanies get behind a system — for better or worse — it gains more credibility inthe minds of businesses Therefore, having companies involved in the development
of Linux is a good thing
What’s So Special about GNU/Linux?
Stallman’s dream of having an operating system free from commercial purse stringscame true with the completion of the kernel by Torvalds As the community of pro-grammers grew, so did the draw to GNU/Linux The metamorphosis of the operatingsystem grew to gain the attention of the world
Trang 39More and more people started joining the Linux movement by adopting GNU/Linux
as their operating system of choice Many migrated to it looking for a stable
envi-ronment from which to create programs, while others sought something that
wouldn’t crash when performing simple daily tasks like word processing Both
groups of users were pleasantly surprised with GNU/Linux
With the popularity of GNU/Linux increasing, some programmers created special
distributions of the operating systems by adding in their own special programs as
enhancements You can easily obtain some of these systems, while others
encour-age the purchase of their packencour-ages Still others include software at a price, which
dilutes the openness of the source Table 1-3 lists some of the more popular Linux
distributions All can be purchased from store (except Debian) or downloaded from
a site like www.linuxiso.orgwhere all you have to do is burn the distribution
image to a CD for you own copy
Table 1-3 Linux distributions and Web sites
Distribution Web Site
Some of these distributions listed in Table 1-3 were created from other
distribu-tions For instance, Linux-Mandrake uses a Red Hat base while Corel and Storm
Linux both originated with Debian Surprised? Even though some of the distribution
originated from other distributions (like Linux-Mandrake originated from Red Hat),
each one adds something a little different to the mix — a graphical installer, special
configuration tools, or even hardware detection software
Trang 40Understanding the Debian Distribution
One of the oldest distributions of Linux, Debian GNU/Linux has an awesome tion At the heart of this distribution is a faithful community of programmers, alldedicated to advancing free software This is the purest in the sense of non-commercial and most stable flavor of Linux because all base components are com-munity created, community supported, and no-strings-attached free There are over
reputa-500 developers working together from around the world to put out the latest sion Debian is the oldest distribution that does not have corporate stringsattached However, because this distribution is volunteer driven, the releases tend
ver-to be slow This slowness could be considered a drawback, but in my opinion, it’sworth the wait
If you are interested in getting connected to the Debian community, check out one
of the many mailing lists at www.debian.org/MailingLists/subscribe Ifyou are interested in becoming a Debian Developer, subscribe to one of the devel-oper lists and become known Official Developers must be invited so don’t expect
to become one overnight
To date of the known Linux installations, Debian makes up 21 percent compared
to Red Hat at 29 percent (as reported by the Linux Counter at counter.li.org).This is remarkable because no marketing teams, corporate strategies, or distribu-tion channels promote the Debian distribution
How did Debian get its start? In 1993, Ian Murdock attempted to create a tion that combined the Linux kernel with GNU In the process, the concept of pack-ages developed A package is a collection of all the compiled components needed tomake a program work Each package includes information about install location,configuration and any other packages it need to use These packages were orga-nized to allow others to contribute to the distribution Table 1-4 shows the timelinefor this distribution
distribu-Table 1-4 Time Chart for Debian
Release Date Name Contributors