cyan yelloW MaGenTa Black panTone 123 c Books for professionals By professionals® The eXperT’s Voice® in open source Companion eBook Available Beginning Ubuntu Server Administration: From Novice to Professional Beginning U Dear Reader, Beginning For the past few years, many have hailed Ubuntu Linux as the best chance to b finally sway the computing masses toward the Linux desktop. And it’s easy to u see why: it offers an amazingly user-friendly interface, intuitive installation and configuration process, and an enormous choice of applications. Indeed, n Author of it’s become so popular that system administrators are rapidly adopting Ubuntu t Ubuntu Server The Definitive Guide to SUSE Server Edition to configure, deploy, and manage network services more effective- u Linux Enterprise Server ly than ever before. Pro Novell Open Enterprise Whether you’re interested in using Ubuntu within a Fortune 500 environment S Server or just managing your home network, you hold in your hands the only book you need. While writing it, I kept your daily administration tasks constantly e in mind, and I’ve included chapters on how to set up and run Ubuntu Server r as a file and print server, a virtualization server, and a web server. I also show Administration v you how to perform many other tasks that you’ll frequently encounter as an Ubuntu Server administrator, such as automating installation, configuration, e and deployment processes, and managing the kernel. r Along the way, this book will help you become a more proficient administra- tor as you learn to take advantage of little-known shell-related features, tips, A and tricks. Efficiency is a major theme of this book, and you’ll also learn how to optimize, troubleshoot, and remotely manage your server. d Reading this book will help you master every aspect of Ubuntu Server, from From Novice to Professional m both the command line and the graphical interface. Whether you’re about to manage your first server or are interested in expanding your knowledge of i Ubuntu Server, this is the book for you! n Sander van Vugt i s t THE APRESS ROADMAP r Everything you need to know to manage Ubuntu Server Companion eBook From Bash to Z-Shell: a Conquering the Command Line Beginning Ubuntu, The Definitive Guide to t Second Edition SUSE Linux Enterprise Server Beginning Ubuntu i o Server Administration Beginning SUSE Linux, The Definitive Guide to See last page for details Second Edition Samba 4, Second Edition n on $10 eBook version Practical MythTV: Building a PVR and Media Center v Sander van Vugt a ISBN-13: 978-1-59059-923-5 n www.apress.com ISBN-10: 1-59059-923-3 V 53999 u g US $39.99 t Shelve in Operating Systems/Linux User level: 9 781590 599235 Beginner–Intermediate this print for content only—size & color not accurate spine = 0.875" 376 page count m o ok.c o utl o @ ultz h a.sc by t. d e as h urc p as w ok o b his T 9233fm.qxd 11/13/07 2:51 PM Page i Beginning Ubuntu Server Administration From Novice to Professional Sander van Vugt 9233fm.qxd 11/13/07 2:51 PM Page ii Beginning Ubuntu Server Administration: From Novice to Professional Copyright © 2008 by Sander van Vugt All rights reserved. No part of this work may be reproduced or transmitted in any form or by any means, electronic or mechanical, including photocopying, recording, or by any information storage or retrieval system, without the prior written permission of the copyright owner and the publisher. ISBN-13 (pbk): 978-1-59059-923-5 ISBN-10 (pbk): 1-59059-923-3 ISBN-13 (electronic): 978-1-4302-0509-8 ISBN-10 (electronic): 1-4302-0509-1 Printed and bound in the United States of America 9 8 7 6 5 4 3 2 1 Trademarked names may appear in this book. Rather than use a trademark symbol with every occurrence of a trademarked name, we use the names only in an editorial fashion and to the benefit of the trademark owner, with no intention of infringement of the trademark. Lead Editors: Jason Gilmore, Tom Welsh Technical Reviewer: Curtis Smith Editorial Board: Steve Anglin, Ewan Buckingham, Tony Campbell, Gary Cornell, Jonathan Gennick, Jason Gilmore, Kevin Goff, Jonathan Hassell, Matthew Moodie, Joseph Ottinger, Jeffrey Pepper, Ben Renow-Clarke, Dominic Shakeshaft, Matt Wade, Tom Welsh Senior Project Manager: Kylie Johnston Copy Editor: Tom Gillen Associate Production Director: Kari Brooks-Copony Senior Production Editor: Laura Cheu Compositor: Molly Sharp, ContentWorks Proofreader: April Eddy Indexer: Brenda Miller Artist: April Milne Cover Designer: Kurt Krames Manufacturing Director: Tom Debolski Distributed to the book trade worldwide by Springer-Verlag New York, Inc., 233 Spring Street, 6th Floor, New York, NY 10013. Phone 1-800-SPRINGER, fax 201-348-4505, e-mail [email protected], or visit http://www.springeronline.com. For information on translations, please contact Apress directly at 2855 Telegraph Avenue, Suite 600, Berkeley, CA 94705. Phone 510-549-5930, fax 510-549-5939, e-mail [email protected], or visit http://www.apress.com. The information in this book is distributed on an “as is” basis, without warranty. Although every precaution has been taken in the preparation of this work, neither the author(s) nor Apress shall have any liability to any person or entity with respect to any loss or damage caused or alleged to be caused directly or indirectly by the information contained in this work. The source code for this book is available to readers at http://www.apress.com. 9233fm.qxd 11/13/07 2:51 PM Page iii This book is dedicated to Alex. 9233fm.qxd 11/13/07 2:51 PM Page iv 9233fm.qxd 11/13/07 2:51 PM Page v Contents at a Glance About the Author . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xv About the Technical Reviewer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xvii Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xix ■ CHAPTER 1 Installing Ubuntu Server . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 ■ CHAPTER 2 Getting the Most Out of the Command Line. . . . . . . . . . . . . . . . . . . . . 25 ■ CHAPTER 3 Performing Essential System Administration Tasks . . . . . . . . . . . . . 47 ■ CHAPTER 4 Performing File System Management Tasks . . . . . . . . . . . . . . . . . . . . 73 ■ CHAPTER 5 Configuring Your Server for Security. . . . . . . . . . . . . . . . . . . . . . . . . . . 107 ■ CHAPTER 6 Setting the System to Your Hand . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 151 ■ CHAPTER 7 Running It Anyway You Like. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 185 ■ CHAPTER 8 Making Connection. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 217 ■ CHAPTER 9 Configuring Network Infrastructure Services . . . . . . . . . . . . . . . . . . 255 ■ CHAPTER 10 Using Ubuntu Server As a File and Print Server. . . . . . . . . . . . . . . . 287 ■ CHAPTER 11 Setting Up Web Services. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 313 ■ CHAPTER 12 Multiplying Your Server. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 329 ■ INDEX . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 343 v 9233fm.qxd 11/13/07 2:51 PM Page vi 9233fm.qxd 11/13/07 2:51 PM Page vii Contents About the Author . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xv About the Technical Reviewer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xvii Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xix ■ CHAPTER 1 Installing Ubuntu Server. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 Preparing for the Installation. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 Starting the Ubuntu Server Installation Process. . . . . . . . . . . . . . . . . . . . . . . 2 Configuring the Server’s Hard Drive. . . . . . . . . . . . . . . . . . . . . . . . . . . . 8 Completing the Installation. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24 ■ CHAPTER 2 Getting the Most Out of the Command Line. . . . . . . . . . . . . . . 25 Working As root?. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25 Working with the Shell. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26 Using Bash to Best Effect. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26 Managing Bash with Key Sequences. . . . . . . . . . . . . . . . . . . . . . . . . . 29 Performing Basic File System Management Tasks . . . . . . . . . . . . . . . . . . . 30 Working with Directories . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30 Working with Files. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31 Viewing the Content of Text Files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33 Finding Files That Contain Specific Text. . . . . . . . . . . . . . . . . . . . . . . . 35 Creating Empty Files. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36 Piping and Redirection. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37 Piping. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37 Redirection . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37 Finding Files. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40 Working with an Editor. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40 Vi Modes. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41 Saving and Quitting. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42 Cut,Copy,and Paste. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42 Deleting Text. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42 vii 9233fm.qxd 11/13/07 2:51 PM Page viii viii ■ CONTENTS Getting Help . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43 Using man to Get Help . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43 Using the --help Option . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45 Getting Information on Installed Packages . . . . . . . . . . . . . . . . . . . . . 46 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 46 ■ CHAPTER 3 Performing Essential System Administration Tasks. . . . . . 47 Software Management. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47 Software Repositories and Package Databases. . . . . . . . . . . . . . . . . 48 Package Management Utilities . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49 Installing Software from Tarballs. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 57 Configuring a Graphical User Interface . . . . . . . . . . . . . . . . . . . . . . . . 58 Creating Backups . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 60 Making File Backups with tar . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 60 Making Device Backups Using dd. . . . . . . . . . . . . . . . . . . . . . . . . . . . . 63 Configuring Logging . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 64 Configuring syslog. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 64 Logging in Other Ways . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 69 Rotating Log Files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 69 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 72 ■ CHAPTER 4 Performing File System Management Tasks. . . . . . . . . . . . . . 73 Mounting Disks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 73 Using the mount Command. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 73 Unmounting Devices. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 77 Automating Mounts with /etc/fstab . . . . . . . . . . . . . . . . . . . . . . . . . . . 78 Checking File System Integrity. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 81 Working with Links. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 82 Why Use Links?. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 82 Working with Symbolic Links. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 82 Working with Hard Links. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 84 Configuring Storage . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 85 Comparing File Systems. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 85 Creating File Systems. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 94 Working with Logical Volumes. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 97 Doing Magic on Your File Systems with dd. . . . . . . . . . . . . . . . . . . . . . . . . 102 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 105
Description: