Siêu thị PDFTải ngay đi em, trời tối mất

Thư viện tri thức trực tuyến

Kho tài liệu với 50,000+ tài liệu học thuật

© 2023 Siêu thị PDF - Kho tài liệu học thuật hàng đầu Việt Nam

McGraw Hill Osborne Media Ubuntu Server Administration Nov 2008
PREMIUM
Số trang
593
Kích thước
11.6 MB
Định dạng
PDF
Lượt xem
765

McGraw Hill Osborne Media Ubuntu Server Administration Nov 2008

Nội dung xem thử

Mô tả chi tiết

Ubuntu®

Server

Administration

MICHAEL JANG

New York Chicago San Francisco

Lisbon London Madrid Mexico City Milan

New Delhi San Juan Seoul Singapore Sydney Toronto

Copyright © 2009 by The McGraw-Hill Companies. All rights reserved. Except as permitted under the United States Copyright Act of

1976, no part of this publication may be reproduced or distributed in any form or by any means, or stored in a database or retrieval

system, without the prior written permission of the publisher.

ISBN: 978-0-07-164370-2

MHID: 0-07-164370-2

The material in this eBook also appears in the print version of this title: ISBN: 978-0-07-159892-7, MHID: 0-07-159892-8.

All trademarks are trademarks of their respective owners. Rather than put a trademark symbol after every occurrence of a trademarked

name, we use names in an editorial fashion only, and to the benefit of the trademark owner, with no intention of infringement of the

trademark. Where such designations appear in this book, they have been printed with initial caps.

McGraw-Hill eBooks are available at special quantity discounts to use as premiums and sales promotions, or for use in corporate

training programs. To contact a representative please visit the Contact Us page at www.mhprofessional.com.

Information has been obtained by McGraw-Hill from sources believed to be reliable. However, because of the possibility of human or

mechanical error by our sources, McGraw-Hill, or others, McGraw-Hill does not guarantee the accuracy, adequacy, or completeness of

any information and is not responsible for any errors or omissions or the results obtained from the use of such information.

TERMS OF USE

This is a copyrighted work and The McGraw-Hill Companies, Inc. (“McGraw-Hill”) and its licensors reserve all rights in and to the work.

Use of this work is subject to these terms. Except as permitted under the Copyright Act of 1976 and the right to store and retrieve one

copy of the work, you may not decompile, disassemble, reverse engineer, reproduce, modify, create derivative works based upon, trans￾mit, distribute, disseminate, sell, publish or sublicense the work or any part of it without McGraw-Hill’s prior consent. You may use the

work for your own noncommercial and personal use; any other use of the work is strictly prohibited. Your right to use the work may be

terminated if you fail to comply with these terms.

THE WORK IS PROVIDED “AS IS.” McGRAW-HILL AND ITS LICENSORS MAKE NO GUARANTEES OR WARRANTIES AS

TO THE ACCURACY, ADEQUACY OR COMPLETENESS OF OR RESULTS TO BE OBTAINED FROM USING THE WORK,

INCLUDING ANY INFORMATION THAT CAN BE ACCESSED THROUGH THE WORK VIA HYPERLINK OR OTHERWISE,

AND EXPRESSLY DISCLAIM ANY WARRANTY, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO IMPLIED

WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. McGraw-Hill and its licensors do not

warrant or guarantee that the functions contained in the work will meet your requirements or that its operation will be uninterrupted or

error free. Neither McGraw-Hill nor its licensors shall be liable to you or anyone else for any inaccuracy, error or omission, regardless

of cause, in the work or for any damages resulting therefrom. McGraw-Hill has no responsibility for the content of any information

accessed through the work. Under no circumstances shall McGraw-Hill and/or its licensors be liable for any indirect, incidental, special,

punitive, consequential or similar damages that result from the use of or inability to use the work, even if any of them has been advised

of the possibility of such damages. This limitation of liability shall apply to any claim or cause whatsoever whether such claim or cause

arises in contract, tort or otherwise.

Ubuntu: humanity towards others.

ABOUT THE AUTHOR

Michael Jang (RHCE, UCP, LPIC-2, LCP, Linux+, MCP) is currently a full-time

writer who specializes in operating systems and networks. His experience with

computers goes back to the days of jumbled punch cards. He has written other

books on Linux certification, including RHCE Red Hat Certified Engineer Linux Study

Guide, Ubuntu Certified Professional Study Guide, Linux+ Certification Passport, and

Sair GNU/Linux Installation and Configuration Exam Cram. His other Linux books

include Linux Annoyances for Geeks, Linux Patch Management, and Mastering Fedora

Core Linux 5. He has also written or contributed to books on Microsoft operating

systems, including MCSE Guide to Microsoft Windows 98 and Mastering Windows XP

Professional, Second Edition.

About the Technical Editor

Elizabeth Zinkann is a logical Linux catalyst, a freelance technical editor, and

an independent computer consultant. She was a contributing editor and review

columnist for Sys Admin Magazine for 10 years. Some of her editing projects have

included RHCE Red Hat Certified Engineer Linux Study Guide, Linux+ Certification

Passport, Mastering Fedora Core Linux 5, Linux Patch Management, and Write Portable

Code. She owns an iBook that thinks it’s an “UbuntuBook” and is an avid digital

photographer. In a former life, she also programmed communications features,

including ISDN, at AT&T Network Systems.

v

CONTENTS

Preface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xvii

Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xix

▼ 1 The Ubuntu Community . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1

A Short History of Ubuntu and Linux . . . . . . . . . . . . . . . . . . . . . . 2

Background on Unix . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3

Linux Is Not Unix . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3

A Linux Distribution . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4

Linux and Open Source Licenses . . . . . . . . . . . . . . . . . . . . . 4

The Debian Project and Ubuntu . . . . . . . . . . . . . . . . . . . . . . 5

Ubuntu Just Works . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6

Hardy Heron Highlights . . . . . . . . . . . . . . . . . . . . . . . . . . . 7

The Ubuntu Release Configuration . . . . . . . . . . . . . . . . . . . . . . . . 8

Past Releases . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8

The Ubuntu Development Cycle . . . . . . . . . . . . . . . . . . . . . 9

Support Levels . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10

Desktop Environments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10

The Ubuntu Server . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11

vi Ubuntu Server Administration

Participate in the Ubuntu Community . . . . . . . . . . . . . . . . . . . . . 12

Sponsored by Canonical . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12

Request a “Hard Copy” Release with ShipIt . . . . . . . . . . . . 13

The Ubuntu Launchpad . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13

Ubuntu Community Resources . . . . . . . . . . . . . . . . . . . . . . 16

Launchpad Answers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19

The Ubuntu Wiki . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20

Ubuntu News and Security Notices . . . . . . . . . . . . . . . . . . . 20

Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21

▼ 2 Installing Ubuntu Server . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23

Acquire the Media . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24

Download the ISO File Online . . . . . . . . . . . . . . . . . . . . . . . 24

Download the ISO File from the Command Line . . . . . . . . . 26

Downloading the ISO File Cooperatively . . . . . . . . . . . . . . . 27

Write the ISO File to Disc . . . . . . . . . . . . . . . . . . . . . . . . . . . 27

Mount the ISO File on a Virtual Machine . . . . . . . . . . . . . . . 28

Mount the ISO File . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29

Alternatives to Downloads . . . . . . . . . . . . . . . . . . . . . . . . . . 29

Install from the CD . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29

Stability or Features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30

Hardware Configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . 30

Linux Hardware Documentation . . . . . . . . . . . . . . . . . . . . . 31

The Ubuntu Server Installation Screen . . . . . . . . . . . . . . . . . 31

Install Ubuntu Server, Step by Step . . . . . . . . . . . . . . . . . . . . . . . . 34

Choose a Language . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37

Configure the Keyboard . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38

Detect and Mount the CD-ROM . . . . . . . . . . . . . . . . . . . . . . 39

Load the Debconf Preconfiguration File . . . . . . . . . . . . . . . . 39

Load Installer Components from the CD . . . . . . . . . . . . . . . 39

Detect Network Hardware . . . . . . . . . . . . . . . . . . . . . . . . . . 40

Configure the Network . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41

Continue Installation Remotely Using SSH . . . . . . . . . . . . . 42

Choose a Mirror of the Ubuntu Archive . . . . . . . . . . . . . . . . 44

Download Installer Components . . . . . . . . . . . . . . . . . . . . . 45

Configure the Clock . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 46

Detect Disks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 46

Partition Disks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47

Configure MD Devices . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53

Install the Base System . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53

Set Up Users and Passwords . . . . . . . . . . . . . . . . . . . . . . . . 53

Configure the Package Manager . . . . . . . . . . . . . . . . . . . . . 54

vii Contents

Select and Install Software . . . . . . . . . . . . . . . . . . . . . . . . . . 55

Build LTSP Chroot . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 57

Install the GRUB Boot Loader on a Hard Disk . . . . . . . . . . . 58

Install the LILO Boot Loader on a Hard Disk . . . . . . . . . . . . 59

Continue Without Boot Loader . . . . . . . . . . . . . . . . . . . . . . 59

Finish the Installation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 59

Change Debconf Priority . . . . . . . . . . . . . . . . . . . . . . . . . . . 59

Check the CD-ROM(s) Integrity . . . . . . . . . . . . . . . . . . . . . 60

Save Debug Logs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 61

Execute a Shell . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 62

Eject a CD from the Drive . . . . . . . . . . . . . . . . . . . . . . . . . . . 63

Abort the Installation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 63

Finish the Installation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 63

Network Installations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 64

Dynamic Host Configuration Protocol (DHCP) Services . . . 64

Trivial File Transfer Protocol . . . . . . . . . . . . . . . . . . . . . . . . 66

Configure a Network Installation . . . . . . . . . . . . . . . . . . . . . 66

PXE Booting . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 67

Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 68

▼ 3 Automated Installations with Kickstart . . . . . . . . . . . . . . . . . . . . . . . . . . 69

How to Kickstart an Installation . . . . . . . . . . . . . . . . . . . . . . . . . . 70

Install the Kickstart Software . . . . . . . . . . . . . . . . . . . . . . . . 70

Use the Kickstart Configuration Tool . . . . . . . . . . . . . . . . . . 71

Customize the Kickstart File . . . . . . . . . . . . . . . . . . . . . . . . . 81

Boot an Installation with a Kickstart File . . . . . . . . . . . . . . . 84

Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 85

▼ 4 The Boot Process and Rescue Mode . . . . . . . . . . . . . . . . . . . . . . . . . . 87

What Happens After Powering Up . . . . . . . . . . . . . . . . . . . . . . . . 88

The BIOS Sequence . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 88

Making GRUB . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 90

Kernels and Hardware Detection . . . . . . . . . . . . . . . . . . . . . 96

Upstart, RCs Scripts, and Services . . . . . . . . . . . . . . . . . . . . 96

Rescue Options . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 100

Recovery and Single-User Mode . . . . . . . . . . . . . . . . . . . . . 100

Using the GRUB Command Line . . . . . . . . . . . . . . . . . . . . . 102

The Installation CD Rescue Mode . . . . . . . . . . . . . . . . . . . . 104

Using a LiveCD/DVD . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 107

Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 108

viii Ubuntu Server Administration

▼ 5 Filesystem Configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 109

Make the Filesystem Work for You . . . . . . . . . . . . . . . . . . . . . . . . 110

The Filesystem Hierarchy Standard . . . . . . . . . . . . . . . . . . . 110

Partition Device Files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 112

Create Partitions with fdisk . . . . . . . . . . . . . . . . . . . . . . . . . 113

The parted Utility . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 118

Format New Filesystems . . . . . . . . . . . . . . . . . . . . . . . . . . . 122

Manage Filesystems in /etc/fstab . . . . . . . . . . . . . . . . . . . . 124

How to Make RAID Work . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 128

RAID Definitions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 128

Create RAID Partitions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 129

Format and Configure a RAID Array . . . . . . . . . . . . . . . . . . 130

Use an Active RAID Array . . . . . . . . . . . . . . . . . . . . . . . . . . 131

Maintaining RAID Arrays . . . . . . . . . . . . . . . . . . . . . . . . . . 132

Make RAID Work in /etc/fstab . . . . . . . . . . . . . . . . . . . . . . 132

Logical Volumes Promote Flexibility . . . . . . . . . . . . . . . . . . . . . . . 133

Logical Volume Concepts . . . . . . . . . . . . . . . . . . . . . . . . . . . 133

Create Physical Volumes . . . . . . . . . . . . . . . . . . . . . . . . . . . . 134

Creating a Volume Group . . . . . . . . . . . . . . . . . . . . . . . . . . . 135

Creating a Logical Volume . . . . . . . . . . . . . . . . . . . . . . . . . . 136

Activate Logical Volumes . . . . . . . . . . . . . . . . . . . . . . . . . . . 138

Configure Logical Volumes in /etc/fstab . . . . . . . . . . . . . . . 139

Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 140

▼ 6 Command Line Tools and Shell Management . . . . . . . . . . . . . . . . . . . . 141

Command Line Fundamentals . . . . . . . . . . . . . . . . . . . . . . . . . . . 142

Interactivity and Command Completion . . . . . . . . . . . . . . . 142

Navigate Around Directories . . . . . . . . . . . . . . . . . . . . . . . . 144

File Management . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 146

Quotes and Backslashes . . . . . . . . . . . . . . . . . . . . . . . . . . . . 149

Aliases . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 151

Wildcards in a Glob . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 152

File Filters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 152

Command Combinations and Data Streams . . . . . . . . . . . . 153

Set the Default Linux Text Editor . . . . . . . . . . . . . . . . . . . . . 154

Optimize the Shell . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 156

Profiles in Bash . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 156

A Minor in Scripts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 157

Variables and More . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 158

Manage Permissions, Octal and Super . . . . . . . . . . . . . . . . . . . . . 158

Basic File Permissions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 159

Commands to Modify Permissions and Ownership . . . . . . 159

ix Contents

Special File Permissions . . . . . . . . . . . . . . . . . . . . . . . . . . . . 162

Access Control Lists . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 164

Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 165

▼ 7 Basic Administrative Tools . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 167

Create a Secure Shell Server . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 168

Installation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 168

Configuring the SSH Server . . . . . . . . . . . . . . . . . . . . . . . . . 168

Passphrases . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 172

A Warning . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 174

Client Access . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 174

Telnet if You Must . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 176

Schedule Important Jobs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 176

Standard cron Jobs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 177

User cron Jobs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 178

Configure at Jobs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 179

Job Scheduling Security . . . . . . . . . . . . . . . . . . . . . . . . . . . . 181

Customize Services and Runlevels . . . . . . . . . . . . . . . . . . . . . . . . 181

Script Actions in Different Runlevels . . . . . . . . . . . . . . . . . . 181

Manage when a Service Starts and Stops . . . . . . . . . . . . . . . 182

Manage Those Log Files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 184

General Log Configuration . . . . . . . . . . . . . . . . . . . . . . . . . . 185

General Log Files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 188

Service-Specific Log Files . . . . . . . . . . . . . . . . . . . . . . . . . . . 188

Log Rotation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 190

Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 190

▼ 8 Manage Updates and Local Repositories . . . . . . . . . . . . . . . . . . . . . . . 191

The Basics of dpkg and apt . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 192

A Background in dpkg . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 192

Ubuntu Repository Organization . . . . . . . . . . . . . . . . . . . . . 194

Repository Source Management . . . . . . . . . . . . . . . . . . . . . . 195

Find the Right Mirror . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 198

Fundamental apt Commands . . . . . . . . . . . . . . . . . . . . . . . . 198

More apt Commands . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 201

Update Management Tools . . . . . . . . . . . . . . . . . . . . . . . . . . 202

The Task Selector . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 208

Keep the Server Up-to-Date . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 209

Security Updates . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 209

Kernel Updates . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 209

Application Updates . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 210

x Ubuntu Server Administration

Create a Repository Mirror . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 210

Mirror Configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 210

To Mirror an Ubuntu Repository . . . . . . . . . . . . . . . . . . . . . 213

Use the Local Mirror . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 213

Manage with Landscape . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 214

Landscape Features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 214

Work with Landscape . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 214

Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 219

▼ 9 Printer Configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 221

CUPS and the Internet Printing Protocol . . . . . . . . . . . . . . . . . . . 222

The Installation of CUPS . . . . . . . . . . . . . . . . . . . . . . . . . . . . 222

A Variety of Local and Network Printers . . . . . . . . . . . . . . . 223

The Universal Resource Identifier (URI) . . . . . . . . . . . . . . . . 225

Major CUPS Configuration Files . . . . . . . . . . . . . . . . . . . . . 226

The GUI Configuration Tools . . . . . . . . . . . . . . . . . . . . . . . . . . . . 231

The CUPS Configuration Tools . . . . . . . . . . . . . . . . . . . . . . . 232

Add a New Printer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 234

Add a Print Class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 236

Samba Shared Printers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 236

More Print Management Options . . . . . . . . . . . . . . . . . . . . . . . . . 239

Configure Print Administrators . . . . . . . . . . . . . . . . . . . . . . 239

Print Management Commands . . . . . . . . . . . . . . . . . . . . . . . 240

Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 245

▼ 10 User, Group, and Administrator Management . . . . . . . . . . . . . . . . . . . . . 247

The Shadow Password Suite . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 248

Shadow Password Files . . . . . . . . . . . . . . . . . . . . . . . . . . . . 248

If You Need to Deactivate the Shadow Password Suite . . . . 252

A User and Group Configuration Tool . . . . . . . . . . . . . . . . . 252

Configure Users at the Command Line . . . . . . . . . . . . . . . . 257

Delegate Administrative Authority . . . . . . . . . . . . . . . . . . . . . . . . 262

Super User Concepts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 262

Partial Authorization in sudoers . . . . . . . . . . . . . . . . . . . . . . 263

Partial Authorization for a Wheel . . . . . . . . . . . . . . . . . . . . . 264

Quota Configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 265

Quotas in /etc/fstab . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 265

Quota Management Commands . . . . . . . . . . . . . . . . . . . . . . 266

Quotas by Size and Inode . . . . . . . . . . . . . . . . . . . . . . . . . . . 267

Quota Grace Periods . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 268

Quota Reports . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 269

Pluggable Authentication Modules (PAM) . . . . . . . . . . . . . . . . . . 269

PAM Configuration File Format . . . . . . . . . . . . . . . . . . . . . . 269

PAM Configuration Files . . . . . . . . . . . . . . . . . . . . . . . . . . . 271

xi Contents

The PolicyKit . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 273

Keeping It Simple . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 273

PolicyKit Concepts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 274

Configure with the PolicyKit GUI Tool . . . . . . . . . . . . . . . . . 275

PolicyKit Commands . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 284

Restore Default PolicyKit Settings . . . . . . . . . . . . . . . . . . . . 286

Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 287

▼ 11 Network Configuration and Troubleshooting . . . . . . . . . . . . . . . . . . . . . . 289

Basic Networking . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 290

Configure a Network Interface Card . . . . . . . . . . . . . . . . . . 290

Configure a Hardware Address . . . . . . . . . . . . . . . . . . . . . . 292

Configure Routing Tables . . . . . . . . . . . . . . . . . . . . . . . . . . . 292

Configure Forwarding . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 295

Network Configuration Files . . . . . . . . . . . . . . . . . . . . . . . . 296

Wireless Networking . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 300

The Network Settings Tool . . . . . . . . . . . . . . . . . . . . . . . . . . 304

Network Troubleshooting . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 305

Networking in the Boot Process . . . . . . . . . . . . . . . . . . . . . . 306

Troubleshoot a Network Connection . . . . . . . . . . . . . . . . . . 306

Troubleshoot a Network Route . . . . . . . . . . . . . . . . . . . . . . . 307

Troubleshoot Network Channels . . . . . . . . . . . . . . . . . . . . . 307

Troubleshoot Network Services . . . . . . . . . . . . . . . . . . . . . . 310

Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 311

▼ 12 Manage Network Authentication . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 313

Network Information Service . . . . . . . . . . . . . . . . . . . . . . . . . . . . 314

Prepare a Network for NIS . . . . . . . . . . . . . . . . . . . . . . . . . . 314

Installation and NIS Domains . . . . . . . . . . . . . . . . . . . . . . . . 315

Make portmap Responsive . . . . . . . . . . . . . . . . . . . . . . . . . . 315

Configuration Files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 316

The NIS Makefile . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 319

Database Maps . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 320

NIS Security . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 321

An NIS Client . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 322

Testing NIS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 322

NIS Slave Services . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 323

NIS in the Search Order . . . . . . . . . . . . . . . . . . . . . . . . . . . . 323

Lightweight Directory Access Protocol . . . . . . . . . . . . . . . . . . . . . 324

Installation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 324

Configure LDAP on the Server . . . . . . . . . . . . . . . . . . . . . . . 328

Configure LDAP on the Client . . . . . . . . . . . . . . . . . . . . . . . 331

Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 332

xii Ubuntu Server Administration

▼ 13 A Minimal Graphical Environment . . . . . . . . . . . . . . . . . . . . . . . . . . . . 333

Basic Graphical Definitions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 334

The X Server . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 334

The Desktop Environment . . . . . . . . . . . . . . . . . . . . . . . . . . 335

The Window Manager . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 335

Graphical Environment Options . . . . . . . . . . . . . . . . . . . . . . . . . . 336

Install Xfce . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 336

Install GNOME . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 338

Install KDE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 339

Configure the Xfce Desktop Environment . . . . . . . . . . . . . . . . . . 342

Selected Xfce Packages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 343

Configure the X Server . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 343

The X Server Configuration File, xorg.conf . . . . . . . . . . . . . 349

Basic Xfce Tools . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 351

Remote GUI Access . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 353

Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 357

▼ 14 DHCP and DNS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 359

Create a Dynamic Host Configuration

Protocol (DHCP) Server . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 360

Install the DHCP Server Packages . . . . . . . . . . . . . . . . . . . . 360

The Configuration File . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 362

The GUI DHCP Server Configuration Tool . . . . . . . . . . . . . 365

The Domain Name System . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 366

Install DNS Packages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 367

Focus on BIND . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 367

Ubuntu File Structure for BIND . . . . . . . . . . . . . . . . . . . . . . 368

Configure a Caching-Only Server . . . . . . . . . . . . . . . . . . . . 369

BIND Command Utilities . . . . . . . . . . . . . . . . . . . . . . . . . . . 370

Configure a Forwarding Server . . . . . . . . . . . . . . . . . . . . . . 373

Configure a Standard DNS Server . . . . . . . . . . . . . . . . . . . . 374

Configure a Secondary Master (Slave) Server . . . . . . . . . . . 378

Common DNS Pitfalls . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 379

Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 380

▼ 15 Web Servers and Apache’s LAMP . . . . . . . . . . . . . . . . . . . . . . . . . . . . 381

The Specialized LAMP Installation . . . . . . . . . . . . . . . . . . . . . . . . 382

Install the LAMP Stack . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 383

Installed Packages in the LAMP Stack . . . . . . . . . . . . . . . . . 384

If You Prefer Perl . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 386

If You Prefer Python . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 386

xiii Contents

Configure MySQL and PHP5 . . . . . . . . . . . . . . . . . . . . . . . . . . . . 386

Configure MySQL for Websites . . . . . . . . . . . . . . . . . . . . . . 387

Configure PHP for Websites . . . . . . . . . . . . . . . . . . . . . . . . . 388

Install and Configure Apache . . . . . . . . . . . . . . . . . . . . . . . . . . . . 388

Learn the Apache Configuration Files . . . . . . . . . . . . . . . . . 389

Apache Default Settings . . . . . . . . . . . . . . . . . . . . . . . . . . . . 390

Apache Global Settings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 390

The Apache Control Command . . . . . . . . . . . . . . . . . . . . . . 394

Examine the First Host . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 395

Configure Virtual Hosts . . . . . . . . . . . . . . . . . . . . . . . . . . . . 398

Configure Secure Virtual Hosts . . . . . . . . . . . . . . . . . . . . . . 400

Prepare Apache Documentation for Web Access . . . . . . . . . 403

Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 405

▼ 16 Create a File Server . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 407

Two Network File Servers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 408

The Kernel Server . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 409

The User Server . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 409

Related Services . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 409

Configure Exports . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 412

Share Exports . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 413

From an NFS Client . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 413

Sharing on Microsoft Networks . . . . . . . . . . . . . . . . . . . . . . . . . . 415

A Bit of Background on Samba . . . . . . . . . . . . . . . . . . . . . . . 415

Install Samba . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 416

Common Samba Commands . . . . . . . . . . . . . . . . . . . . . . . . 416

Analyze the Configuration File . . . . . . . . . . . . . . . . . . . . . . 418

A Basic Domain Member . . . . . . . . . . . . . . . . . . . . . . . . . . . 424

A Domain Controller . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 424

Part of an Active Directory Network . . . . . . . . . . . . . . . . . . 425

Implement Changes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 425

A Graphical Network Sharing Tool . . . . . . . . . . . . . . . . . . . . . . . . 425

Prepare to Share . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 425

Create a Samba Share . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 427

Create an NFS Share . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 428

Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 430

▼ 17 Other Services: Mail, FTP, and NTP . . . . . . . . . . . . . . . . . . . . . . . . . . . 431

Mail Services . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 432

Components of E-mail Systems . . . . . . . . . . . . . . . . . . . . . . 432

Simple Postfix Configuration . . . . . . . . . . . . . . . . . . . . . . . . 433

Simple sendmail Configuration . . . . . . . . . . . . . . . . . . . . . . 439

xiv Ubuntu Server Administration

FTP Services . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 445

Other FTP Servers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 445

The Very Secure FTP Service . . . . . . . . . . . . . . . . . . . . . . . . . 445

FTP Client . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 448

The Network Time Protocol Service . . . . . . . . . . . . . . . . . . . . . . . 449

Configure an NTP Client . . . . . . . . . . . . . . . . . . . . . . . . . . . 449

Select a Remote NTP Server . . . . . . . . . . . . . . . . . . . . . . . . . 450

Basic Configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 450

Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 452

▼ 18 Backups and Security . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 453

Backups . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 454

The Tape Archive (tar) Command . . . . . . . . . . . . . . . . . . . . 454

Sync Remotely . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 456

Other Backup Tools . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 458

Security with AppArmor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 458

AppArmor Packages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 459

AppArmor Modes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 460

Unsuitable AppArmor Commands . . . . . . . . . . . . . . . . . . . 460

AppArmor Status . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 460

AppArmor Boot Process . . . . . . . . . . . . . . . . . . . . . . . . . . . . 460

AppArmor Profiles . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 461

AppArmor Access Modes . . . . . . . . . . . . . . . . . . . . . . . . . . . 462

AppArmor Commands . . . . . . . . . . . . . . . . . . . . . . . . . . . . 462

Extra AppArmor Profiles . . . . . . . . . . . . . . . . . . . . . . . . . . . 463

Security with TCP Wrappers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 464

The TCP Wrappers Process . . . . . . . . . . . . . . . . . . . . . . . . . . 464

TCP Wrappers with /etc/hosts.allow

and /etc/hosts.deny . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 465

Port Security with iptables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 466

Port Security Concepts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 466

Configuring iptables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 467

Configuring iptables in Ubuntu . . . . . . . . . . . . . . . . . . . . . . 471

Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 471

▼ 19 Kernel Management . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 473

Why Recompile a Kernel? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 474

The Right Reasons . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 475

Basic Kernel Concepts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 475

Easy Kernel Upgrades . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 477

Get a New Kernel with apt . . . . . . . . . . . . . . . . . . . . . . . . . . 477

Make Sure the Boot Loader Is Right . . . . . . . . . . . . . . . . . . . 477

Tải ngay đi em, còn do dự, trời tối mất!