ebook img

Linux® Administration Handbook PDF

1041 Pages·2009·10.74 MB·English
Save to my drive
Quick download
Download
Most books are stored in the elastic cloud where traffic is expensive. For this reason, we have a limit on daily download.

Preview Linux® Administration Handbook

Linux ® Administration Handbook SECOND EDITION Evi Nemeth Garth Snyder Trent R. Hein with Lynda McGinley, Ben Whaley, Adam Boggs, Jeffrey S. Haemer, Tobi Oetiker, Fritz Zaucker, Scott Seidel, Bryan Buus, Ned McClain, and David Schweikert Upper Saddle River, NJ • Boston • Indianapolis • San Francisco New York • Toronto • Montreal • London • Munich • Paris • Madrid Capetown • Sydney • Tokyo • Singapore • Mexico City Many of the designations used by manufacturers and sellers to distinguish their products are claimed as trademarks. Where those designations appear in this book, and the publisher was aware of a trademark claim, the designations have been printed with initial capital letters or in all capitals. Red Hat Enterprise Linux and the Red Hat SHADOWMAN logo are registered trademarks of Red Hat Inc., and such trademarks are used with permission. Ubuntu is a registered trademark of Canonical Limited, and is used with permission. Fedora is a trademark of Red Hat Inc., and is used with permission. Novell, the Novell logo, the N logo, and SUSE are registered trademarks of Novell Inc. in the United States and other countries. The authors and publisher have taken care in the preparation of this book, but make no expressed or implied warranty of any kind and assume no responsibility for errors or omissions. No liability is assumed for incidental or consequential damages in connection with or arising out of the use of the information or programs contained herein. The publisher offers excellent discounts on this book when ordered in quantity for bulk purchases or special sales, which may include custom covers and content particular to your business, training goals, marketing focus, and branding interests. For more information, please contact: U.S. Corporate and Government Sales (800) 382-3419 [email protected] For sales outside the United States, please contact: International Sales [email protected] Visit us on the Web: www.prenhallprofessional.com Library of Congress Cataloging-in-Publication Data Nemeth, Evi. Linux administration handbook / Evi Nemeth, Garth Snyder, Trent R. Hein.—2nd ed. p. cm. Includes index. ISBN 0-13-148004-9 (pbk. : alk. paper) 1. Linux. 2. Operating systems (Computers) I. Snyder, Garth. II. Hein, Trent R. III. Title. QA76.76.O63N448 2006 005.4'32—dc22 2006030150 Copyright © 2007 Pearson Education, Inc. All rights reserved. Printed in the United States of America. This publication is protected by copy- right, and permission must be obtained from the publisher prior to any prohibited reproduction, storage in a retrieval system, or transmission in any form or by any means, electronic, mechanical, photocopying, recording, or likewise. For information regarding permissions, write to: Pearson Education, Inc. Rights and Contracts Department One Lake Street Upper Saddle River, NJ 07458 Fax: (201) 236-3290 ISBN 0-13-148004-9 Text printed in the United States on recycled paper at Courier in Stoughton, Massachusetts. First printing, October 2006 Contents FOREWORDTOTHE FIRST EDITION xxxiii PREFACE xxxiv ACKNOWLEDGMENTS xxxvii SECTION ONE: BASIC ADMINISTRATION CHAPTER 1 WHERETO START 3 Suggested background. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4 Linux’s relationship to UNIX . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4 Linux in historical context. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5 Linux distributions. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6 So what’s the best distribution? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8 Distribution-specific administration tools. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9 Notation and typographical conventions. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9 System-specific information. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10 Where to go for information. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11 Organization of the man pages. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12 man: read manual pages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13 Other sources of Linux information . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13 How to find and install software. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14 iii iv Linux Administration Handbook Essential tasks of the system administrator . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .16 Adding, removing, and managing user accounts . . . . . . . . . . . . . . . . . . . . . . . .16 Adding and removing hardware. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .16 Performing backups. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .17 Installing and upgrading software . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .17 Monitoring the system. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .17 Troubleshooting . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .17 Maintaining local documentation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .17 Vigilantly monitoring security . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .17 Helping users. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .18 System administration under duress. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .18 System Administration Personality Syndrome . . . . . . . . . . . . . . . . . . . . . . . . . .18 Recommended reading . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .19 Exercises. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .20 CHAPTER 2 BOOTINGAND SHUTTING DOWN 21 Bootstrapping . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .21 Automatic and manual booting . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .22 Steps in the boot process. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .22 Kernel initialization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .23 Hardware configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .23 Kernel threads . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .23 Operator intervention (manual boot only). . . . . . . . . . . . . . . . . . . . . . . . . . . . . .24 Execution of startup scripts. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .25 Multiuser operation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .25 Booting PCs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .25 Using boot loaders: LILO and GRUB. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .26 GRUB: The GRand Unified Boot loader . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .26 LILO: The traditional Linux boot loader. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .28 Kernel options. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .29 Multibooting on PCs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .30 GRUB multiboot configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .30 LILO multiboot configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .31 Booting single-user mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .31 Single-user mode with GRUB. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .32 Single-user mode with LILO. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .32 Working with startup scripts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .32 init and run levels. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .33 Red Hat and Fedora startup scripts. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .36 SUSE startup scripts. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .38 Debian and Ubuntu startup scripts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .40 Contents v Rebooting and shutting down . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40 Turning off the power . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41 shutdown: the genteel way to halt the system. . . . . . . . . . . . . . . . . . . . . . . . . . . 41 halt: a simpler way to shut down. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42 reboot: quick and dirty restart. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42 telinit: change init’s run level . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42 poweroff: ask Linux to turn off the power. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42 Exercises. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43 CHAPTER 3 ROOTLY POWERS 44 Ownership of files and processes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44 The superuser . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 46 Choosing a root password. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47 Becoming root. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48 su: substitute user identity . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48 sudo: a limited su. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48 Other pseudo-users . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51 bin: legacy owner of system commands . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51 daemon: owner of unprivileged system software . . . . . . . . . . . . . . . . . . . . . . . . 51 nobody: the generic NFS user. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51 Exercises. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52 CHAPTER 4 CONTROLLING PROCESSES 53 Components of a process. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53 PID: process ID number . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 54 PPID: parent PID . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 54 UID and EUID: real and effective user ID. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 54 GID and EGID: real and effective group ID . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 55 Niceness. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 55 Control terminal. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56 The life cycle of a process . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56 Signals. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 57 kill and killall: send signals . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 60 Process states. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 60 nice and renice: influence scheduling priority . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 61 ps: monitor processes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 62 top: monitor processes even better . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 65 The /proc filesystem. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 65 strace: trace signals and system calls. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 66 Runaway processes. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 67 Recommended reading . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 69 Exercises. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 69 vi Linux Administration Handbook CHAPTER 5 THE FILESYSTEM 70 Pathnames . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .72 Filesystem mounting and unmounting. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .73 The organization of the file tree . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .75 File types. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .76 Regular files. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .78 Directories . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .78 Character and block device files. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .79 Local domain sockets. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .80 Named pipes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .80 Symbolic links. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .80 File attributes. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .81 The permission bits . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .81 The setuid and setgid bits . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .82 The sticky bit. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .82 Viewing file attributes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .82 chmod: change permissions. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .84 chown: change ownership and group. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .86 umask: assign default permissions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .86 Bonus flags. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .87 Access control lists . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .88 ACL overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .88 Default entries. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .91 Exercises. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .92 CHAPTER 6 ADDING NEW USERS 93 The /etc/passwd file. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .93 Login name . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .94 Encrypted password. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .96 UID (user ID) number. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .96 Default GID number. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .97 GECOS field. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .98 Home directory. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .98 Login shell . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .98 The /etc/shadow file. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .99 The /etc/group file . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .101 Adding users . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .102 Editing the passwd and shadow files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .103 Editing the /etc/group file. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .104 Setting an initial password . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .104 Contents vii Creating the user’s home directory . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 105 Copying in the default startup files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 105 Setting the user’s mail home. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 106 Verifying the new login . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 106 Recording the user’s status and contact information. . . . . . . . . . . . . . . . . . . . 107 Removing users. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 107 Disabling logins. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 108 Managing accounts. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 108 Exercises. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 110 CHAPTER 7 ADDINGA DISK 111 Disk interfaces. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 111 The PATA interface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 112 The SATA interface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 114 The SCSI interface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 114 Which is better, SCSI or IDE?. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 118 Disk geometry. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 119 Linux filesystems . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 120 Ext2fs and ext3fs. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 120 ReiserFS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 121 XFS and JFS. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 122 An overview of the disk installation procedure. . . . . . . . . . . . . . . . . . . . . . . . . . . . . 122 Connecting the disk . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 122 Formatting the disk . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 123 Labeling and partitioning the disk. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 124 Creating filesystems within disk partitions . . . . . . . . . . . . . . . . . . . . . . . . . . . . 125 Mounting the filesystems . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 126 Setting up automatic mounting . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 127 Enabling swapping. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 129 hdparm: set IDE interface parameters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 129 fsck: check and repair filesystems . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 131 Adding a disk: a step-by-step guide. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 133 Advanced disk management: RAID and LVM. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 138 Linux software RAID . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 139 Logical volume management . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 139 An example configuration with LVM and RAID. . . . . . . . . . . . . . . . . . . . . . . . 140 Dealing with a failed disk . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 144 Reallocating storage space. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 146 Mounting USB drives. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 147 Exercises. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 148 viii Linux Administration Handbook CHAPTER 8 PERIODIC PROCESSES 150 cron: schedule commands. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .150 The format of crontab files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .151 Crontab management. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .153 Some common uses for cron . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .154 Cleaning the filesystem . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .154 Network distribution of configuration files . . . . . . . . . . . . . . . . . . . . . . . . . . . .155 Rotating log files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .156 Other schedulers: anacron and fcron. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .156 Exercises. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .157 CHAPTER 9 BACKUPS 158 Motherhood and apple pie . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .159 Perform all dumps from one machine. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .159 Label your media . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .159 Pick a reasonable backup interval . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .159 Choose filesystems carefully . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .160 Make daily dumps fit on one piece of media . . . . . . . . . . . . . . . . . . . . . . . . . . .160 Make filesystems smaller than your dump device. . . . . . . . . . . . . . . . . . . . . . .161 Keep media off-site. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .161 Protect your backups . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .161 Limit activity during dumps . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .162 Verify your media. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .162 Develop a media life cycle . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .163 Design your data for backups. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .163 Prepare for the worst . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .163 Backup devices and media. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .163 Optical media: CD-R/RW, DVD±R/RW, and DVD-RAM. . . . . . . . . . . . . . . .164 Removable hard disks (USB and FireWire) . . . . . . . . . . . . . . . . . . . . . . . . . . . .165 Small tape drives: 8mm and DDS/DAT. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .166 DLT/S-DLT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .166 AIT and SAIT. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .166 VXA/VXA-X . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .167 LTO. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .167 Jukeboxes, stackers, and tape libraries . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .167 Hard disks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .168 Summary of media types. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .168 What to buy. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .168 Setting up an incremental backup regime with dump . . . . . . . . . . . . . . . . . . . . . . .169 Dumping filesystems . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .169 Dump sequences. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .171 Contents ix Restoring from dumps with restore . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 173 Restoring individual files. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 173 Restoring entire filesystems . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 175 Dumping and restoring for upgrades . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 176 Using other archiving programs. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 177 tar: package files. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 177 cpio: archiving utility from ancient times . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 178 dd: twiddle bits. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 178 Using multiple files on a single tape . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 178 Bacula. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 179 The Bacula model. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 180 Setting up Bacula . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 181 Installing the database and Bacula daemons . . . . . . . . . . . . . . . . . . . . . . . . . . . 181 Configuring the Bacula daemons. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 182 bacula-dir.conf: director configuration. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 183 bacula-sd.conf: storage daemon configuration . . . . . . . . . . . . . . . . . . . . . . . . 187 bconsole.conf: console configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 188 Installing and configuring the client file daemon . . . . . . . . . . . . . . . . . . . . . . . 188 Starting the Bacula daemons. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 189 Adding media to pools. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 190 Running a manual backup . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 190 Running a restore job. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 192 Monitoring and debugging Bacula configurations . . . . . . . . . . . . . . . . . . . . . . 195 Alternatives to Bacula . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 197 Commercial backup products . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 197 ADSM/TSM. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 197 Veritas . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 198 Other alternatives. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 198 Recommended reading . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 198 Exercises. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 198 CHAPTER 10 SYSLOGAND LOG FILES 201 Logging policies . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 201 Throwing away log files. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 201 Rotating log files. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 202 Archiving log files. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 204 Linux log files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 204 Special log files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 206 Kernel and boot-time logging. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 206 logrotate: manage log files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 208

Description:
Linux administration handbook / Evi Nemeth, Garth Snyder, Trent R. Hein.—2nd ed. p. cm. Creating the user's home directory . Running a manual backup . Most current versions of BSD UNIX (including FreeBSD, NetBSD, b) “Umm, I accidentally did a sudo rm -rf /* on my machine khaya.
See more

The list of books you might like

Most books are stored in the elastic cloud where traffic is expensive. For this reason, we have a limit on daily download.