Sams Teach Yourself Unix System Administration in 24 Hours

Dave Taylor

Image  201 West 103rd St., Indianapolis, Indiana, 46290 USA

Sams Teach Yourself Unix System Administration in 24 Hours

International Standard Book Number: 0-672-32398-2

Library of Congress Catalog Card Number: 2001099557

Printed in the United States of America

First Printing: July 2002

05  04  03  02    4  3  2  1

Trademarks

All terms mentioned in this book that are known to be trademarks or 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.

Warning and Disclaimer

Every effort has been made to make this book as complete and as accurate as possible, but no warranty or fitness is implied. The information provided is on an ″as is″ basis. The author and the publisher shall have neither liability nor responsibility to any person or entity with respect to any loss or damages arising from the information contained in this book.

Acquisitions Editor

Kathryn Purdum

Development Editor

Heather Goodell

Managing Editor

Charlotte Clapp

Project Editor

Elizabeth Finney

Production Editor

Seth Kerney

Indexer

Larry Sweazy

Proofreader

Suzanne Thomas

Technical Editors

Dee-Ann LeBlanc

David Ennis

Team Coordinator

Amy Patton

Interior Designer

Gary Adair

Cover Designer

Alan Clements

Page Layout

Stacey Richwine-DeRome

Contents at a Glance

Introduction

Part I Installing Unix

Hour 1 Installing Unix

Part II Introduction to the Filesystem

Hour 2 An Unsung Resource: Unix Documentation

3 Disk Usage

4 File Ownership

Part III User & Package Management

Hour 5 Working with User Accounts

6 Account Management

7 Large File Management & Backups

8 Unix Package Management

Part IV Advanced Filesystem Topics

Hour 9 Fixing Broken Disks

10 Adding Disks to Your System

11 Multiple Boot Configurations

12 Managing Disk Quotas

Part V Process & System Controls

Hour 13 Changing System State

14 Exploring Processes

15 Running Jobs in the Future

16 Managing Your Log Files

Part VI Network Topics

Hour 17 Basic Network Configuration

18 Running Your Own Name Server

19 Running Internet Services

20 Working with E-mail

Part VII Web Server Management & Shell Programming

Hour 21 Shell Scripting: The Administrator’s Swiss Army Knife

22 Power Scripting with awk and Perl

23 Introduction to the Apache Web Server

24 Virtual Hosts with Apache

Index

Contents

Introduction

Part I Installing Unix

Hour 1 Installing Unix

Unix Installation Options

Basic Red Hat Linux Installation

Installation Help Online

Summary

Q&A

Workshop

Quiz

Answers

Part II Introduction to the Filesystem

Hour 2 An Unsung Resource: Unix Documentation

The Philosophy of Digging

apropos: The Administrator’s Secret Weapon

Task 2.1: apropos and the Whatis Database

Exploring the whatis Database

Task 2.2: What’s Inside the whatis Database

Finding Commands

Task 2.3: Which Command Are You Running?

Digging Around in Executable Binaries

Task 2.4: The strings Command

Summary

Q&A

Workshop

Quiz

Answers

Hour 3 Disk Usage

Physical Disks and Partitions

Task 3.1: Exploring Partitions

A Closer Look with du

Task 3.2: Using du to Ascertain Directory Sizes

Simplifying Analysis with sort

Task 3.3: Piping Output to sort

Identifying the Biggest Files

Task 3.4: Finding Big Files

Keeping Track of Users: diskhogs

Task 3.5: This Little Piggy Stayed Home?

Summary

Q&A

Workshop

Quiz

Answers

Hour 4 File Ownership

Starting at the Beginning: Permission Strings

Task 4.1: The Basics of File Permissions

Ownership and /etc/passwd

Task 4.2: Understanding /etc/passwd

Understanding Unix Groups and /etc/group

Task 4.3: Groups and the /etc/group file

Using Groups to Control Access

Task 4.4: Access Control with Groups

Summary

Q&A

Workshop

Questions

Answers

Part III User & Package Management

Hour 5 Working with User Accounts

Understanding the /etc/passwd File

Task 5.1: Exploring /etc/passwd

Password Files in BSD/Mac OS X

Task 5.2: Accounts and the Password File in Darwin

Adding Users and the adduser Script

Task 5.3: Adding Users in a Conventional Unix World

Adding Users in a NetInfo World

Task 5.4: The Darwin Version of adduser

Summary

Q&A

Workshop

Quiz

Answers

Hour 6 Accounts Management

Ways to Suspend User Accounts

Task 6.1: Suspending Users

Deleting User Accounts

Task 6.2: Deleting User Accounts

Linux Account Management Tools

Task 6.3: Linux Admin Tools

Solaris Account Management Tools

Task 6.4: Solaris Account Administration Tools

Password Aging

Task 6.5: Tools for Managing Password Aging

Summary

Q&A

Workshop

Quiz

Answers

Hour 7 Large File Management and Backups

Shrinking Big Files with compress

Task 7.1: Working with compress

The gzip Alternative

Task 7.2: Working with gzip

A Zippy Tour of zip

Task 7.3: Working with zip

Copying Directory Trees with tar

Task 7.4: Working with tar

dump and System Backups

Task 7.5: Incremental Backups

Summary

Q&A

Workshop

Quiz

Answers

Hour 8 Unix Package Management

Red Hat Package Manager and Linux

Task 8.1: Working with RPM

Adding New RPM Packages from the Internet

Task 8.2: Installing New Web-Based RPM Packages

Package Management in Darwin

Task 8.3: Installing and Working with fink

Package Management in Solaris

Task 8.4: Managing Packages in Solaris

Summary

Q&A

Workshop

Quiz

Answers

Part IV Advanced File System Topics

Hour 9 Fixing Broken Disks

Introduction to fsck

Task 9.1: Getting Started with fsck

Fixing Problems with fsck

Task 9.2: Fixing Disk Problems with fsck

Single-User Mode

Task 9.3: Single-User Mode in Darwin

Don’t Panic!

Summary

Q&A

Workshop

Quiz

Answers

Hour 10 Adding Disks to Your System

Formatting Disks with fdisk

Task 10.1: Formatting a Disk with fdisk

Adding a Filesystem with mke2fs

Task 10.2: Making a Filesystem with mke2fs

Mounting the New Disk

Task 10.3: Adding New Drives to Your System

Fine-tuning Your /etc/fstab Configuration File

Task 10.4: Creating the Perfect /etc/fstab File

Summary

Q&A

Workshop

Quiz

Answers

Hour 11 Multiple Boot Configurations

The Theory of Dual-Booting

Task 11.1: Partitioning Disks for Dual Boot

Dual-Boot Configurations with LILO

Task 11.2: Configuring LILO

Dual-Boot Configurations with GRUB

Task 11.3: Configuring GRUB

Other Solutions for Other Unixes

Task 11.4: Learning About Virtual Machines

Summary

Q&A

Workshop

Quiz

Answers

Hour 12 Managing Disk Quotas

Implementing a Disk-Quota Policy

Task 12.1: Implementing Quotas

Quota Nuances on Other Unixes

Task 12.2: Quotas on Other Systems

Creating Your Own Quota System with find

Task 12.3: Disk-Quotas with find

Summary

Q&A

Workshop

Quiz

Answers

Part V Process & System Controls

Hour 13 Changing System State

Configuring and Working with the init Process

Task 13.1: The init Process and Configuration

Enabling Specific Services at Different Run Levels

Task 13.2: Configuring Your System for Run Levels

Shutting Down Your System the Right Way

Task 13.3: Safe Shutdowns and Reboots

Summary

Q&A

Workshop

Quiz

Answers

Hour 14 Exploring Processes

The Secret Life of Process IDs

Task 14.1: Process ID Information

Examining Processes with the ps Command

Task 14.2: Exploring ps

A Typical Sysadmin Task: What’s artsd?

Task 14.3: A Little Unix Detective Work

Process Priorities

Task 14.4: Managing Process Priorities

Zapping Stray Processes

Task 14.5: The kill Command

Summary

Q&A

Workshop

Quiz

Answers

Hour 15 Running Jobs in the Future

Allowing User Access to crontab

Task 15.1: Turning on crontab

Building crontab Files

Task 15.2: Building a crontab File

System cron Jobs in /etc

Task 15.3: Exploring the Administrative cron Jobs

Once in the Future with at

Task 15.4: Working with at

Summary

Q&A

Workshop

Quiz

Answers

Hour 16 Managing Your Log Files

Understanding Log Files

Task 16.1: Rummaging Around in Log Files

Tracking a Hacker

Task 16.2: Tracking Backward

The httpd Log File

Task 16.3: Exploring the httpd Log File

Trimming Log Files with logrotate

Task 16.4: The logrotate Program

Building Your Own Log Rotation Tool

Task 16.5: Rotating Your Own Logs

Q&A

Workshop

Quiz

Answers

Part VI Network Topics

Hour 17 Basic Network Configuration

Hooking Up a Linux Box to the Internet

Task 17.1: Hooking Up a Linux System

Network Configuration on Other Unixes

Task 17.2: Configuring Solaris and Mac OS X

Testing and Evaluating Connectivity

Task 17.3: Evaluating Connectivity

Summary

Q&A

Workshop

Quiz

Answers

Hour 18 Running Your Own Name Server

The Berkeley Internet Name Domain Package

Task 18.1: Exploring BIND and Zone Files

Configuring named

Task 18.2: Configuring the Name Server named

Working with rndc

Task 18.3: Learning rndc

Testing DNS Setups

Task 18.4: Testing with dig and host

Summary

Q&A

Workshop

Quiz

Answers

Hour 19 Running Internet Services

The inetd Super-Daemon

Task 19.1: Understanding and Working with inetd

Managing inetd Security with TCP Wrapper

Task 19.2: Working with TCP Wrapper

Super-inetd: xinetd

Task 19.3: Working with xinetd

An Example: Enabling ftp

Task 19.4: Enabling ftp (and Why You Might Not Want To)

Summary

Q&A

Workshop

Quiz

Answers

Hour 20 Working with E-mail

Testing Mail Connectivity with sendmail

Task 20.1: Using sendmail to Verify Connectivity

Mail Logs and Mail Queues

Task 20.2: Mail Logs and Mail Queues

Creating sendmail Aliases

Task 20.3: Mail Aliases

sendmail Aliases Within Mac OS X

Task 20.4: Mac OS X and sendmail Aliases

Summary

Q&A

Workshop

Quiz

Answers

Part VII Web Server Management & Shell Programming

Hour 21 Shell Scripting: The Administrator’s Swiss Army Knife

The Basics of Shell Scripting

Task 21.1: Basic Shell Scripts

Flow Control

Task 21.2: Conditionals, Looping, and Functions

Some Cool Examples

Task 21.3: Some Example Scripts

Summary

Q&A

Workshop

Quiz

Answers

Hour 22 Power Scripting with awk and Perl

The Elegant awk Language

Task 22.1: An Overview of awk

Basic Perl Programming

Task 22.2: Basic Perl

Advanced Perl Examples

Task 22.3: Advanced Perl Capabilities

Summary

Q&A

Workshop

Quiz

Answers

Hour 23 Introduction to the Apache Web Server

Setting Up Your Web Server

Task 23.1: Bringing Apache to Life

Exploring the httpd.conf File

Task 23.2: The Internals of the httpd.conf File

Testing and Tuning the Configuration

Task 23.3: What Can Apache Do?

Summary

Q&A

Workshop

Quiz

Answers

Hour 24 Virtual Hosts with Apache

Enabling Virtual Hosting in Apache

Task 24.1: Configuring Virtual Hosts

Keeping Your System Secure

Passwords

rlogin

Unnecessary Network Services

Keep Your Operating System Up-To-Date

Join the Computer Emergency Response Team

Other Useful Web Sites

Useful Tools

Summary

And So Our 24 Hours Come to an End…

Index

About the Author

Dave Taylor is a popular writer, teacher, and speaker focused on business and technology issues. The founder of The Internet Mall and iTrack.com, he has been involved with Unix and the Internet since 1980, having created the popular Elm Mail System and Embot mail autoresponder. A prolific author, his most recent books include Learning Unix for Mac OS X, Sams Teach Yourself Unix in 24 Hours, Creating Cool HTML 4.0 Web Pages, Dynamic HTML Weekend Crash Course, and The e*Auction Insider.

Previous positions include research scientist at HP Laboratories and senior reviews editor of SunWorld magazine. He has contributed software to the official 4.4 release of Berkeley Unix (BSD), and his programs are found in all versions of Linux and other popular Unix variants.

Dave has a bachelor’s degree in computer science, a master’s degree in educational computing, and is working on an MBA. He teaches business and technology-related courses both in the physical world through the University of Colorado at Boulder, and online with the University of Phoenix. His e-mail address has been the same for over 15 years: [email protected].

When not typing madly on the keyboard of his Mac, Dave’s either playing with his wife Linda and two wonderful kids, Ashley and Gareth, or out bicycling around Boulder.

Dedication

To the three shining stars in my firmament…

Acknowledgments

This project has been quite complex, juggling multiple operating systems, installations, and configurations. Fortunately I was lucky to have a group of Unix and system experts helping me along. As a result, I’d like to thank Andy Lester for his help with my oft-inefficient Perl coding, Westley Annis for helping clarify the mysterious world of DNS, and Max Horn for his helpful corrections on the Darwin Fink project. Gideon Shaanan, Richard Blum, Cedric Higgins, Tim Hicks, Dave Ennis, Brian Bilbrey, Eugene Lee, and Tyler and Rima Regas were all also helpful with their comments and assistance.

I can’t say enough wonderful things about Dee-Ann LeBlanc and David Ennis, the tech editors for this book. They’re master nit-pickers, but ultimately any errors you encounter are probably mine. (But please, file an errata report so we can fix it in the next edition!) In particular, Dee-Ann was always available for late night IM sessions as my sanity started to slip. Thanks! I was also blessed to work with the same Sams team I’ve used on other books, notably Katie Purdum, Heather Goodell, and Elizabeth Finney. They’re all ably led by my longtime friend Mark Taber.

Finally, I couldn’t have done this book without the indulgence of my wife and kids. Thanks oodles to Linda, Ashley, and Gareth. It might not be entirely clear why Daddy’s always on the computer, but there is an end-product occasionally!

We Want to Hear from You!

As the reader of this book, you are our most important critic and commentator. We value your opinion and want to know what we’re doing right, what we could do better, what areas you’d like to see us publish in, and any other words of wisdom you’re willing to pass our way.

You can e-mail or write me directly to let me know what you did or didn’t like about this book—as well as what we can do to make our books better.

Please note that I cannot help you with technical problems related to the topic of this book, and that due to the high volume of mail I receive, I might not be able to reply to every message.

When you write, please be sure to include this book’s title and author as well as your name, e-mail address, and phone number. I will carefully review your comments and share them with the author and editors who worked on the book.

E-mail:        [email protected]

Mail:           Mark Taber
                  Associate Publisher
                  Sams Publishing
                  201 West 103rd Street
                  Indianapolis, IN 46290 USA

Reader Services

For more information about this book or another Sams title, visit our Web site at www.samspublishing.com. Type the ISBN (excluding hyphens) or the title of a book in the Search field to find the page you’re looking for.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.223.195.97