-->

Table of Contents

Introduction

I don't know how many times I have been asked what Red Hat is. When I say that it is a distribution of Linux, people tend to know what I am talking about. (At least the people I hang around with do!) The follow-up question is usually something like, "Okay, if it is a distribution of Linux, why should I use it, and not Linux itself?" This introduction should start to answer that question. Red Hat also answers the question on its Web page (http://www.redhat.com), which is summarized in this introduction.

Linux is a full-fledged operating system. It provides full multitasking in a multiuser environment. It gives a high quality of software for a cost far lower than other commercial versions of UNIX. Red Hat has opted to take Linux a step further.

Red Hat Software is a computer software development company that sells products and provides services related to Linux. Red Hat's mission is to "provide professional tools to computing professionals." Red Hat provides these professional tools by doing the following:

Red Hat's customer-oriented business focus forces it to recognize that the primary benefits of the Linux OS are not any of the particular advanced and reliable features for which it is famous. The primary benefit is the availability of complete source code and its "freely distributable" GPL license. This gives any user the ability to modify the technology to his or her needs and to contribute to the on-going development of the technology to the benefit of all the users, providing benefits such as security and reliability that commercially restricted, binary-only operating systems simply cannot match.

Linux, like UNIX itself, is a very modular operating system. The skills required to select, compile, link, and install the various components that are needed for a complete Linux OS are beyond the experience of most people who might want to use Linux. The various Linux distributions go a long way towards solving this for the average Linux user, but most don't address the problem of how to upgrade your Linux system once you get it successfully installed. Most users found it easier to delete their whole Linux system and reinstall from scratch when they needed to upgrade.

Page 24

The Red Hat distribution makes Linux easier to install and maintain by providing the user with advanced package management, graphical (point and click!) system installation and control, and system administration tools.

Probably the best feature of Linux, the GNU utilities in general, and Red Hat Linux in particular is that they are distributable under the terms of the GNU Public License (GPL). This feature has allowed research institutions, universities, commercial enterprises, and hackers to develop and use Red Hat Linux and related technologies cooperatively without fear that their work would someday be controlled and restricted by a commercial vendor.

The huge development effort and wide distribution of the Linux OS will ensure that it takes its place as a real, viable, and significant alternative to commercially restricted operating systems. The open development model, availability of source, and lack of license restrictions are features of the Linux OS that commercial OS developers simply cannot offer. Software development groups that need this model include groups from government-affiliated research organizations, to academic research and teaching projects, to commercial software application developers.

The recent rapid increase in new applications becoming available for Linux and the rapidly growing user base of these technologies are causing even the largest computer industry organizations to take Linux seriously. Even Datapro (a McGraw-Hill Company) in its recent 1996 survey of the UNIX industry concluded that, "Programmers are taking a hard look at the viability of Linux on production platforms now that Linux costs less than Microsoft and has the added benefits of UNIX, such as great performance, inherent power tool sets, and communication capabilities."

It was said once that over half of the Web servers used around the world are run on Red Hat Linux. Although I cannot deny or substantiate this claim, it does show how rapidly Red Hat is taking on the commercial operating systems and succeeding. With the purchase of this book, you are taking the first step necessary to take back control of your computing system from the corporate giants. There is an exciting future for Linux, and we are glad that you are now a part of it!

Conventions Used in This Book

The following conventions are used in this book:

Page 25

Page 3

Overview

Introductionxxiii
Part I Introduction and Installation of Linux
  1. Introduction to Red Hat Linux and UNIX3
  2. Installation of Your Red Hat System11
  3. LILO 27
Part II Configuring Other Servers
  1. System Startup and Shutdown 37
  2. Configuring and Building Kernels 53
  3. Common Desktop Environment 75
  4. SMTP and POP 97
  5. FTP 131
  6. Apache Server 153
  7. X Window 175
Part III Hardware Connectivity and Devices
  1. Filesystems, Disks, and Other Devices 195
  2. Printing with Linux 229
  3. TCP/IP Network Management 243
Part IV System Administration and Management
  1. Getting Started with Red Hat Linux 299
  2. Essential System Administration 319
  3. Advanced System Administration 341
  4. GNU Project Utilities 351
  5. Backup and Restore 373
Part V Dealing with Others
  1. User Accounts and Logins 383
  2. System Security 395
  3. Shell Programming 411

Page 4

Part VI Automation, Programming, and Modifying Source Code
  1. Automating Tasks 437
  2. C and C++ Programming 455
  3. Perl Programming 487
  4. tcl and tk Programming 499
  5. Motif Programming 529
  6. gawk Programming 545
  7. Network Programming 583
Part VII Appendixes
    A The Linux Documentation Project 607
    B Top 50 Linux Commands and Utilities 611
    C The Linux Documentation Project Copyright License 629
    D Glossary 633
    E What's on the CD-ROM 653
    Index 655

Page 26

Contents

Introductionxxiii

Part 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 7
System Requirements 7
System Requirements—Intel 8
System Requirements—SPARC 8
System Requirements—Alpha 8
Summary 9
  1. 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
Virtual 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
  1. LILO27
Installing and Configuring LILO 28
Configuring LILO 29
Using LOADLIN.EXE to Boot Linux 33
How to Uninstall LILO 33
Summary 33
Part II Configuring Other Servers
  1. System Startup and Shutdown 37
The Boot Process 38 The Initialization Process and Startup Scripts 38 init and /etc/inittab 39
/etc/inittab and System States 40

Page 6

tksysv and Managing Your Services 43
Shutting Down the Linux System 44
shutdown 44
halt and reboot 45
When the System Crashes 46
Running 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
  1. 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
Final Notes About Configuration 70
Building the Kernel 70
Installing the Kernel 72
Recovering from Faulty Kernels 73
Summary 73
  1. Common Desktop Environment 75
Installation 76
Getting Started with the CDE 77
Logging in to the CDE 77
The Desktop Environment 78
Customizing Your Session 81
The Style Manager 81
The Front Panel 82
Advanced 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

Page 7

Adding Help to Icons 94
Help Topics 95
Summary 96
  1. SMTP and POP97
SMTP 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
  1. FTP131
Getting 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
  1. Apache Server 153
Server Installation 154
Runtime Server Configuration Settings 155
Editing httpd.conf 155
Editing srm.conf 158
Editing access.conf 158
Configuring an inetd Server 159
Configuring inetd 160
Running the Web Server for the First Time 162
Starting a Standalone Server 163
Starting an inetd Server 163

Page 8

Starting and Stopping the Server 163
The start Script 164
The stop Script 164
The restart Script 164
Configuration File Listings 165
Summary 173
  1. X Window 175
Setting Up Your XFree86 System 176
The 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
Setting 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
  1. Filesystems, Disks, and Other Devices 195
Block Devices 197
Filesystems 197
The 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

Page 9

Character 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
  1. Printing with Linux 229
Printer Devices 230
How 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
System 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
  1. TCP/IP Network Management243
An Introduction to Networking 244
What Is an IP Number? 244
A TCP/IP Primer 244
Subnetworking 246
Determining the Broadcast Address 247
The Next Generation of IP, IPv6 247
Getting a New IP Address 248

Page 10

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
Configuring 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 274
Configuring an NIS Secondary Server 276
The Network File System 280
Installing NFS 281
Starting and Stopping the NFS daemons 282
Configuring NFS 282
Connecting to the Net with PPP 288
Simple Client 289
On-Demand Dialing 293
Summary 294
Part IV System Administration and Management
  1. Getting Started with Red Hat Linux 299
Organization 300
/bin and /sbin 300
/etc 301
/home 303
/mnt 303
/tmp and /var 303
/usr 304
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

Page 11

  1. Essential System Administration 319
Handling the All-Powerful Root Account 320
Maintaining the System—Implementing Changes 321
Planning Processes 322
Creating a Back-Out Plan 322
Making 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
syslog 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
  1. 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
  1. GNU Project Utilities 351
File Utilities 352
Listing 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

Page 12

Checking What System You're Running 365
Environment Variables and Shell Functions 365
Text Utilities 366
The head and tail Commands 366
The split Command 368
Counting Words 369
Summary 371
  1. Backup and Restore 373
Qualities of a Good Backup 374
Selecting a Backup Medium 375
Selecting a Backup Tool 375
Backup Strategy 376
Performing Backups with tar and cpio 377
Restoring Files 378
What Is on the Tape? 378
Summary 379
Part V Dealing with Others
  1. User Accounts and Logins 383
Adding Users 384
Editing etc/passwd 384
Editing /etc/group 387
Creating 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
The Login and How to Become a Specific User 390
The su Command 391
Searching 391
who 392
finger 392
Summary 393
  1. System Security 395
Thinking About Security—An Audit 396
A Plan 396
Tools 397
Knowledge Gathering 399
Danger, Will Robins, Danger! 400

Page 13

Preparing for the Worst 400
suid and sgid 401
File and Directory Permissions 402
Files 402
Directories 403
How suid and sgid Fit into This Picture 406
The Default Mode for a File or Directory 407
Passwords—A Second Look 407
Related WWW Sites 408
Summary 409
  1. Shell Programming 411
Creating and Executing a Shell Program 412
Variables 413
Assigning a Value to a Variable 414
Accessing Variable Values 414
Positional 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
The while Statement 427
The until Statement 428
The repeat Statement (tcsh) 429
The select Statement (pdksh) 429
The 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
Summary 434

Page 14

Part VI Automation, Programming, and Modifying Source Code
  1. Automating Tasks 437
First Example—Automating Data Entry 438
Problem and Solution 438
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
Conclusions on Shell Programming 445
cron and at Jobs 445
cron and find—Exploring Disk Usage 445
at: Scheduling Future Events 446
Other 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
  1. C and C++ Programming 455
Introduction to C 456
Programming in C: Basic Concepts 457
Creating, Compiling, and Executing Your First Program 459
An Overview of the C Language 460
Expressions 463
Statement 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
Scope of Reference in C and C++ 476
Overloading Functions and Operators in C++ 478

Page 15

Functions Within C++ Data Structures 480
Classes in C++ 481
GNU C/C++ Compiler Command-Line Switches 484
Additional Resources 485
Summary 485
  1. Perl Programming 487
A Simple Perl Program 488
Perl Variables and Data Structures 489
Conditional Statements: if/else 489
Looping 490
for 490
foreach 490
while 491
until 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
  1. tcl and tk Programming 499
tcl Basics 500
Interactive Use of tcl 500
Noninteractive Use of tcl 501
The tcl Language 502
Command Structure 502
Comments 502
Datatypes 502
Variables 503
Manipulating String Values 506
Manipulating Numeric Values 507
Quoting and Substitution 509
Flow Control—if and switch 511
Loops 512
File I/O and File Info 514
Procedures 516
The tk Toolkit 517

Page 16

Introduction to Widgets 517
Creating Widgets 518
Widget Options 519
A tcl/tk Widget Programming Example 520
A tcl/tk Interface to xsetroot 522
Summary 527
  1. Motif Programming 529
What Is Motif? 530
Where Do I Get Motif? 531
What Version of Motif Should I Use? 531
Red Hat Motif Installation 532
motif-devel-2.0.1-1.i386.rpm 532
motif-2.0.1-1.i386.rpm 533
motif-mwm-2.0.1-1.i386.rpm 533
motif-demosrc-2.0.1-1.i386.rpm 533
motif-demos-2.0.1-1.i386.rpm 534
A Simple Example of Motif Programming Concepts 534
Widgets and Event-Driven Programming 535
The Simple Motif Program 535
How the Program Works 538
Sample Program Resources 539
Shared and Static Libraries 540
The UIL Compiler 541
Tutorials and Examples 541
Using imake and xmkmf 541
LessTif—An Alternative Motif Clone 542
For More Information 543
Summary 544
  1. gawk Programming 545
Applications 546
Features 547
awk Fundamentals 547
Using awk from the Command Line 547
Patterns and Actions 549
Handling Input 553
Coding Your Program 554
Actions 555
Variables 555
Strings 558
Arrays 562

Page 17

Built-in Numeric Functions 564
Arithmetic Operators 565
Conditional Flow 565
Looping 567
Advanced Input and Output 569
Input 569
Output 571
Functions 574
Function Definition 575
Function Parameters 576
The return Statement (Explicit Return) 577
Writing Reports 577
Complex Reports 578
Extracting Data 578
Commands On-the-Fly 579
One Last Built-in Function: system 580
Summary 581
  1. Network Programming 583
Networking Concepts 584
Building Network Addresses 585
Network Services 587
Sockets 588
Protocols and Socket Types 588
Making a Connection 590
A TCP Client Example 590
A TCP Server Example 591
A UDP Example 593
Blocking Versus Nonblocking Descriptors 596
I/O Multiplexing with UDP 597
I/O Multiplexing with TCP 600
Advanced Topics 601
Summary 602
Part VII Appendixes
    A The Linux Documentation Project 607
Overview 608
Getting Involved 608
Current Projects 608
Glossary and Global Index 609
Documentation Conventions 609

Page 18

    B Top 50 Linux Commands and Utilities611
General Guidelines 612
The List 612
. 613
& 613
adduser 613
alias 613
apropos <parameter> 613
banner 614
bg 614
bind 614
cat 615
cd 615
chgrp 616
chmod 616
chown 617
chroot 617
cp 617
dd 617
env 618
fc 618
fg 618
file 618
find 619
grep 619
groff 619
gzip 620
halt 620
hostname 620
kill 620
less 620
login 620
logout 620
lpc 621
lpd 621
lpq 621
lpr 621
ls 621
make 622
man 622
mesg 622
mkdir 622

Page 19

mkefs 623
mkfs 623
mkswap 623
more 623
mount 623
mv 623
netstat 624
passwd 624
ps 624
pwd 625
rm 625
rmdir 625
set 625
shutdown 625
su 625
swapoff 626
swapon 626
tail 626
talk 626
tar 626
umount 626
unalias 626
unzip 627
wall 627
who 627
xhost + 627
xmkmf 627
xset 628
zip 628
Summary 628
    C The Linux Documentation Project Copyright License 629
Copyright License 630
Publishing LDP Manuals 630
    D Glossary 633
    E What's on the CD-ROM 653
About the Software 654
Index655

Page 20

Table of Contents