Lemasters, Darlena Murray, Julie Searls, Sossity Smith Overview iii Introduction xxiii Part I Introduction and Installation of Linux 1 Introduction to Red Hat Linux and UNIX 3 2 Installa
Trang 1Publisher Dean Miller
Executive Editor Jeff Koch
Managing Editor Sarah Kearns
Senior Indexer Ginny Bess
Director of Software
and User Services Cheryl Willoughby
Brand Director Alan Bower
This book is dedicated to TM3 and
Associates Thanks, guys
retrieval system, or transmitted by any
means, electronic, mechanical,
photocopying, recording, or otherwise,
without written permission from the
publisher No patent liability is assumed with respect to the use of the
information contained herein Although everyprecaution has been taken in
Trang 2the preparation of this book, the publisher and author assume no responsibility
for errors or omissions Neither is any liabilityassumed for damages
resulting from the use of the information
contained herein For information,
address Sams Publishing, 201 W 103rd St., Indianapolis, IN 46290
International Standard Book Number: 31173-9
0-672-Library of Congress Catalog Card Number: 97-68008
01 00 99 98 4 3 2 1
Interpretation of the printing code: The
rightmost double-digit number is
the year of the book’s printing; the rightmost single digit, the number of the
book’s printing For example, a printing code
of 98-1 shows that the first
printing of the book occurred in 1998
Composed in AGaramond and MCPdigital by Macmillan Computer
service marks have been appropriately
capitalized Sams Publishing cannot
attest to the accuracy of this information Use of a term in this book should
not be regarded as affecting the validity of any trademark or service mark
Trang 3Red Hat Linux is a trademark of Red Hat Software.
Carolyn Linn, Kate Talbot,
Michael Brumitt, Chuck
Hutchinson, Nancy Albright
Indexer
Cheryl Jackson
Technical Reviewers
Bill Ball, Sriranga R.
Veeraraghavan, Robin Burk
Trang 4Bryan Flores, Julie Geeting,
Kay Hoskin, Christy M.
Lemasters, Darlena Murray,
Julie Searls, Sossity Smith
Overview iii
Introduction xxiii
Part I Introduction and Installation of Linux
1 Introduction to Red Hat Linux and UNIX 3
2 Installation of Your Red Hat System 11
3 LILO 27
Part II Configuring Other Servers
4 System Startup and Shutdown 37
5 Configuring and Building Kernels 53
6 Common Desktop Environment 75
7 SMTP and POP 97
8 FTP 131
9 Apache Server 153
10 X Window 175
Part III Hardware Connectivity and Devices
11 Filesystems, Disks, and Other Devices
195
12 Printing with Linux 229
13 TCP/IP Network Management 243
Trang 5Part IV System Administration and
Management
14 Getting Started with Red Hat Linux 299
15 Essential System Administration 319
16 Advanced System Administration 341
17 GNU Project Utilities 351
18 Backup and Restore 373
Part V Dealing with Others
19 User Accounts and Logins 383
Part VI Automation, Programming, and
Modifying Source Code
Part VII Appendixes
A The Linux Documentation Project 607
B Top 50 Linux Commands and Utilities 611
C The Linux Documentation Project Copyright
Trang 6Part I Introduction and Installation of Linux
1 Introduction to Red Hat Linux and
UNIX 3
Advantages of
Linux 5
Copyright and
Warranty 7
Where to Get Red Hat
Linux 7System
Requirements 7
2 Installation of Your Red Hat System
Be Prepared, Be Very
Prepared! 12
Installing Red Hat
Linux 13
Creating the Boot and Supplemental
Disks 13
Installing Without Using a Boot
Floppy 14
Trang 7Virtual
Consoles
14
Dialog Boxes
14
Step-by-Step Installation
15
Booting
15
The Installation Program
15 Selecting an Installation Method 17
CD-ROM Installation
17
The Red Hat Package Manager
25 RPM Usage
25
Summary
26
3 LILO 27 Installing and Configuring LILO 28
Configuring LILO
29
Trang 8Using LOADLIN.EXE to Boot
Linux 33
How to Uninstall
LILO 33
Summary 33
Part II Configuring Other Servers
4 System Startup and Shutdown 37
The Boot
Process 38
The Initialization Process and Startup
halt and reboot
45
When the System
Crashes 46
Trang 9Running as
Root
47
Creating a Boot Disk
47 Your File Toolbox
48
Red Hat to the Rescue! When the System Won’t Boot 49
For More Information
50
Summary
51
5 Configuring and Building Kernels 53 An Introduction to the Linux Kernel 54
Acquiring the Source Tree 55
Patching the Source Tree 57
Modules
57
Configuring the Linux Kernel 58
Starting the Configuration
58
Stepping Through the Menus 59
Trang 10Final Notes About
Configuration 70
Building the
Kernel 70
Installing the
Kernel 72
Recovering from Faulty
Kernels 73Summary 73
6 Common Desktop Environment 75
Installation 76
Getting Started with the
CDE 77Logging in to the
CDE 77
The Desktop
Environment 78
Customizing Your
Session 81
The Style
Manager 81
The Front
Panel 82
Trang 11Advanced
Customizations
84
Creating New Actions
87
Creating and Modifying Subpanels 90
Restoring a Session When Something Goes Wrong 91
Executing Applications and Commands at Login 92
Executing Commands at Logout 93
The Help Viewer
93
Using the Help Viewer
93
Context-Sensitive Help
93 vii Adding Help to Icons
94 Help Topics
95
Summary
96
7 SMTP and POP 97
Trang 12SMTP
98
Internet Mail Protocols
99
The Domain Name System and E-mail 100
sendmail’s Jobs
104
sendmail’s Auxiliary Files 105
The Aliases File
105
Setting Up sendmail 106
sendmail.cf—The Configuration File 109
Testing sendmail and sendmail.cf 123
POP
124
Configuring a POP Server
125 Managing Bulletins
128
Summary
129
8 FTP 131
Trang 13Getting and Installing the FTP
Server 132
How the FTP Server Works
133 Configuring Your FTP Server 134
Controlling Access—The /etc/ftpaccess File 135
Converting Files On-the-Fly—The /etc/ftpconversions File 147 Configuring Host Access—The /etc/ftphosts File 149
The FTP Log File—/var/log/xferlog 150
FTP Administrative Tools
151 ftpshut
151
ftpwho
151
ftpcount
152
Summary
152
9 Apache Server 153 Server Installation
154
Runtime Server Configuration Settings 155
Trang 14Editing httpd.conf
155Editing srm.conf
158
Editing access.conf
158Configuring an inetd
Server 159
Configuring inetd
160
Running the Web Server for the First
Time 162
Starting a Standalone
Server 163Starting an inetd
Server 163
Script 164
The stop
Script 164
Trang 15The restart
Script 164
Configuration File
Listings 165
Summary 173
10 X Window 175
Setting Up Your XFree86
System 176The XF86Config
File 176
Using Xconfigurator
177
Examining the XF86Config
File 177
The File
Pathnames 178
The Keyboard
Section 179
The Pointer
Section 179
The Server
Section 181
Trang 16Setting Up Video
Modes
182 International Keyboard Layout for XFree86 184
The xinitrc File
185
The Personal X Resource File 186
Using xdm
187
Configuration of the Window Manager 188
Compiling Programs That Use X 188
Some Common Problems
189
Compiling Sources for XFree86 190
Summary
191
Part III Hardware Connectivity and Devices 11 Filesystems, Disks, and Other Devices 195 Block Devices
197
Filesystems
197
Trang 17The mount
Command
198
Setting Up Filesystems
202
The Red Hat File System Manager 202
Editing /etc/fstab Manually 203
Creating New Filesystems
204
Repairing Filesystems
207
Hardware
209
Hard Disks
209
Floppy Disks
211
CD-ROM Drives
212
Loopback Devices
213
Other Block Devices
215
Trang 18Character
Devices
217
Parallel Ports
217
Tape Drives
218
Terminals
220
Serial Communications
222
Generic SCSI Devices
223
CD-ROM Recorders
224
Testing CD Images
224
Other Character Devices
224 Summary
228
12 Printing with Linux 229 Printer Devices
230
Trang 19How Do I
Print?
231
The RHS Linux Print System Manager 232
Remote and LAN Printers
232 Local Printers
233
Linux Printing Commands
234
Simple Formatting
235
Other Helpful Printer Programs and Filters 236
APSfilter
236
BubbleTools
236
magicfilter
236
PostScript Printers
237
Enhanced Printer Spooler 237
Trang 20System
Accounting
237
Some Program Tips
237
emacs
237
Applixware for Linux
238 Other Helpful Programs
239
xv
239
pbm Utilities
240
Ghostview
240
For More Information
240
Summary
241
13 TCP/IP Network Management 243 An Introduction to Networking
244 What Is an IP Number?
244
Trang 21A TCP/IP
Primer
244
Subnetworking
246
Determining the Broadcast Address 247
The Next Generation of IP, IPv6 247
Getting a New IP Address
248 Contents Red Hat Linux, Second Edition UNLEASHED x The Network Card Solution
249 Stock Network Configuration
250 Using ifconfig
254 Using route
256
The Domain Name Service
258 Before DNS—The /etc/hosts File 258
Trang 22Configuring the DNS Client: /etc/resolv.conf 259
The Software of
DNS 259
Configuring DNS
Servers 261
The Network Information
Service 269
A Brief
History 269
Understanding
NIS 270
Configuring a Master NIS
Server 271
Configuring an NIS
client 274Configuring an NIS Secondary
Server 276
The Network File
System 280
Installing
NFS 281
Starting and Stopping the NFS
daemons 282
Configuring
NFS 282
Trang 23Connecting to the Net with
PPP 288
Simple
Client 289
On-Demand
Dialing 293
Summary 294
Part IV System Administration and
Management
14 Getting Started with Red Hat Linux 299
Organization 300
/bin and /sbin
300
/etc
301
/home
303
/mnt
303
/tmp and /var
303
Trang 24304
RPM 305
Major Modes and Common
Options 305
Installing
Packages 306
Upgrading
Packages 309
Uninstalling
Packages 309
Querying
Packages 310
Verifying
Packages 313
Introduction to
glint 314
Summary 317
xi
15 Essential System Administration 319
Handling the All-Powerful Root
Account 320
Maintaining the System—Implementing
Changes 321
Trang 25Planning
Processes 322
Creating a Back-Out
Plan 322Making Changes in Small
Increments 322
Developing a Test
Plan 323
Communicating Effectively and in a Timely Manner 323
Getting
Help 328
Man
Pages 329
E-mail 331
Red Hat Mailing Lists and
Newsgroups 332
Other
Newsgroups 334
Problem Solving—
Logs 335
login.access 336
Other Files That Deny or Allow Users or Hosts 337
Trang 26syslog 337
Wine—Accessing Windows Applications
Under Linux 338
New Releases of
Wine 339
Where to Get Copies of
Wine 339
Installation and Problems Running Windows Applications 339
Summary 340
16 Advanced System Administration 341
Basic Performance
Analysis 342
Determining CPU
Usage 342
top 344
How Much Swap Is
Enough? 347
Momma Always Said to Be
Nice! 348
Summary 349
17 GNU Project Utilities 351
File
Utilities 352
Trang 27Listing Directory
Contents 352
File
Operations 354
Changing File
Attributes 355
Disk
Usage 358
Find
Utilities 358
locate 358
find 359
xargs 361
Shell
Utilities 363
Who’s Who in
GNU 363
The id
Commands 364
Contents
Red Hat Linux, Second Edition
UNLEASHED
Trang 28The head and tail
Commands 366
The split
Command 368
Counting
Words 369
Summary 371
18 Backup and Restore 373
Qualities of a Good
Backup 374
Selecting a Backup
Medium 375
Selecting a Backup
Tool 375
Backup
Strategy 376
Trang 29Performing Backups with tar and cpio
377
Restoring
Files 378
What Is on the
Tape? 378
Summary 379
Part V Dealing with Others
19 User Accounts and Logins 383
Adding
Users 384
Editing etc/passwd
384Editing /etc/group
387Creating a Home Directory and Copying Files
to the New
Home 389
Changing Ownerships and
Permissions 389
Setting the
Password 389
Changing User
Properties 390
Temporarily Disabling a
User 390
Trang 30The Login and How to Become a Specific User 390
The su
Command 391
Searching 391
who 392
finger 392
Summary 393
Tools 397
Knowledge
Gathering 399
Danger, Will Robins,
Danger! 400
xiii
Preparing for the
Worst 400
Trang 31suid and sgid
401
File and Directory
Permissions 402
Files 402
Directories 403
How suid and sgid Fit into This
Sites 408
Summary 409
21 Shell Programming 411
Creating and Executing a Shell
Program 412
Variables 413
Assigning a Value to a
Variable 414Accessing Variable
Values 414
Trang 32Positional
Parameters 415
Built-in
Variables 416
Special
Characters 416
Double
Quotes 417
Single
Quote 418
Backslash 418
Backtick 419
Comparison of
Expressions 419
pdksh and bash
419
tcsh 423
Iteration
Statements 426
The for
Statement 426
Trang 33The while
Statement 427
The until
Statement 428
The repeat Statement
(tcsh) 429The select Statement
(pdksh) 429The shift
Statement 429
Conditional
Statements 430
The if
Statement 430
The case
Statement 431
Miscellaneous
Statements 433
The break
Statement 433
The exit
Statement 433
Functions 434
Trang 34Summary 434
Contents
Red Hat Linux, Second Edition
UNLEASHED
xiv
Part VI Automation, Programming, and
Modifying Source Code
Analysis of the
Implementation 439
Tips for Improving Automation
Technique 441
Continuing
Education 441
Good
Engineering 442
Shell
Scripts 442
chstr 442
WWW
Retrieval 443
Trang 35Conclusions on Shell
Programming 445cron and at
Jobs 445
cron and find—Exploring Disk
Usage 445
at: Scheduling Future
Events 446Other Mechanisms: Expect, Perl, and
More 447
Comparing
Technologies 447
Expect 447
Perl 449
Other
Tools 449
Internal
Scripts 452
Concluding Challenge for an Automater—
Explaining Value 452
Summary 453
23 C and C++ Programming 455
Introduction to
C 456
Trang 36Statement
Controls 465
Functions 468
Creating a Simple
Program 470
Building Large
Applications 472
Debugging
Tools 473
Introduction to C+
+ 474
Programming in C++: Basic
Concepts 474
File
Naming 475
Differences Between C and C+
+ 475
Trang 37Scope of Reference in C and C+
GNU C/C++ Compiler Command-Line
Switches 484
Additional
Resources 485
Summary 485
24 Perl Programming 487
A Simple Perl
Program 488
Perl Variables and Data
Structures 489Conditional Statements: if/else
489
Looping 490
for 490
foreach 490
while 491
Trang 38until 491
Regular
Expressions 491
Access to the
Shell 492
Command-Line
Mode 492
Automation Using
Perl 493
Moving
Files 493
Purging
Logs 495
Posting to
Usenet 496
For More
Information 496
Summary 497
25 tcl and tk Programming 499
tcl
Basics 500
Trang 39Interactive Use of tcl
500Noninteractive Use of tcl
501
The tcl
Language 502
Command
Structure 502
Comments 502
Datatypes 502
Variables 503
Manipulating String
Values 506Manipulating Numeric
Values 507Quoting and
Substitution 509
Flow Control—if and
switch 511Loops 512
File I/O and File
Info 514
Procedures 516
Trang 40The tk
Toolkit 517
Creating
Widgets 518
Widget
Options 519
A tcl/tk Widget Programming
Example 520
A tcl/tk Interface to
xsetroot 522Summary 527
26 Motif Programming 529
What Is
Motif? 530
Where Do I Get
Motif? 531
What Version of Motif Should I
Use? 531