
3,375 256 11MB
Pages 1184 Page size 561 x 702 pts Year 2008
A Practical Guide to Ubuntu Linux
Mark G. Sobell
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. Ubuntu is a registered trademark of Canonical Ltd. The author 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 electronic versions and/or 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 Sobell, Mark G. A practical guide Ubuntu Linux / Mark G. Sobell. p. cm. Includes index. ISBN-13: 978-0-13-236039-5 (pbk. : alk. paper) 1. Linux. 2. Operating systems (Computers) I. Title. QA76.76.O63S59497 2008 005.4'32—dc22 2007043244 Copyright © 2008 Mark G. Sobell All rights reserved. Printed in the United States of America. This publication is protected by copyright, 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 Permissions 501 Boylston Street, Suite 900 Boston, MA 02116 Fax (617) 671-3447 ISBN-13: ISBN-10:
978-0-13-236039-5 0-13-236039-X
Text printed in the United States on recycled paper at Courier in Stoughton, Massachusetts. First printing, December 2007
For my dad, Morton Sobell, who taught me to examine the world very carefully.
This page intentionally left blank
Brief Contents Contents xi Preface xxxv 1
Welcome to Linux
PART I 2 3
Installing Ubuntu Linux
21
Installation Overview 23 Step-by-Step Installation 45
PART II 4 5 6 7
1
Getting Started with Ubuntu Linux
Introduction to Ubuntu Linux The Linux Utilities 145 The Linux Filesystem 183 The Shell 219
PART III
85
87
Digging into Ubuntu Linux
8 Linux GUIs: X and GNOME 251 9 The Bourne Again Shell 275 10 Networking and the Internet 353 11 Programming the Bourne Again Shell
249
395
ix
x Brief Contents
PART IV 12 13 14 15 16 17 18
PART V 19 20 21 22 23 24 25 26 27
483
Using Clients and Setting Up Servers
OpenSSH: Secure Network Communication 707 FTP: Transferring Files Across a Network 729 exim4: Setting Up Mail Servers, Clients, and More 755 NIS: Network Information Service 781 NFS: Sharing Filesystems 799 Samba: Linux and Windows File and Printer Sharing 823 DNS/BIND: Tracking Domain Names and Addresses 845 firestarter and iptables: Setting Up a Firewall 885 Apache: Setting Up a Web Server 915
PART VI A B C D E
System Administration
System Administration: Core Concepts 485 Files, Directories, and Filesystems 553 Downloading and Installing Software 583 Printing with CUPS 611 Building a Linux Kernel 635 Administration Tasks 657 Configuring a LAN 693
Appendixes
969
Regular Expressions 971 Help 981 Security 991 The Free Software Definition The Linux 2.6 Kernel 1015
Glossary 1021 Index 1071
1011
705
Contents Preface xxxvi Chapter 1: Welcome to Linux
1
The GNU–Linux Connection 2 The History of GNU–Linux 2 The Code Is Free 4 Have Fun! 5 The Linux 2.6 Kernel 5 The Heritage of Linux: UNIX
5
What Is So Good About Linux? 6 Why Linux Is Popular with Hardware Companies and Developers 7 Linux Is Portable 8 Standards 9 The C Programming Language 9 Ubuntu Linux 10 Overview of Linux 10 Linux Has a Kernel Programming Interface 10 Linux Can Support Many Users 11 Linux Can Run Many Tasks 11 Linux Provides a Secure Hierarchical Filesystem 12 The Shell: Command Interpreter and Programming Language A Large Collection of Useful Utilities 14 Interprocess Communication 14 System Administration 15
12
xi
xii
Contents
Additional Features of Linux 15 GUIs: Graphical User Interfaces 15 (Inter)Networking Utilities 16 Software Development 17 Conventions Used in This Book 17 Chapter Summary 20 Exercises 20
PART I
Installing Ubuntu Linux
Chapter 2: Installation Overview
21
23
The Live/Install Desktop CD/DVD 24 More Information 24 Planning the Installation 25 Considerations 25 Requirements 25 Processor Architecture 26 Interfaces: Installer and Installed System 27 Ubuntu Releases 28 Ubuntu Editions 28 Installing a Fresh Copy or Upgrading an Existing Ubuntu System? Setting Up the Hard Disk 30 RAID 34 LVM: Logical Volume Manager 35 The Installation Process 36 Downloading and Burning a CD/DVD 37 The Easy Way to Download a CD ISO Image File 37 Other Ways to Download a CD/DVD ISO Image File 37 Verifying an ISO Image File 40 Burning the CD/DVD 40 Gathering Information About the System 41 Chapter Summary 42 Exercises 43 Advanced Exercises 43
Chapter 3: Step-by-Step Installation
45
Basic Installation from the Live/Install Desktop CD/DVD Booting the System 46 Checking the CD/DVD for Defects 47 Live Session 47
46
29
Contents xiii
Graphical Partitioners 53 gparted: the GNOME Partition Editor 53 ubiquity: Setting Up Partitions 56 Upgrading to a New Release 59 Installing KDE 60 Setting Up a Dual-Boot System 61 Creating Free Space on a Windows System 61 Installing Ubuntu Linux as the Second Operating System 61 Advanced Installation 62 The Live/Install Desktop CD: The Initial Install Screen 62 The Alternate CD Initial Install Screen Menu 65 The Server CD Initial Install Screen Menu 66 The DVD 67 The Ubuntu Textual Installer 67 The X Window System 74 displayconfig-gtk: Configures the Display 75 The xorg.conf File 77 gdm: Displays a Graphical Login 82 Chapter Summary 83 Exercises 83 Advanced Exercises 84
PART II
Getting Started with Ubuntu Linux
Chapter 4: Introduction to Ubuntu Linux Curbing Your Power: root Privileges/sudo 88 A Tour of the Ubuntu Linux Desktop 89 Logging In on the System 89 Introduction 90 Launching Programs from the Desktop 91 Switching Workspaces 93 Setting Personal Preferences 94 Mouse Preferences 95 Working with Windows 96 Using Nautilus to Work with Files 96 The Update Notifier 100 Changing Appearances (Themes) 102 Session Management 104 Getting Help 104 Feel Free to Experiment 105 Logging Out 105
87
85
xiv
Contents
Getting the Most out of the Desktop 105 GNOME Desktop Terminology 105 Opening Files 106 Panels 107 The Main Menu 110 Windows 111 The Object Context Menu 115 Updating, Installing, and Removing Software Packages 119 Software Sources Window 119 Add/Remove Applications 120 Synaptic: Finds, Installs, and Removes Software 121 Where to Find Documentation 124 Ubuntu Help Center 124 man: Displays the System Manual 124 info: Displays Information About Utilities 126 The ––help Option 129 HOWTOs: Finding Out How Things Work 129 Getting Help with the System 130 More About Logging In 132 The Login Screen 132 What to Do if You Cannot Log In 133 Logging In Remotely: Terminal Emulators, ssh, and Dial-Up Connections Logging In from a Terminal (Emulator) 134 Changing Your Password 135 Using Virtual Consoles 136 Working from the Command Line 136 Correcting Mistakes 137 Repeating/Editing Command Lines 139 Controlling Windows: Advanced Operations 139 Changing the Input Focus 139 Changing the Resolution of the Display 140 The Window Manager 141 Chapter Summary 142 Exercises 143 Advanced Exercises 144
Chapter 5: The Linux Utilities
145
Special Characters 146 Basic Utilities 147 ls: Lists the Names of Files 147 cat: Displays a Text File 147 rm: Deletes a File 148 less Is more: Display a Text File One Screen at a Time hostname: Displays the System Name 149
148
133
Contents xv
Working with Files 149 cp: Copies a File 149 mv: Changes the Name of a File 150 lpr: Prints a File 151 grep: Searches for a String 151 head: Displays the Beginning of a File 152 tail: Displays the End of a File 152 sort: Displays a File in Order 153 uniq: Removes Duplicate Lines from a File 154 diff: Compares Two Files 154 file: Tests the Contents of a File 155 | (Pipe): Communicates Between Processes 156 Four More Utilities 157 echo: Displays Text 157 date: Displays the Time and Date 157 script: Records a Shell Session 158 unix2dos: Converts Linux and Macintosh Files to Windows Format Compressing and Archiving Files 159 bzip2: Compresses a File 160 bunzip2 and bzcat: Decompress a File 160 gzip: Compresses a File 161 tar: Packs and Unpacks Archives 161 Locating Commands 164 which and whereis: Locate a Utility 164 apropos: Searches for a Keyword 165 slocate: Searches for a File 166 Obtaining User and System Information 166 who: Lists Users on the System 167 finger: Lists Users on the System 167 w: Lists Users on the System 169 Communicating with Other Users 170 write: Sends a Message 170 mesg: Denies or Accepts Messages 171 Email 171 Tutorial: Creating and Editing a File with vim 172 Starting vim 172 Command and Input Modes 174 Entering Text 175 Getting Help 176 Ending the Editing Session 178 The compatible Parameter 179 Chapter Summary 179 Exercises 181 Advanced Exercises 182
159
xvi
Contents
Chapter 6: The Linux Filesystem
183
The Hierarchical Filesystem 184 Directory Files and Ordinary Files 184 Filenames 185 The Working Directory 188 Your Home Directory 188 Pathnames 189 Absolute Pathnames 189 Relative Pathnames 190 Directory Commands 191 mkdir: Creates a Directory 191 Important Standard Directories and Files 194 Working with Directories 196 rmdir: Deletes a Directory 196 Using Pathnames 197 mv, cp: Move or Copy Files 197 mv: Moves a Directory 198 Access Permissions 199 ls –l: Displays Permissions 199 chmod: Changes Access Permissions 200 Setuid and Setgid Permissions 201 Directory Access Permissions 202 ACLs: Access Control Lists 203 Enabling ACLs 204 Working with Access Rules 204 Setting Default Rules for a Directory 207 Links 209 Hard Links 210 Symbolic Links 212 rm: Removes a Link 214 Chapter Summary 214 Exercises 216 Advanced Exercises 218
Chapter 7: The Shell
219
The Command Line 220 Syntax 220 Processing the Command Line 223 Executing the Command Line 225 Editing the Command Line 225 Standard Input and Standard Output 226 The Screen as a File 226 The Keyboard and Screen as Standard Input and Standard Output Redirection 228 Pipes 234
227
Contents xvii
Running a Program in the Background 237 Filename Generation/Pathname Expansion 239 The ? Special Character 239 Special Character 240 The The [ ] Special Characters 241 Builtins 243 Chapter Summary 244 Utilities and Builtins Introduced in This Chapter Exercises 245 Advanced Exercises 247
*
PART III
245
Digging into Ubuntu Linux
Chapter 8: Linux GUIs: X and GNOME
251
X Window System 252 Using X 254 Window Managers 259 The Nautilus File Browser Window 260 The View Pane 261 The Side Pane 261 Control Bars 262 Menubar 263 GNOME Utilities 266 Deskbar Applet 266 Font Preferences 267 Pick a Font Window 268 Pick a Color Window 268 Run Application Window 269 Searching for Files 269 GNOME Terminal Emulator/Shell 270 Chapter Summary 271 Exercises 272 Advanced Exercises 272
Chapter 9: The Bourne Again Shell Background 276 Shell Basics 277 Startup Files 277 Commands That Are Symbols 280 Redirecting Standard Error 280 Writing a Simple Shell Script 282 Separating and Grouping Commands 286 Job Control 290 Manipulating the Directory Stack 292
275
249
xviii
Contents
Parameters and Variables 295 User-Created Variables 296 Variable Attributes 299 Keyword Variables 301 Special Characters 309 Processes 310 Process Structure 310 Process Identification 310 Executing a Command 312 History 312 Variables That Control History 312 Reexecuting and Editing Commands 314 The Readline Library 322 Aliases 328 Single Versus Double Quotation Marks in Aliases Examples of Aliases 330 Functions 331 Controlling bash Features and Options 334 Command Line Options 334 Shell Features 334 Processing the Command Line 338 History Expansion 338 Alias Substitution 338 Parsing and Scanning the Command Line 338 Command Line Expansion 339 Chapter Summary 347 Exercises 349 Advanced Exercises 351
329
Chapter 10: Networking and the Internet Types of Networks and How They Work 355 Broadcast Networks 356 Point-to-Point Networks 356 Switched Networks 356 LAN: Local Area Network 357 WAN: Wide Area Network 358 Internetworking Through Gateways and Routers 358 Network Protocols 361 Host Address 363 CIDR: Classless Inter-Domain Routing 367 Hostnames 368 Communicate Over a Network 370 finger: Displays Information About Remote Users 370 Sending Mail to a Remote User 371 Mailing List Servers 372
353
Contents xix
Network Utilities 372 Trusted Hosts 372 OpenSSH Tools 373 telnet: Logs In on a Remote System 373 ftp: Transfers Files Over a Network 375 ping: Tests a Network Connection 375 traceroute: Traces a Route Over the Internet 376 host and dig: Query Internet Nameservers 378 jwhois: Looks Up Information About an Internet Site Distributed Computing 379 The Client/Server Model 380 DNS: Domain Name Service 381 Ports 383 NIS: Network Information Service 383 NFS: Network Filesystem 383 Internet Services 384 Proxy Servers 387 RPC Network Services 387 Usenet 388 WWW: World Wide Web 390 URL: Uniform Resource Locator 391 Browsers 392 Search Engines 392 Chapter Summary 392 Exercises 393 Advanced Exercises 394
378
Chapter 11: Programming the Bourne Again Shell Control Structures 396 if...then 396 if...then...else 400 if...then...elif 403 for...in 409 for 410 while 412 until 416 break and continue 418 case 419 select 425 Here Document 427 File Descriptors 429 Parameters and Variables 432 Array Variables 432 Locality of Variables 434 Special Parameters 436 Positional Parameters 438 Expanding Null and Unset Variables
443
395
xx
Contents
Builtin Commands 444 type: Displays Information About a Command 445 read: Accepts User Input 445 exec: Executes a Command 448 trap: Catches a Signal 451 kill: Aborts a Process 454 getopts: Parses Options 454 A Partial List of Builtins 457 Expressions 458 Arithmetic Evaluation 458 Logical Evaluation (Conditional Expressions) 459 String Pattern Matching 460 Operators 461 Shell Programs 466 A Recursive Shell Script 467 The quiz Shell Script 470 Chapter Summary 476 Exercises 478 Advanced Exercises 480
PART IV
System Administration
483
Chapter 12: System Administration: Core Concepts 485 Running Commands with root Privileges 487 sudo: Running a Command with root Privileges 490 sudoers: Configuring sudo 494 Unlocking the root Account (Assigning a Password to root) su: Gives You Another User’s Privileges 499 The Upstart Event-Based init Daemon 500 Software Packages 501 Definitions 501 Jobs 503 SysVinit (rc) Scripts: Start and Stop System Services 507 System Operation 510 Runlevels 510 Booting the System 511 Recovery (Single-User) Mode 512 Going to Multiuser Mode 515 Logging In 516
499
Contents xxi
Logging Out 517 Bringing the System Down 518 Crash 519 Avoiding a Trojan Horse 520 Getting Help 522 Textual System Administration Utilities 522 kill: Sends a Signal to a Process 522 Other Textual Utilities 525 Setting Up a Server 527 Standard Rules in Configuration Files 528 rpcinfo: Displays Information About portmap 530 The inetd and xinetd Superservers 531 Securing a Server 532 DHCP: Configures Network Interfaces 538 nsswitch.conf: Which Service to Look at First 542 How nsswitch.conf Works 542 PAM 545 More Information 546 Configuration Files, Module Types, and Control Flags 546 Example 548 Modifying the PAM Configuration 549 Chapter Summary 550 Exercises 551 Advanced Exercises 551
Chapter 13: Files, Directories, and Filesystems Important Files and Directories 554 File Types 566 Ordinary Files, Directories, Links, and Inodes 566 Special Files 567 Filesystems 570 mount: Mounts a Filesystem 572 umount: Unmounts a Filesystem 575 fstab: Keeps Track of Filesystems 576 fsck: Checks Filesystem Integrity 577 tune2fs: Changes Filesystem Parameters 578 RAID Filesystem 580 Chapter Summary 580 Exercises 580 Advanced Exercises 581
553
xxii
Contents
Chapter 14: Downloading and Installing Software 583 JumpStart: Installing and Removing Packages Using aptitude 585 Finding the Package That Holds a File You Need 587 APT: Keeps the System Up-to-Date 588 Repositories 588 sources.list: Specifies Repositories for APT to Search 589 The APT Local Package Indexes and the APT Cache 590 The apt cron Script and APT Configuration Files 590 aptitude: Works with Packages and the Local Package Index 592 apt-cache: Displays Package Information 596 apt-get source: Downloads Source Files 598 dpkg: The Debian Package Management System 598 deb Files 599 dpkg: The Foundation of the Debian Package Management System BitTorrent 604 Installing Non-dpkg Software 607 The /opt and /usr/local Directories 607 GNU Configure and Build System 607 wget: Downloads Files Noninteractively 609 Chapter Summary 610 Exercises 610 Advanced Exercises 610
Chapter 15: Printing with CUPS
600
611
Introduction 612 Prerequisites 612 More Information 613 Notes 613 JumpStart I: Configuring a Local Printer 614 system-config-printer: Configuring a Printer 614 Configuration Tabs 614 Setting Up a Remote Printer 616 JumpStart II: Configuring a Remote Printer Using the CUPS Web Interface Traditional UNIX Printing 622 Configuring Printers 624 The CUPS Web Interface 624 CUPS on the Command Line 626 Sharing CUPS Printers 629 Printing from Windows 630 Printing Using CUPS 631 Printing Using Samba 631
618
Contents
Printing to Windows 632 Chapter Summary 633 Exercises 633 Advanced Exercises 633
Chapter 16: Building a Linux Kernel
635
Prerequisites 636 Downloading the Kernel Source Code 637 aptitude: Downloading and Installing the Kernel Source Code git: Obtaining the Latest Kernel Source Code 637 Read the Documentation 638 Configuring and Compiling the Linux Kernel 639 .config: Configures the Kernel 639 Customizing a Kernel 640 Cleaning the Source Tree 642 Compiling a Kernel Image File and Loadable Modules 643 Using Loadable Kernel Modules 643 Installing the Kernel, Modules, and Associated Files 646 Rebooting 647 grub: The Linux Boot Loader 647 menu.lst: Configures grub 648 update-grub: Updates the menu.lst file 651 grub-install: Installs the MBR and grub Files 653 dmesg: Displays Kernel Messages 654 Chapter Summary 655 Exercises 656 Advanced Exercises 656
Chapter 17: Administration Tasks Configuring User and Group Accounts 658 users-admin: Manages User Accounts 658 useradd: Adds a User Account 660 userdel: Removes a User Account 661 usermod: Modifies a User Account 661 groupadd: Adds a Group 661 groupdel: Removes a Group 661 Backing Up Files 662 Choosing a Backup Medium 663 Backup Utilities 663 Performing a Simple Backup 665 dump , restore: Back Up and Restore Filesystems
657
666
637
xxiii
xxiv
Contents
Scheduling Tasks 668 cron and anacron: Schedule Routine Tasks 668 at: Runs Occasional Tasks 671 System Reports 671 vmstat: Reports Virtual Memory Statistics 671 top: Lists Processes Using the Most Resources 672 parted: Reports on and Partitions a Hard Disk 673 Keeping Users Informed 677 Creating Problems 678 Solving Problems 679 Helping When a User Cannot Log In 679 Speeding Up the System 680 lsof: Finds Open Files 681 Keeping a Machine Log 681 Keeping the System Secure 682 Log Files and Mail for root 683 Monitoring Disk Usage 683 logrotate: Manages Log Files 684 Removing Unused Space from Directories 686 Disk Quota System 687 syslogd: Logs System Messages 688 Chapter Summary 690 Exercises 690 Advanced Exercises 691
Chapter 18: Configuring a LAN
693
Setting Up the Hardware 694 Connecting the Computers 694 Routers 695 NIC: Network Interface Card 695 Tools 695 Configuring the Systems 697 network-admin: Configures Network Connections 698 nm-applet: Configures Network Connections Automatically 700 iwconfig: Configures a Wireless NIC 700 Setting Up Servers 702 More Information 703 Chapter Summary 703 Exercises 704 Advanced Exercises 704
Contents
PART V
xxv
Using Clients and Setting Up Servers 705
Chapter 19: OpenSSH: Secure Network Communication 707 Introduction 708 About OpenSSH 708 Files 708 How OpenSSH Works 710 More Information 711 OpenSSH Clients 711 Prerequisites 711 JumpStart: Using ssh and scp 711 Setup 712 ssh: Connects to or Executes Commands on a Remote System 714 scp: Copies Files to and from a Remote System 716 sftp: A Secure FTP Client 718 ~/.ssh/config and /etc/ssh/ssh_config Configuration Files 718 sshd: OpenSSH Server 720 Prerequisites 720 Note 720 JumpStart: Starting the sshd Daemon 720 Authorized Keys: Automatic Login 721 Command Line Options 722 /etc/ssh/sshd_config Configuration File 722 Troubleshooting 724 Tunneling/Port Forwarding 725 Chapter Summary 727 Exercises 728 Advanced Exercises 728
Chapter 20: FTP: Transferring Files Across a Network 729 Introduction 730 More Information 731 FTP Client 731 Prerequisites 731 JumpStart I: Downloading Files Using ftp 732 Notes 735 Anonymous FTP 735 Automatic Login 735 Binary Versus ASCII Transfer Mode 736 ftp Specifics 736
xxvi
Contents
FTP Server (vsftpd) 740 Prerequisites 740 Notes 740 JumpStart II: Starting a vsftpd Server 741 Testing the Setup 741 vsftpd.conf: The vsftpd Configuration File 742 Chapter Summary 753 Exercises 753 Advanced Exercises 754
Chapter 21: exim4: Setting Up Mail Servers, Clients, and More 755 Introduction to exim4 756 Prerequisites 757 Notes 757 More Information 758 JumpStart I: Configuring exim4 to Use a Smarthost 758 JumpStart II: Configuring exim4 to Send and Receive Email 760 How exim4 Works 761 Mail Logs 762 Working with Messages 763 Aliases and Forwarding 763 Related Programs 765 Configuring exim4 765 Using a Text Editor to Configure exim4 766 The update-exim4.conf.conf Configuration File 766 dpkg-reconfigure: Configures exim4 768 SpamAssassin 768 Prerequisites 769 How SpamAssassin Works 769 Testing SpamAssassin 770 Configuring SpamAssassin 771 Additional Email Tools 772 Webmail 772 Mailing Lists 774 Setting Up an IMAP or POP3 Server 776 Authenticated Relaying 777 Alternatives to exim4 779 Chapter Summary 779 Exercises 780 Advanced Exercises 780
Contents
Chapter 22: NIS: Network Information Service Introduction to NIS 782 How NIS Works 782 More Information 784 Setting Up an NIS Client 784 Prerequisites 785 Notes 785 Step-by-Step Setup 786 Testing the Setup 787 yppasswd: Changes NIS Passwords 788 Setting Up an NIS Server 790 Prerequisites 790 Notes 791 Step-by-Step Setup 791 Testing 796 yppasswdd: The NIS Password Update Daemon Chapter Summary 798 Exercises 798 Advanced Exercises 798
781
797
Chapter 23: NFS: Sharing Filesystems
799
Introduction 800 More Information 802 Setting Up an NFS Client 802 Prerequisites 802 JumpStart I: Mounting a Remote Directory Hierarchy 803 mount: Mounts a Directory Hierarchy 804 Improving Performance 806 /etc/fstab: Mounts Directory Hierarchies Automatically 807 Setting Up an NFS Server 808 Prerequisites 808 Notes 808 JumpStart II: Configuring an NFS Server Using shares-admin 809 Manually Exporting a Directory Hierarchy 811 Where the System Keeps NFS Mount Information 815 exportfs: Maintains the List of Exported Directory Hierarchies 817 Testing the Server Setup 818 automount: Mounts Directory Hierarchies on Demand 818 Chapter Summary 821 Exercises 822 Advanced Exercises 822
xxvii
xxviii
Contents
Chapter 24: Samba: Linux and Windows File and Printer Sharing 823 Introduction 824 About Samba 825 Prerequisites 825 More Information 825 Notes 825 Samba Users, User Maps, and Passwords 826 JumpStart: Configuring a Samba Server Using shares-admin 826 swat: Configures a Samba Server 828 smb.conf: Manually Configuring a Samba Server 832 Parameters in the smbd.conf File 832 The [homes] Share: Sharing Users’ Home Directories 838 Accessing Linux Shares from Windows 838 Browsing Shares 838 Mapping a Share 839 Accessing Windows Shares from Linux 839 smbtree: Displays Windows Shares 839 smbclient: Connects to Windows Shares 840 Browsing Windows Networks 840 Mounting Windows Shares 841 Troubleshooting 841 Chapter Summary 844 Exercises 844 Advanced Exercises 844
Chapter 25: DNS/BIND: Tracking Domain Names and Addresses 845 Introduction to DNS 846 Nodes, Domains, and Subdomains Zones 848 Queries 849 Servers 850 Resource Records 851 DNS Query and Response 854 Reverse Name Resolution 855 About DNS 857 How DNS Works 857 Prerequisites 857 More Information 858 Notes 858
846
Contents
JumpStart I: Setting Up a DNS Cache 858 Setting Up BIND 860 named.conf: The named Configuration File Zone Files 863 A DNS Cache 864 DNS Glue Records 868 TSIGs: Transaction Signatures 868 Running BIND in a chroot Jail 870 Troubleshooting 872 A Full-Functioned Nameserver 873 A Slave Server 877 A Split Horizon Server 878 Chapter Summary 883 Exercises 883 Advanced Exercises 884
860
Chapter 26: firestarter and iptables: Setting Up a Firewall 885 About firestarter 886 Prerequisites 886 Notes 887 More Information 888 JumpStart: Building a Firewall Using the firestarter Firewall Wizard 888 firestarter: Maintains a Firewall 890 The Status Tab 890 The Events Tab 892 The Policy Tab 894 How iptables Works 896 About iptables 899 More Information 899 Prerequisites 899 Notes 899 Anatomy of an iptables Command 900 Building a Set of Rules 901 Commands 901 Packet Match Criteria 903 Display Criteria 903 Match Extensions 903 Targets 906 Copying Rules to and from the Kernel 907
xxix
xxx
Contents
Sharing an Internet Connection Using NAT 908 Connecting Several Clients to a Single Internet Connection 910 Connecting Several Servers to a Single Internet Connection 912 Chapter Summary 912 Exercises 913 Advanced Exercises 913
Chapter 27: Apache: Setting Up a Web Server
915
Introduction 916 About Apache 917 Prerequisites 917 More Information 918 Notes 918 JumpStart: Getting Apache Up and Running 919 Modifying the Configuration Files 919 Testing Apache 920 Putting Your Content in Place 920 Configuring Apache 921 Configuration Tools 921 Include Directives 922 Filesystem Layout 923 Configuration Directives 925 Directives I: Directives You May Want to Modify as You Get Started 926 Contexts and Containers 931 Directives II: Advanced Directives 935 The Ubuntu apache2.conf File 948 The Ubuntu default Configuration File 950 Redirects 951 Content Negotiation 951 Type Maps 951 MultiViews 952 Server-Generated Directory Listings (Indexing) 953 Virtual Hosts 953 Setting Up a Virtual Host 954 Types of Virtual Hosts 954 The default Virtual Host 954 Examples 954 Troubleshooting 956 Modules 957 mod_cgi and CGI Scripts 958 mod_ssl 959 Authentication Modules and .htaccess 961 Scripting Modules 962 Multiprocessing Modules (MPMs) 963
Contents webalizer: Analyzes Web Traffic
MRTG: Monitors Traffic Loads Error Codes 964 Chapter Summary 965 Exercises 966 Advanced Exercises 966
PART VI
964 964
Appendixes
969
Appendix A: Regular Expressions Characters 972 Delimiters 972 Simple Strings 972 Special Characters 972 Periods 973 Brackets 973 Asterisks 974 Carets and Dollar Signs 974 Quoting Special Characters 975 Rules 975 Longest Match Possible 975 Empty Regular Expressions 976 Bracketing Expressions 976 The Replacement String 976 Ampersand 977 Quoted Digit 977 Extended Regular Expressions 977 Appendix Summary 979
Appendix B: Help
981
Solving a Problem 982 Finding Linux-Related Information 983 Documentation 983 Useful Linux Sites 984 Linux Newsgroups 985 Mailing Lists 985 Words 986 Software 986 Office Suites and Word Processors 988 Specifying a Terminal 988
971
xxxi
xxxii
Contents
Appendix C: Security
991
Encryption 992 Public Key Encryption 993 Symmetric Key Encryption 994 Encryption Implementation 995 GnuPG/PGP 995 File Security 997 Email Security 997 MTAs (Mail Transfer Agents) 997 MUAs (Mail User Agents) 998 Network Security 998 Network Security Solutions 999 Network Security Guidelines 999 Host Security 1001 Login Security 1002 Remote Access Security 1003 Viruses and Worms 1004 Physical Security 1004 Security Resources 1006 Appendix Summary 1009
Appendix D: The Free Software Definition Appendix E: The Linux 2.6 Kernel
1011
1015
Native Posix Thread Library (NPTL) 1016 IPSecurity (IPSec) 1016 Asynchronous I/O (AIO) 1016 O(1) Scheduler 1017 OProfile 1017 kksymoops 1017 Reverse Map Virtual Memory (rmap VM) 1017 HugeTLBFS: Translation Look-Aside Buffer Filesystem 1018 remap_file_pages 1018 2.6 Network Stack Features (IGMPv3, IPv6, and Others) 1018 Internet Protocol Virtual Server (IPVS) 1019 Access Control Lists (ACLs) 1019 4GB-4GB Memory Split: Physical Address Extension (PAE) 1019 Scheduler Support for HyperThreaded CPUs 1019
Contents
Block I/O (BIO) Block Layer 1019 Support for Filesystems Larger Than 2 Terabytes 1020 New I/O Elevators 1020 Interactive Scheduler Response Tuning 1020
Glossary 1021 Index 1071
xxxiii
This page intentionally left blank
M
Preface
Preface The book
Whether you are an end user, a system administrator, or a little of both, this book explains with step-by-step examples how to get the most out of an Ubuntu Linux system. In 27 chapters, this book takes you from installing an Ubuntu system through understanding its inner workings to setting up secure servers that run on the system.
The audience
This book is designed for a wide range of readers. It does not require you to have programming experience, although having some experience using a general-purpose computer, such as a Windows, Macintosh, UNIX, or another Linux system is certainly helpful. This book is appropriate for • Students who are taking a class in which they use Linux • Home users who want to set up and/or run Linux • Professionals who use Linux at work • System administrators who need an understanding of Linux and the tools that are available to them • Computer science students who are studying the Linux operating system • Technical executives who want to get a grounding in Linux
Benefits
A Practical Guide to Ubuntu Linux® gives you a broad understanding of many facets of Linux, from installing Ubuntu Linux through using and customizing it. No matter what your background, this book provides the knowledge you need to get on with your work. You will come away from this book understanding how to use Linux, and this book will remain a valuable reference for years to come.
xxxv
xxxvi Preface Overlap
If you read A Practical Guide to Linux® Commands, Editors, and Shell Programming, you will notice some overlap between that book and the one you are reading now. The first chapter, the chapters on the utilities and the filesystem, and the appendix on regular expressions are very similar in the two books, as are the three chapters on the Bourne Again Shell (bash). Chapters that appear in this book but do not appear in A Practical Guide to Linux® Commands, Editors, and Shell Programming include Chapters 2 and 3 (installation), Chapters 4 and 8 (Ubuntu Linux and the GUI), Chapter 10 (networking), all of the chapters in Part IV (system administration) and Part V (servers), and Appendix C (security).
Differences
While this book explains how to use Linux from a graphical interface and from the command line (a textual interface), A Practical Guide to Linux® Commands, Editors, and Shell Programming works exclusively with the command line. It includes full chapters on the vi and emacs editors, as well as chapters on the gawk pattern processing language and the sed stream editor. In addition, it has a command reference section that provides extensive examples of the use of more than 80 of the most important Linux utilities. You can use these utilities to solve problems without resorting to programming in C.
This Book Includes Ubuntu Gutsy Gibbon (7.10) on a Live/Install DVD This book includes a live/install DVD that holds the Gutsy Gibbon (7.10) release of Ubuntu Linux. You can use this DVD to run a live Ubuntu session that displays the GNOME desktop without making any changes to your computer: Boot from the DVD, run an Ubuntu live session, and log off. Your system remains untouched: When you reboot, it is exactly as it was before you ran the Ubuntu live session. Alternatively, you can install Ubuntu from the live session. Chapter 2 helps you get ready to install Ubuntu. Chapter 3 provides step-by-step instructions for installing Ubuntu from this DVD. This book guides you through learning about, using, and administrating an Ubuntu Linux session. DVD features
The included DVD incorporates all the features of the live/install Desktop CD as well as the Alternate and Server CDs. It also includes all software packages supported by Ubuntu. You can use it to perform a graphical or textual (command line) installation of either a graphical or a textual Ubuntu system. If you do not have an Internet connection, you can use the DVD as a software repository and install any supported software packages from it.
Features of This Book This book is designed and organized so you can get the most out of it in the shortest amount of time. You do not have to read this book straight through in page order. Instead, once you are comfortable using Linux, you can use this book as a reference:
Features of This Book xxxvii
Look up a topic of interest in the table of contents or index and read about it. Or think of the book as a catalog of Linux topics: Flip through the pages until a topic catches your eye. The book includes many pointers to Web sites where you can get additional information: Consider the Internet an extension of this book. A Practical Guide to Ubuntu Linux® is structured with the following features: • Optional sections enable you to read the book at different levels, returning to more difficult material when you are ready to delve into it. • Caution boxes highlight procedures that can easily go wrong, giving you guidance before you run into trouble. • Tip boxes highlight ways you can save time by doing something differently or situations when it may be useful or just interesting to have additional information. • Security boxes point out places where you can make a system more secure. The security appendix presents a quick background in system security issues. • Concepts are illustrated by practical examples throughout the book. • Chapter summaries review the important points covered in each chapter. • Review exercises are included at the end of each chapter for readers who want to further hone their skills. Answers to even-numbered exercises are available at www.sobell.com. • The glossary defines more than 500 common terms. • The chapters that cover servers include JumpStart sections that get you off to a quick start using clients and setting up servers. Once a server is up and running, you can test and modify its configuration as explained in the rest of the chapter. • This book provides resources for finding software on the Internet. It also explains how to download and install software using Synaptic, aptitude, the GNOME Add/Remove Applications window, and BitTorrent. It details controlling automatic updates using the Update Notifier and the Update Manager window. • This book describes in detail many important GNU tools, including the GNOME desktop, the Nautilus File Browser, the parted and gparted partition editors, the gzip compression utility, and many command line utilities that come from the GNU project. • Pointers throughout the text provide help in obtaining online documentation from many sources, including the local system, the Ubuntu Web site, and other locations on the Internet. • Many useful URLs point to Web sites where you can obtain software, security programs and information, and more. • The comprehensive index helps you locate topics quickly and easily.
xxxviii Preface
Key Topics Covered in This Book This book contains a lot of information. This section distills and summarizes its contents. In addition, “Details” (starting on page xli) describes what each chapter covers. Finally, the table of contents provides more detail. This book: Installation
• Describes how to download Ubuntu Linux ISO images from the Internet and burn the Ubuntu live/install Desktop CD, the DVD, or the Ubuntu Alternate or Server installation CD. • Helps you plan the layout of the system’s hard disk. It includes a discussion of partitions, partition tables, and mount points, and assists you in using the ubiquity or gparted graphical partitioner or the Ubuntu textual partitioner to partition the hard disk. • Explains how to set up a dual-boot system so you can install Ubuntu Linux on a Windows system and boot either operating system. • Describes in detail how to install Ubuntu Linux from a live/install Desktop CD or the live/install DVD using the ubiquity graphical installer. It also explains how to use the textual installer found on the Alternate CD, the Server CD, and the DVD. The graphical installer is fast and easy to use. The textual installer gives you more options and works on systems with less RAM (system memory). • Covers testing an Ubuntu CD/DVD for defects, setting boot command line parameters (boot options), and creating a RAID array. • Covers the details of installing and customizing the X.org version of the X Window System either graphically using the Screen and Graphics Preferences window or manually with a text editor.
Working with Ubuntu Linux
• Introduces the GNOME desktop (GUI) and explains how to use desktop tools, including the Top and Bottom panels, panel objects, the Main menu, object context menus, the Workspace Switcher, the Nautilus File Browser, and the GNOME Terminal emulator. • Explains how to use the Appearance Preferences window to add and modify themes to customize your desktop to please your senses and help you work more efficiently. • Details how to set up 3D desktop visual effects that take advantage of Compiz Fusion. • Covers the Bourne Again Shell (bash) in three chapters, including an entire chapter on shell programming that includes many sample shell scripts. These chapters provide clear explanations and extensive examples of how bash works both from the command line in day-to-day work and as a programming language to write shell scripts.
Key Topics Covered in This Book xxxix
• Explains the textual (command line) interface and introduces more than 30 command line utilities. • Presents a tutorial on the vim textual editor. • Covers types of networks, network protocols, and network utilities. • Explains hostnames, IP addresses, and subnets, and explores how to use host and dig to look up domain names and IP addresses on the Internet. • Covers distributed computing and the client/server model. • Explains how to use ACLs (Access Control Lists) to fine-tune user access permissions. System administration
• Explains how to use the Ubuntu graphical and textual (command line) tools to configure the display, DNS, NFS, Samba, Apache, a firewall, a network interface, and more. You can also use these tools to add users and manage local and remote printers. • Goes into detail about using sudo to allow specific users to work with root privileges (become Superuser) and customizing the way sudo works by editing the sudoers configuration file. It also explains how you can unlock the root account if necessary. • Describes how to use the following tools to download and install software to keep a system up-to-date and to install new software: ◆
The Software Sources window controls which Ubuntu and third-party software repositories Ubuntu downloads software packages from and whether Ubuntu downloads updates automatically. You can also use this window to cause Ubuntu to download and install security updates automatically.
◆
If you do not have an Internet connection, you can use the Software Sources window to set up the DVD included with this book as a software repository. You can then install any software packages that Ubuntu supports from this repository.
◆
Based on how you set up updates in the Software Sources window, the Update Notifier pops up on the desktop to let you know when software updates are available. Click the Update Notifier to open the Update Manager window, from which you can download and install updates.
◆
The Add/Remove Applications window provides an easy way to select, download, and install a wide range of software packages.
◆
Synaptic allows you to search for, install, and remove software packages. It gives you more ways to search for packages than does the Add/Remove Applications window.
xl Preface ◆
APT downloads and installs software packages from the Internet (or the included DVD), keeping a system up-to-date and resolving dependencies as it processes the packages. You can use APT from a graphical interface (Synaptic) or from several textual interfaces (e.g., aptitude and apt-get).
◆
BitTorrent is a good choice for distributing large amounts of data such as the Ubuntu installation DVD and CDs. The more people who use BitTorrent to download a file, the faster it works.
• Covers graphical system administration tools, including the many tools available from the GNOME Main menu. • Explains system operation, including the boot process, init scripts, recovery (single-user) and multiuser modes, and steps to take if the system crashes. • Describes how to use and program the new Upstart init daemon, which replaces the System V init daemon. • Describes files, directories, and filesystems, including types of files and filesystems, fstab (the filesystem table), and automatically mounted filesystems, and explains how to fine-tune and check the integrity of filesystems. • Covers backup utilities, including tar, cpio, dump, and restore. • Describes compression/archive utilities, including gzip, bzip2, compress, and zip. • Explains how to customize and build a Linux kernel. Security
• Helps you manage basic system security issues using ssh (secure shell), vsftpd (secure FTP server), Apache (Web server), iptables (firewalls), and more. • Covers using firestarter to share an Internet connection over a LAN, run a DHCP server, and set up a basic firewall to protect the system. • Provides instructions on using iptables to share an Internet connection over a LAN and to build advanced firewalls. • Describes how to set up a chroot jail to help protect a server system. • Explains how to use TCP wrappers to control who can access a server.
Clients and servers
• Explains how to set up and use the most popular Linux servers, providing a chapter on each: Apache, Samba, OpenSSH, exim4, DNS, NFS, FTP, firestarter and iptables, and NIS (all of which are supported by Ubuntu Linux). • Describes how to set up a CUPS printer server. • Describes how to set up and use a DHCP server either by itself or from firestarter.
Programming
• Provides a full chapter covering shell programming using bash, including many examples.
Key Topics Covered in This Book
xli
Details Chapter 1
Chapter 1 presents a brief history of Linux and explains some of the features that make it a cutting-edge operating system. The “Conventions Used in This Book” (page 17) section details the typefaces and terminology this book uses.
Part I
Part I, “Installing Ubuntu Linux,” discusses how to install Ubuntu Linux. Chapter 2 presents an overview of the process of installing Ubuntu Linux, including hardware requirements, downloading and burning a CD or DVD, and planning the layout of the hard disk. Chapter 3 is a step-by-step guide to installing Ubuntu Linux from a CD or DVD, using the graphical or textual installer. It also shows how to set up the X Window System and customize your desktop (GUI).
Part II
Part II, “Getting Started with Ubuntu Linux,” familiarizes you with Ubuntu Linux, covering logging in, the GUI, utilities, the filesystem, and the shell. Chapter 4 introduces desktop features, including the Top and Bottom panels and the Main menu; explains how to use the Nautilus File Browser to manage files, run programs, and connect to FTP and HTTP servers; covers finding documentation, dealing with login problems, and using the window manager; and presents some suggestions on where to find documentation, including manuals, tutorials, software notes, and HOWTOs. Chapter 5 introduces the shell command line interface, describes more than 30 useful utilities, and presents a tutorial on the vim text editor. Chapter 6 discusses the Linux hierarchical filesystem, covering files, filenames, pathnames, working with directories, access permissions, and hard and symbolic links. Chapter 7 introduces the Bourne Again Shell (bash) and discusses command line arguments and options, redirecting input to and output from commands, running programs in the background, and using the shell to generate and expand filenames.
Experienced users may want to skim Part II tip If you have used a UNIX or Linux system before, you may want to skim or skip some or all of the chapters in Part II. Part I has two sections that all readers should take a look at: “Conventions Used in This Book” (page 17), which explains the typographic and layout conventions used in this book, and “Where to Find Documentation” (page 124), which points out both local and remote sources of Linux and Ubuntu documentation. Part III
Part III, “Digging into Ubuntu Linux,” goes into more detail about working with the system. Chapter 8 discusses the GUI (desktop) and includes a section on how to run a graphical program on a remote system and have the display appear locally. The section on GNOME describes several GNOME utilities, including the new Deskbar applet, and goes into more depth about the Nautilus File Browser. Chapter 9 extends the bash coverage from Chapter 7, explaining how to redirect error output, avoid overwriting files, and work with job control, processes, startup files, important shell builtin commands, parameters, shell variables, and aliases. Chapter 10 explains networks, network security, and the Internet and discusses types of networks, subnets, protocols, addresses, hostnames, and various network utilities. The section on distributed computing describes the client/server model and some of the servers you can use on a network. Chapter 11 goes into greater depth about shell programming
xlii Preface
using bash, with the discussion enhanced by extensive examples. Details of setting up and using clients and servers are reserved until Part V. Part IV
Part IV covers system administration. Chapter 12 discusses core concepts such as the use of sudo, working with root privileges, system operation, chroot jails, TCP wrappers, general information about how to set up a server, DHCP, and PAM. Chapter 13 explains the Linux filesystem, going into detail about types of files, including special and device files; the use of fsck to verify the integrity of and repair filesystems; and the use of tune2fs to change filesystem parameters. Chapter 14 explains how to keep a system up-to-date by downloading software from the Internet and installing it, including examples of using APT programs such as aptitude, apt-get, and apt-cache. It also covers the dpkg software packaging system and the use of some dpkg utilities. Finally, it explains how to use BitTorrent from the command line to download files. Chapter 15 explains how to set up the CUPS printing system so you can print on both local and remote systems. Chapter 16 details customizing and building a Linux kernel. Chapter 17 covers additional administration tasks, including setting up user accounts, backing up files, scheduling automated tasks, tracking disk usage, and solving general problems. Chapter 18 explains how to set up a local area network (LAN), including both hardware (including wireless) and software configuration.
Part V
Part V goes into detail about setting up and running servers and connecting to them with clients. Where appropriate, these chapters include JumpStart sections that get you off to a quick start in using clients and setting up servers. The chapters in Part V cover the following clients/servers: • OpenSSH Set up an OpenSSH server and use ssh, scp, and sftp to communicate securely over the Internet. • FTP Set up a vsftpd secure FTP server and use any of several FTP clients to exchange files with the server. • Mail Configure exim4 and use Webmail, POP3, or IMAP to retrieve email; use SpamAssassin to combat spam. • NIS
Set up NIS to facilitate system administration of a LAN.
• NFS
Share filesystems between systems on a network.
• Samba Share filesystems and printers between Windows and Linux systems. • DNS/BIND Set up a domain nameserver to let other systems on the Internet know the names and IP addresses of local systems they may need to contact. • firestarter and iptables Share a single Internet connection between systems on a LAN, run a DHCP server, and set up a firewall to protect local systems. • Apache Set up an HTTP server that serves Web pages that browsers can display. This chapter includes many suggestions for increasing Apache security.
Thanks xliii Part VI
Part VI includes appendixes on regular expressions, helpful Web sites, system security, and free software. This part also includes an extensive glossary with more than 500 entries plus a comprehensive index.
Supplements The author’s home page (www.sobell.com) contains downloadable listings of the longer programs from this book as well as pointers to many interesting and useful Linux sites on the World Wide Web, a list of corrections to the book, answers to evennumbered exercises, and a solicitation for corrections, comments, and suggestions.
Thanks First and foremost, I want to thank Mark L. Taub, Editor-in-Chief, Prentice Hall, who provided encouragement and support through the hard parts of this project. Mark is unique in my 25 years of book writing experience: an editor who works with the tools I write about. Because Mark runs Ubuntu on his home computer, we shared experiences as I wrote this book. Mark, your comments and direction are invaluable; this book would not exist without your help. Thank you, Mark T. Molly Sharp of ContentWorks worked with me day-by-day during production of this book providing help, listening to my rants, and keeping everything on track. Thanks to Jill Hobbs, Copyeditor, who made the book readable, understandable, and consistent; and Linda Seifert, Proofreader, who made each page sparkle. Thanks also to the folks at Prentice Hall who helped bring this book to life, especially Julie Nahil, Full-Service Production Manager, who oversaw production of the book; John Fuller, Managing Editor, who kept the large view in check; Marie McKinley, Marketing Manager; Noreen Regina, Editorial Assistant, who attended to the many details involved in publishing this book, including keeping the review team on schedule (no small task); Heather Fox, Publicist; Dan Scherf, Media Developer; Sandra Schroeder, Design Manager; Chuti Prasertsith, Cover Designer; and everyone else who worked behind the scenes to make this book come into being. I am also indebted to Denis Howe, Editor of The Free On-line Dictionary of Computing (FOLDOC). Denis has graciously permitted me to use entries from his compilation. Be sure to look at this dictionary (www.foldoc.org). A big “thank you” to the folks who read through the drafts of the book and made comments that caused me to refocus parts of the book where things were not clear or were left out altogether: David Chisnall, Swansea University; Scott Mann, Aztek Networks; Matthew Miller, Senior Systems Analyst/Administrator, BU Linux Project, Boston University Office of Information Technology; George
xliv Preface
Vish II, Senior Education Consultant, Hewlett-Packard; Thomas Achtemichuk, Mansueto Ventures; John Dong, Ubuntu Forum Council Member/Backports Team Leader; Scott James Remnant, Ubuntu Development Manager and Desktop Team Leader; Daniel R. Arfsten, Pro/Engineer Drafter/Designer; Chris Cooper, Senior Education Consultant, Hewlett-Packard Education Services; Sameer Verma, Associate Professor of Information Systems, San Francisco State University; Valerie Chau, Palomar College and Programmers Guild; James Kratzer; Sean McAllister; Nathan Eckenrode, New York Ubuntu Local Community Team; Christer Edwards; Nicolas Merline; and Michael Price. Thanks also to the following people who helped with my previous Linux books, which provided a foundation for this book: Chris Karr, Northwestern University; Jesse Keating, Fedora Project; Carsten Pfeiffer, Software Engineer and KDE Developer; Aaron Weber, Ximian; Cristof Falk, Software Developer at CritterDesign; Steve Elgersma, Computer Science Department, Princeton University; Scott Dier, University of Minnesota; Robert Haskins, Computer Net Works; Lars KelloggStedman, Harvard University; Jim A. Lola, Principal Systems Consultant, Privateer Systems; Eric S. Raymond, Cofounder, Open Source Initiative; Scott Mann; Randall Lechlitner, Independent Computer Consultant; Jason Wertz, Computer Science Instructor, Montgomery County Community College; Justin Howell, Solano Community College; Ed Sawicki, The Accelerated Learning Center; David Mercer; Jeffrey Bianchine, Advocate, Author, Journalist; John Kennedy; and Jim Dennis, Starshine Technical Services. Thanks also to Dustin Puryear, Puryear Information Technology; Gabor Liptak, Independent Consultant; Bart Schaefer, Chief Technical Officer, iPost; Michael J. Jordan, Web Developer, Linux Online; Steven Gibson, Owner, SuperAnt.com; John Viega, Founder and Chief Scientist, Secure Software; K. Rachael Treu, Internet Security Analyst, Global Crossing; Kara Pritchard, K & S Pritchard Enterprises; Glen Wiley, Capital One Finances; Karel Baloun, Senior Software Engineer, Looksmart; Matthew Whitworth; Dameon D. Welch-Abernathy, Nokia Systems; Josh Simon, Consultant; Stan Isaacs; and Dr. Eric H. Herrin II, Vice President, Herrin Software Development. And thanks to Doug Hughes, long-time system designer and administrator, who gave me a big hand with the sections on system administration, networks, the Internet, and programming. More thanks go to consultants Lorraine Callahan and Steve Wampler; Ronald Hiller, Graburn Technology; Charles A. Plater, Wayne State University; Bob Palowoda; Tom Bialaski, Sun Microsystems; Roger Hartmuller, TIS Labs at Network Associates; Kaowen Liu; Andy Spitzer; Rik Schneider; Jesse St. Laurent; Steve Bellenot; Ray W. Hiltbrand; Jennifer Witham; Gert-Jan Hagenaars; and Casper Dik. A Practical Guide to Ubuntu Linux® is based in part on two of my previous UNIX books: UNIX System V: A Practical Guide and A Practical Guide to the UNIX System. Many people helped me with those books, and thanks here go to Pat Parseghian; Dr. Kathleen Hemenway; Brian LaRose; Byron A. Jeff, Clark Atlanta University; Charles Stross; Jeff Gitlin, Lucent Technologies; Kurt Hockenbury; Maury Bach, Intel
Thanks
xlv
Israel; Peter H. Salus; Rahul Dave, University of Pennsylvania; Sean Walton, Intelligent Algorithmic Solutions; Tim Segall, Computer Sciences Corporation; Behrouz Forouzan, DeAnza College; Mike Keenan, Virginia Polytechnic Institute and State University; Mike Johnson, Oregon State University; Jandelyn Plane, University of Maryland; Arnold Robbins and Sathis Menon, Georgia Institute of Technology; Cliff Shaffer, Virginia Polytechnic Institute and State University; and Steven Stepanek, California State University, Northridge, for reviewing the book. I continue to be grateful to the many people who helped with the early editions of my UNIX books. Special thanks are due to Roger Sippl, Laura King, and Roy Harrington for introducing me to the UNIX system. My mother, Dr. Helen Sobell, provided invaluable comments on the original manuscript at several junctures. Also, thanks go to Isaac Rabinovitch, Professor Raphael Finkel, Professor Randolph Bentson, Bob Greenberg, Professor Udo Pooch, Judy Ross, Dr. Robert Veroff, Dr. Mike Denny, Joe DiMartino, Dr. John Mashey, Diane Schulz, Robert Jung, Charles Whitaker, Don Cragun, Brian Dougherty, Dr. Robert Fish, Guy Harris, Ping Liao, Gary Lindgren, Dr. Jarrett Rosenberg, Dr. Peter Smith, Bill Weber, Mike Bianchi, Scooter Morris, Clarke Echols, Oliver Grillmeyer, Dr. David Korn, Dr. Scott Weikart, and Dr. Richard Curtis. Finally, thanks to Peter and his family for providing nourishment and a very comfortable place to work. I spent many hours reading the manuscript at JumpStart, Peter’s neighborhood coffee and sandwich shop. If you are in the neighborhood (24th & Guerrero in San Francisco), stop by and say “Hi.” I take responsibility for any errors and omissions in this book. If you find one or just have a comment, let me know ([email protected]) and I will fix it in the next printing. My home page (www.sobell.com) contains a list of errors and credits those who found them. It also offers copies of the longer scripts from the book and pointers to interesting Linux pages on the Internet. Mark G. Sobell San Francisco, California
This page intentionally left blank
1 Welcome to Linux In This Chapter The GNU–Linux Connection . . . . . . . 2 The Linux 2.6 Kernel . . . . . . . . . . . . . 5 The Heritage of Linux: UNIX . . . . . . . 5 What Is So Good About Linux?. . . . . 6 Overview of Linux . . . . . . . . . . . . . . 10 Additional Features of Linux. . . . . . 15 Conventions Used in This Book . . . 17
The Linux kernel was developed by Finnish undergraduate student Linus Torvalds, who used the Internet to make the source code immediately available to others for free. Torvalds released Linux version 0.01 in September 1991. Chapter1 1
The new operating system came together through a lot of hard work. Programmers around the world were quick to extend the kernel and develop other tools, adding functionality to match that already found in both BSD UNIX and System V UNIX (SVR4) as well as new functionality. The Linux operating system, which was developed through the cooperation of many, many people around the world, is a product of the Internet and is a free operating system. In other words, all the source code is free. You are free to study it, redistribute it, and modify it. As a result, the code is available free of cost—no charge for the software, source, documentation, or support (via newsgroups, mailing lists, and other
1
2 Chapter 1 Welcome to Linux
Internet resources). As the GNU Free Software Definition (reproduced in Appendix D) puts it: Free beer
“Free software” is a matter of liberty, not price. To understand the concept, you should think of “free” as in “free speech,” not as in “free beer.”
The GNU–Linux Connection An operating system is the low-level software that schedules tasks, allocates storage, and handles the interfaces to peripheral hardware, such as printers, disk drives, the screen, keyboard, and mouse. An operating system has two main parts: the kernel and the system programs. The kernel allocates machine resources—including memory, disk space, and CPU (page 1031) cycles—to all other programs that run on the computer. The system programs perform higher-level housekeeping tasks, often acting as servers in a client/server relationship. Linux is the name of the kernel that Linus Torvalds presented to the world in 1991 and that many others have worked on since then to enhance, stabilize, expand, and make more secure.
The History of GNU–Linux This section presents some background on the relationship between GNU and Linux.
Fade to 1983 Richard Stallman (www.stallman.org) announced1 the GNU Project for creating an operating system, both kernel and system programs, and presented the GNU Manifesto,2 which begins as follows: GNU, which stands for Gnu’s Not UNIX, is the name for the complete UNIX-compatible software system which I am writing so that I can give it away free to everyone who can use it. Some years later, Stallman added a footnote to the preceding sentence when he realized that it was creating confusion: The wording here was careless. The intention was that nobody would have to pay for *permission* to use the GNU system. But the words don’t make this clear, and people often interpret them as saying that copies of GNU should always be distributed at little or no charge. That was never the intent; later on, the manifesto mentions the possibility of companies providing the service of distribution for a profit. Subsequently I have learned to distinguish
1. www.gnu.org/gnu/initial-announcement.html 2. www.gnu.org/gnu/manifesto.html
The GNU–Linux Connection
3
carefully between “free” in the sense of freedom and “free” in the sense of price. Free software is software that users have the freedom to distribute and change. Some users may obtain copies at no charge, while others pay to obtain copies—and if the funds help support improving the software, so much the better. The important thing is that everyone who has a copy has the freedom to cooperate with others in using it. In the manifesto, after explaining a little about the project and what has been accomplished so far, Stallman continues: Why I Must Write GNU I consider that the golden rule requires that if I like a program I must share it with other people who like it. Software sellers want to divide the users and conquer them, making each user agree not to share with others. I refuse to break solidarity with other users in this way. I cannot in good conscience sign a nondisclosure agreement or a software license agreement. For years I worked within the Artificial Intelligence Lab to resist such tendencies and other inhospitalities, but eventually they had gone too far: I could not remain in an institution where such things are done for me against my will. So that I can continue to use computers without dishonor, I have decided to put together a sufficient body of free software so that I will be able to get along without any software that is not free. I have resigned from the AI Lab to deny MIT any legal excuse to prevent me from giving GNU away.
Next Scene, 1991 The GNU Project has moved well along toward its goal. Much of the GNU operating system, except for the kernel, is complete. Richard Stallman later writes: By the early ’90s we had put together the whole system aside from the kernel (and we were also working on a kernel, the GNU Hurd,3 which runs on top of Mach4). Developing this kernel has been a lot harder than we expected, and we are still working on finishing it.5 ...[M]any believe that once Linus Torvalds finished writing the kernel, his friends looked around for other free software, and for no particular reason most everything necessary to make a UNIX-like system was already available.
3. www.gnu.org/software/hurd/hurd.html 4. www.gnu.org/software/hurd/gnumach.html 5. www.gnu.org/software/hurd/hurd-and-linux.html
4 Chapter 1 Welcome to Linux
What they found was no accident—it was the GNU system. The available free software6 added up to a complete system because the GNU Project had been working since 1984 to make one. The GNU Manifesto had set forth the goal of developing a free UNIX-like system, called GNU. The Initial Announcement of the GNU Project also outlines some of the original plans for the GNU system. By the time Linux was written, the [GNU] system was almost finished.7 Today the GNU “operating system” runs on top of the FreeBSD (www.freebsd.org) and NetBSD (www.netbsd.org) kernels with complete Linux binary compatibility and on top of Hurd pre-releases and Darwin (developer.apple.com/opensource) without this compatibility.
The Code Is Free The tradition of free software dates back to the days when UNIX was released to universities at nominal cost, which contributed to its portability and success. This tradition died as UNIX was commercialized and manufacturers regarded the source code as proprietary, making it effectively unavailable. Another problem with the commercial versions of UNIX related to their complexity. As each manufacturer tuned UNIX for a specific architecture, it became less portable and too unwieldy for teaching and experimentation. MINIX
Two professors created their own stripped-down UNIX look-alikes for educational purposes: Doug Comer created XINU and Andrew Tanenbaum created MINIX. Linus Torvalds created Linux to counteract the shortcomings in MINIX. Every time there was a choice between code simplicity and efficiency/features, Tanenbaum chose simplicity (to make it easy to teach with MINIX), which meant this system lacked many features people wanted. Linux goes in the opposite direction. You can obtain Linux at no cost over the Internet (page 37). You can also obtain the GNU code via the U.S. mail at a modest cost for materials and shipping. You can support the Free Software Foundation (www.fsf.org) by buying the same (GNU) code in higher-priced packages, and you can buy commercial packaged releases of Linux (called distributions), such as Ubuntu Linux, that include installation instructions, software, and support.
GPL
Linux and GNU software are distributed under the terms of the GNU General Public License (GPL, www.gnu.org/licenses/licenses.html). The GPL says you have the right to copy, modify, and redistribute the code covered by the agreement. When you redistribute the code, however, you must also distribute the same license with the code, thereby making the code and the license inseparable. If you get source code off the Internet for an accounting program that is under the GPL and then
6. See Appendix D or www.gnu.org/philosophy/free-sw.html. 7. www.gnu.org/gnu/linux-and-gnu.html
The Heritage of Linux: UNIX
5
modify that code and redistribute an executable version of the program, you must also distribute the modified source code and the GPL agreement with it. Because this arrangement is the reverse of the way a normal copyright works (it gives rights instead of limiting them), it has been termed a copyleft. (This paragraph is not a legal interpretation of the GPL; it is intended merely to give you an idea of how it works. Refer to the GPL itself when you want to make use of it.)
Have Fun! Two key words for Linux are “Have Fun!” These words pop up in prompts and documentation. The UNIX—now Linux—culture is steeped in humor that can be seen throughout the system. For example, less is more—GNU has replaced the UNIX paging utility named more with an improved utility named less. The utility to view PostScript documents is named ghostscript, and one of several replacements for the vi editor is named elvis. While machines with Intel processors have “Intel Inside” logos on their outside, some Linux machines sport “Linux Inside” logos. And Torvalds himself has been seen wearing a T-shirt bearing a “Linus Inside” logo.
The Linux 2.6 Kernel The Linux 2.6 kernel was released on December 17, 2003. This kernel has many features that offer increased security and speed. Some of these features benefit end users directly; others help developers produce better code and find problems more quickly. See Appendix E for a description of the features introduced in the Linux 2.6 kernel.
The Heritage of Linux: UNIX The UNIX system was developed by researchers who needed a set of modern computing tools to help them with their projects. The system allowed a group of people working together on a project to share selected data and programs while keeping other information private. Universities and colleges played a major role in furthering the popularity of the UNIX operating system through the “four-year effect.” When the UNIX operating system became widely available in 1975, Bell Labs offered it to educational institutions at nominal cost. The schools, in turn, used it in their computer science programs, ensuring that computer science students became familiar with it. Because UNIX was such an advanced development system, the students became acclimated to a sophisticated programming environment. As these students graduated and went into industry, they expected to work in a similarly advanced environment. As more of them worked their way up the ladder in the commercial world, the UNIX operating system found its way into industry.
6 Chapter 1 Welcome to Linux
In addition to introducing students to the UNIX operating system, the Computer Systems Research Group (CSRG) at the University of California at Berkeley made significant additions and changes to it. In fact, it made so many popular changes that one version of the system is called the Berkeley Software Distribution (BSD) of the UNIX system (or just Berkeley UNIX). The other major version is UNIX System V (SVR4), which descended from versions developed and maintained by AT&T and UNIX System Laboratories.
What Is So Good About Linux? In recent years Linux has emerged as a powerful and innovative UNIX work-alike. Its popularity is surpassing that of its UNIX predecessors. Although it mimics UNIX in many ways, the Linux operating system departs from UNIX in several significant ways: The Linux kernel is implemented independently of both BSD and System V, the continuing development of Linux is taking place through the combined efforts of many capable individuals throughout the world, and Linux puts the power of UNIX within easy reach of both business and personal computer users. Using the Internet, today’s skilled programmers submit additions and improvements to the operating system to Linus Torvalds, GNU, or one of the other authors of Linux. Applications
A rich selection of applications is available for Linux—both free and commercial— as well as a wide variety of tools: graphical, word processing, networking, security, administration, Web server, and many others. Large software companies have recently seen the benefit in supporting Linux and now have on-staff programmers whose job it is to design and code the Linux kernel, GNU, KDE, or other software that runs on Linux. For example, IBM (www.ibm.com/linux) is a major Linux supporter. Linux conforms increasingly more closely to POSIX standards, and some distributions and parts of others meet this standard. (See “Standards” on page 9.) These developments indicate that Linux is becoming more mainstream and is respected as an attractive alternative to other popular operating systems.
Peripherals
Another aspect of Linux that appeals to users is the amazing range of peripherals that is supported and the speed with which support for new peripherals emerges. Linux often supports a peripheral or interface card before any company does. Unfortunately some types of peripherals—particularly proprietary graphics cards—lag in their support because the manufacturers do not release specifications or source code for drivers in a timely manner, if at all.
Software
Also important to users is the amount of software that is available—not just source code (which needs to be compiled) but also prebuilt binaries that are easy to install and ready to run. These include more than free software. Netscape, for example, has been available for Linux from the start and included Java support before it was available from many commercial vendors. Now its sibling Mozilla/Thunderbird/ Firefox is also a viable browser, mail client, and newsreader, performing many other functions as well.
What Is So Good About Linux? 7 Platforms
Linux is not just for Intel-based platforms: It has been ported to and runs on the Power PC—including Apple computers (ppclinux), Compaq’s (née Digital Equipment Corporation) Alpha-based machines, MIPS-based machines, Motorola’s 68K-based machines, various 64-bit systems, and IBM’s S/390. Nor is Linux just for single-processor machines: As of version 2.0, it runs on multiple-processor machines (SMPs). It also includes an O(1) scheduler, which dramatically increases scalability on SMP systems.
Emulators
Linux supports programs, called emulators, that run code intended for other operating systems. By using emulators you can run some DOS, Windows, and Macintosh programs under Linux. For example, Wine (www.winehq.com) is an open-source implementation of the Windows API on top of the X Window System and UNIX/Linux; QEMU (fabrice.bellard.free.fr/qemu) is a CPU-only emulator that executes x86 Linux binaries on non-x86 Linux systems.
Xen
Xen, which was created at the University of Cambridge and is now being developed in the open-source community, is an open-source virtual machine monitor (VMM). A VMM enables several virtual machines (VMs), each running an instance of a separate operating system, to run on a single computer. Xen isolates the VMs so that if one crashes it does not affect the others. In addition, Xen introduces minimal performance overhead when compared with running each of the operating systems natively. Using VMs, you can experiment with cutting-edge releases of operating systems and applications without concern for the base (stable) system, all on a single machine. You can also set up and test networks of systems on a single machine. Xen presents a sandbox, an area (system) that you can work in without regard for the results of your work or for the need to clean up. The Gutsy release of Ubuntu supports Xen 3.1. This book does not cover the installation or use of Xen. See help.ubuntu.com/community/Xen for information on running Xen under Ubuntu. For more information on Xen, refer to the wiki at wiki.xensource.com/xenwiki and the Xen home page at www.cl.cam.ac.uk/research/srg/netos/xen.
KVM and VirtualBox
If you want to run a virtual instance of Windows, you may want to investigate KVM (Kernel Virtual Machine, help.ubuntu.com/community/KVM) and VirtualBox (www.virtualbox.org).
Why Linux Is Popular with Hardware Companies and Developers Two trends in the computer industry set the stage for the growing popularity of UNIX and Linux. First, advances in hardware technology created the need for an operating system that could take advantage of available hardware power. In the mid-1970s, minicomputers began challenging the large mainframe computers because, in many applications, minicomputers could perform the same functions less expensively. More recently, powerful 64-bit processor chips, plentiful and inexpensive memory, and lower-priced hard disk storage have allowed hardware companies to install multiuser operating systems on desktop computers.
8 Chapter 1 Welcome to Linux Proprietary operating systems
Second, with the cost of hardware continually dropping, hardware manufacturers could no longer afford to develop and support proprietary operating systems. A proprietary operating system is one that is written and owned by the manufacturer of the hardware (for example, DEC/Compaq owns VMS). Today’s manufacturers need a generic operating system that they can easily adapt to their machines.
Generic operating systems
A generic operating system is written outside of the company manufacturing the hardware and is sold (UNIX, Windows) or given (Linux) to the manufacturer. Linux is a generic operating system because it runs on different types of hardware produced by different manufacturers. Of course, if manufacturers can pay only for development and avoid per-unit costs (as they have to pay to Microsoft for each copy of Windows they sell), manufacturers are much better off. In turn, software developers need to keep the prices of their products down; they cannot afford to convert their products to run under many different proprietary operating systems. Like hardware manufacturers, software developers need a generic operating system. Although the UNIX system once met the needs of hardware companies and researchers for a generic operating system, over time it has become more proprietary as manufacturers added support for their own specialized features and introduced new software libraries and utilities. Linux emerged to serve both needs: It is a generic operating system that takes advantage of available hardware power.
Linux Is Portable A portable operating system is one that can run on many different machines. More than 95 percent of the Linux operating system is written in the C programming language, and C is portable because it is written in a higher-level, machine-independent language. (The C compiler is written in C.) Because Linux is portable, it can be adapted (ported) to different machines and can meet special requirements. For example, Linux is used in embedded computers, such as the ones found in cellphones, PDAs, and the cable boxes on top of many TVs. The file structure takes full advantage of large, fast hard disks. Equally important, Linux was originally designed as a multiuser operating system—it was not modified to serve several users as an afterthought. Sharing the computer’s power among many users and giving them the ability to share data and programs are central features of the system. Because it is adaptable and takes advantage of available hardware, Linux runs on many different microprocessor-based systems as well as mainframes. The popularity of the microprocessor-based hardware drives Linux; these microcomputers are getting faster all the time, at about the same price point. Linux on a fast microcomputer has become good enough to displace workstations on many desktops. Linux benefits both users, who do not like having to learn a new operating system for each vendor’s hardware, and system administrators, who like having a consistent software environment.
What Is So Good About Linux? 9
The advent of a standard operating system has aided the development of the software industry. Now software manufacturers can afford to make one version of a product available on machines from different manufacturers.
Standards Individuals from companies throughout the computer industry have joined together to develop the POSIX (Portable Operating System Interface for Computer Environments) standard, which is based largely on the UNIX System V Interface Definition (SVID) and other earlier standardization efforts. These efforts have been spurred by the U.S. government, which needs a standard computing environment to minimize its training and procurement costs. Now that these standards are gaining acceptance, software developers are able to develop applications that run on all conforming versions of UNIX, Linux, and other operating systems.
The C Programming Language Ken Thompson wrote the UNIX operating system in 1969 in PDP-7 assembly language. Assembly language is machine dependent: Programs written in assembly language work on only one machine or, at best, on one family of machines. The original UNIX operating system therefore could not easily be transported to run on other machines (it was not portable). To make UNIX portable, Thompson developed the B programming language, a machine-independent language, from the BCPL language. Dennis Ritchie developed the C programming language by modifying B and, with Thompson, rewrote UNIX in C in 1973. The revised operating system could be transported more easily to run on other machines. That development marked the start of C. Its roots reveal some of the reasons why it is such a powerful tool. C can be used to write machine-independent programs. A programmer who designs a program to be portable can easily move it to any computer that has a C compiler. C is also designed to compile into very efficient code. With the advent of C, a programmer no longer had to resort to assembly language to get code that would run well (that is, quickly—although an assembler will always generate more efficient code than a high-level language). C is a good systems language. You can write a compiler or an operating system in C. It is highly structured but is not necessarily a high-level language. C allows a programmer to manipulate bits and bytes, as is necessary when writing an operating system. But it also has high-level constructs that allow for efficient, modular programming. In the late 1980s the American National Standards Institute (ANSI) defined a standard version of the C language, commonly referred to as ANSI C or C89 (for the year the standard was published). Ten years later the C99 standard was published; it is mostly supported by the GNU Project’s C compiler (named gcc). The original version of the language is often referred to as Kernighan & Ritchie (or K&R) C, named for the authors of the book that first described the C language.
10 Chapter 1 Welcome to Linux
Another researcher at Bell Labs, Bjarne Stroustrup, created an object-oriented programming language named C++, which is built on the foundation of C. Because object-oriented programming is desired by many employers today, C++ is preferred over C in many environments. Another language of choice is Objective-C, which was used to write the first Web browser. The GNU Project’s C compiler supports C, C++, and Objective-C.
Ubuntu Linux From its first release in October 2004, Ubuntu has been a community-oriented project. Ubuntu maintains several structures to keep it functioning effectively, with community members invited to participate in all structures. For more information about Ubuntu governance, see www.ubuntu.com/community/processes/governance. Ubuntu Linux, which is sponsored by Canonical Ltd. (www.canonical.com), is based on the Debian Linux and focuses on enhancing usability, accessibility, and internationalization. Although Ubuntu initially targeted the desktop user, recent releases have put increasing emphasis on the server market. With a new release scheduled every six months, Ubuntu provides cutting-edge software. An Ubuntu system uses the GNOME desktop manager (www.gnome.org) and includes the OpenOffice.org suite of productivity tools, the Firefox Web browser, the Pidgin (formerly Gaim) IM client, and an assortment of tools and games. To keep software on a system up-to-date, Ubuntu uses Debian’s deb package format and various APT-based tools. Ubuntu distributes and supports many versions of its Linux distribution. For example, Kubuntu (www.kubuntu.org) runs the KDE desktop manager, Edubuntu (www.edubuntu.org) includes many school-related applications, and Xubuntu (www.xubuntu.org) runs the lightweight Xfce desktop, which makes it ideal for older, slower machines. For more information about Ubuntu, see www.ubuntu.com/aboutus/faq.
Overview of Linux The Linux operating system has many unique and powerful features. Like other operating systems, it is a control program for computers. But like UNIX, it is also a well-thought-out family of utility programs (Figure 1-1) and a set of tools that allow users to connect and use these utilities to build systems and applications.
Linux Has a Kernel Programming Interface The Linux kernel—the heart of the Linux operating system—is responsible for allocating the computer’s resources and scheduling user jobs so that each one gets its fair share of system resources, including access to the CPU; peripheral devices, such as hard disk, DVD, and CD-ROM storage; printers; and tape drives. Programs interact with the kernel through system calls, special functions with well-known names. A programmer can use a single system call to interact with many kinds of
Overview of Linux
Compilers
Database Management Systems
Word Processors
Mail and Message Facilities
11
Shells
Linux Kernel
Hardware Figure 1-1
A layered view of the Linux operating system
devices. For example, there is one write() system call, not many device-specific ones. When a program issues a write() request, the kernel interprets the context and passes the request to the appropriate device. This flexibility allows old utilities to work with devices that did not exist when the utilities were written. It also makes it possible to move programs to new versions of the operating system without rewriting them (provided that the new version recognizes the same system calls). See page 1015 for information on the Linux 2.6 kernel.
Linux Can Support Many Users Depending on the hardware and the types of tasks that the computer performs, a Linux system can support from 1 to more than 1,000 users, each concurrently running a different set of programs. The per-user cost of a computer that can be used by many people at the same time is less than that of a computer that can be used by only a single person at a time. It is less because one person cannot generally take advantage of all the resources a computer has to offer. That is, no one can keep all the printers going constantly, keep all the system memory in use, keep all the disks busy reading and writing, keep the Internet connection in use, and keep all the terminals busy at the same time. By contrast, a multiuser operating system allows many people to use all of the system resources almost simultaneously. The use of costly resources can be maximized and the cost per user can be minimized—the primary objectives of a multiuser operating system.
Linux Can Run Many Tasks Linux is a fully protected multitasking operating system, allowing each user to run more than one job at a time. Processes can communicate with one another but remain fully protected from one another, just as the kernel remains protected from all processes. You can run several jobs in the background while giving all your attention to the job being displayed on the screen, and you can switch back and forth between jobs. If you are running the X Window System (page 15), you can run different programs in different windows on the same screen and watch all of them. This capability ensures that users can be more productive.
12 Chapter 1 Welcome to Linux
Linux Provides a Secure Hierarchical Filesystem A file is a collection of information, such as text for a memo or report, an accumulation of sales figures, an image, a song, or an executable program. Each file is stored under a unique identifier on a storage device, such as a hard disk. The Linux filesystem provides a structure whereby files are arranged under directories, which are like folders or boxes. Each directory has a name and can hold other files and directories. Directories, in turn, are arranged under other directories, and so forth, in a treelike organization. This structure helps users keep track of large numbers of files by grouping related files in directories. Each user has one primary directory and as many subdirectories as required (Figure 1-2). Standards
With the idea of making life easier for system administrators and software developers, a group got together over the Internet and developed the Linux Filesystem Standard (FSSTND), which has since evolved into the Linux Filesystem Hierarchy Standard (FHS). Before this standard was adopted, key programs were located in different places in different Linux distributions. Today you can sit down at a Linux system and know where to expect to find any given standard program (page 194).
Links
A link allows a given file to be accessed by means of two or more names. The alternative names can be located in the same directory as the original file or in another directory. Links can make the same file appear in several users’ directories, enabling those users to share the file easily. Windows uses the term shortcut in place of link to describe this capability. Macintosh users will be more familiar with the term alias. Under Linux, an alias is different from a link; it is a command macro feature provided by the shell (page 328).
Security
Like most multiuser operating systems, Linux allows users to protect their data from access by other users. It also allows users to share selected data and programs with certain other users by means of a simple but effective protection scheme. This level of security is provided by file access permissions, which limit which users can read from, write to, or execute a file. More recently, Linux has implemented Access Control Lists (ACLs), which give users and administrators finer-grained control over file access permissions.
The Shell: Command Interpreter and Programming Language In a textual environment, the shell—the command interpreter—acts as an interface between you and the operating system. When you enter a command on the screen, the shell interprets the command and calls the program you want. A number of shells are available for Linux. The three most popular shells are • The Bourne Again Shell (bash), an enhanced version of the original Bourne Shell (the original UNIX shell). • The TC Shell (tcsh), an enhanced version of the C Shell, developed as part of BSD UNIX. • The Z Shell (zsh), which incorporates features from a number of shells, including the Korn Shell.
Overview of Linux
13
/
home
tmp
etc
alex
jenny
hls
bin
report
Figure 1-2
notes
log
The Linux filesystem structure
Because different users may prefer different shells, multiuser systems can have several different shells in use at any given time. The choice of shells demonstrates one of the advantages of the Linux operating system: the ability to provide a customized interface for each user. Shell scripts
Besides performing its function of interpreting commands from a keyboard and sending those commands to the operating system, the shell is a high-level programming language. Shell commands can be arranged in a file for later execution (Linux calls these files shell scripts; Windows calls them batch files). This flexibility allows users to perform complex operations with relative ease, often with rather short commands, or to build with surprisingly little effort elaborate programs that perform highly complex operations.
Filename Generation Wildcards and ambiguous file references
When you type commands to be processed by the shell, you can construct patterns using characters that have special meanings to the shell. These characters are called wildcard characters. The patterns, which are called ambiguous file references, are a kind of shorthand: Rather than typing in complete filenames, users can type patterns; the shell expands these patterns into matching filenames. An ambiguous file reference can save you the effort of typing in a long filename or a long series of similar filenames. For example, the shell might expand the pattern mak* to make-3.80.tar.gz. Patterns can also be useful when you know only part of a filename or cannot remember the exact spelling.
Device-Independent Input and Output Redirection
Devices (such as a printer or a terminal) and disk files appear as files to Linux programs. When you give a command to the Linux operating system, you can instruct it to send the output to any one of several devices or files. This diversion is called output redirection.
14 Chapter 1 Welcome to Linux Device independence
In a similar manner, a program’s input that normally comes from a keyboard can be redirected so that it comes from a disk file instead. Input and output are device independent; that is, they can be redirected to or from any appropriate device. As an example, the cat utility normally displays the contents of a file on the screen. When you run a cat command, you can easily cause its output to go to a disk file instead of the screen.
Shell Functions One of the most important features of the shell is that users can use it as a programming language. Because the shell is an interpreter, it does not compile programs written for it but rather interprets programs each time they are loaded from the disk. Loading and interpreting programs can be time-consuming. Many shells, including the Bourne Again Shell, include shell functions that the shell holds in memory so it does not have to read them from the disk each time you execute them. The shell also keeps functions in an internal format so that it does not have to spend as much time interpreting them.
Job Control Job control is a shell feature that allows users to work on several jobs at once, switching back and forth between them as desired. When you start a job, it is frequently run in the foreground so it is connected to the terminal. Using job control, you can move the job you are working with into the background and continue running it there while working on or observing another job in the foreground. If a background job then needs your attention, you can move it into the foreground so that it is once again attached to the terminal. The concept of job control originated with BSD UNIX, where it appeared in the C Shell.
A Large Collection of Useful Utilities Linux includes a family of several hundred utility programs, often referred to as commands. These utilities perform functions that are universally required by users. The sort utility, for example, puts lists (or groups of lists) in alphabetical or numerical order and can be used to sort lists by part number, last name, city, ZIP code, telephone number, age, size, cost, and so forth. The sort utility is an important programming tool and is part of the standard Linux system. Other utilities allow users to create, display, print, copy, search, and delete files as well as to edit, format, and typeset text. The man (for manual) and info utilities provide online documentation for Linux itself.
Interprocess Communication Pipes and filters
Linux allows users to establish both pipes and filters on the command line. A pipe sends the output of one program to another program as input. A filter is a special
Additional Features of Linux
15
kind of pipe that processes a stream of input data to yield a stream of output data. A filter processes another program’s output, altering it as a result. The filter’s output then becomes input to another program. Pipes and filters frequently join utilities to perform a specific task. For example, you can use a pipe to send the output of the cat utility to sort (a filter) and then use another pipe to send the output of sort to a third utility, lpr, that sends the data to a printer. Thus, in one command line, you can use three utilities together to sort and print a file.
System Administration On a Linux system the system administrator is frequently the owner and only user of the system. This person has many responsibilities. The first responsibility may be to set up the system and install the software. Once the system is up and running, the system administrator is responsible for downloading and installing software (including upgrading the operating system), backing up and restoring files, and managing such system facilities as printers, terminals, servers, and a local network. The system administrator is also responsible for setting up accounts for new users on a multiuser system, bringing the system up and down as needed, and taking care of any problems that arise.
Additional Features of Linux The developers of Linux included features from BSD, System V, and Sun Microsystems’ Solaris, as well as new features, in their operating system. Although most of the tools found on UNIX exist for Linux, in some cases these tools have been replaced by more modern counterparts. This section describes some of the popular tools and features available under Linux.
GUIs: Graphical User Interfaces The X Window System (also called X or X11) was developed in part by researchers at MIT (Massachusetts Institute of Technology) and provides the foundation for the GUIs available with Linux. Given a terminal or workstation screen that supports X, a user can interact with the computer through multiple windows on the screen, display graphical information, or use special-purpose applications to draw pictures, monitor processes, or preview formatted output. X is an across-the-network protocol that allows a user to open a window on a workstation or computer system that is remote from the CPU generating the window. Desktop manager
Usually two layers run under X: a desktop manager and a window manager. A desktop manager is a picture-oriented user interface that enables you to interact with system programs by manipulating icons instead of typing the corresponding
16 Chapter 1 Welcome to Linux
Figure 1-3
A GNOME workspace
commands to a shell. Ubuntu runs GNOME (Figure 1-3; www.gnome.org) by default, but it can also run KDE (www.kde.org) and a number of other desktop managers. Window manager
A window manager is a program that runs under the desktop manager and allows you to open and close windows, run programs, and set up a mouse so it has different effects depending on how and where you click. The window manager also gives the screen its personality. Whereas Microsoft Windows allows you to change the color of key elements in a window, a window manager under X allows you to customize the overall look and feel of the screen: You can change the way a window looks and works (by giving it different borders, buttons, and scrollbars), set up virtual desktops, create menus, and more. Several popular window managers run under X and Linux. Ubuntu Linux provides both Metacity (the default under GNOME) and kwin (the default under KDE). Other window managers, such as Sawfish and WindowMaker, are also available. Chapters 4 and 8 present information on GUIs.
(Inter)Networking Utilities Linux network support includes many utilities that enable you to access remote systems over a variety of networks. In addition to sending email to users on other systems, you can access files on disks mounted on other computers as if they were located on the local system, make your files available to other systems in a similar
Conventions Used in This Book 17
manner, copy files back and forth, run programs on remote systems while displaying the results on the local system, and perform many other operations across local area networks (LANs) and wide area networks (WANs), including the Internet. Layered on top of this network access is a wide range of application programs that extend the computer’s resources around the globe. You can carry on conversations with people throughout the world, gather information on a wide variety of subjects, and download new software over the Internet quickly and reliably. Chapter 10 discusses networks, the Internet, and the Linux network facilities.
Software Development One of Linux’s most impressive strengths is its rich software development environment. You can find compilers and interpreters for many computer languages. Besides C and C++, languages available for Linux include Ada, Fortran, Java, Lisp, Pascal, Perl, and Python. The bison utility generates parsing code that makes it easier to write programs to build compilers (tools that parse files containing structured information). The flex utility generates scanners (code that recognizes lexical patterns in text). The make utility and the GNU Configure and Build System make it easier to manage complex development projects. Source code management systems, such as CVS, simplify version control. Several debuggers, including ups and gdb, can help track down and repair software defects. The GNU C compiler (gcc) works with the gprof profiling utility to help programmers identify potential bottlenecks in a program’s performance. The C compiler includes options to perform extensive checking of C code, thereby making the code more portable and reducing debugging time. Table B-4 on page 987 lists some sites you can download software from.
Conventions Used in This Book This book uses conventions to make its explanations shorter and clearer. The following paragraphs describe these conventions. Widgets
A widget is a simple graphical element that a user interacts with, such as a text box, radio button, or combo box. When referring to a widget, this book specifies the type of widget and its label. The term “tick” refers to the mark you put in a check box, sometimes called a check mark. For example, “put a tick in the check box labeled Run in terminal (click the box to put a tick in it; click again to remove the tick).” See the glossary for definitions of various widgets.
Tabs and frames
Tabs allow windows to display sets of related information, one set at a time. For example, Figure 4-11 on page 102 shows the Appearance Preferences window, which has five tabs; the Background tab is highlighted. A frame isolates a set of information within a window. Figure 4-11 shows the Wallpaper frame, which allows you to select one of several wallpapers.
Menu selection path
The menu selection path is the name of the menu or the location of the menu, followed by a colon, a SPACE, and the menu selections separated by D markers. The entire
18 Chapter 1 Welcome to Linux
menu selection path is in bold type. You can read Main menu: SystemDPreferencesD Appearance as “From the Main menu, select System; from System, select Preferences; and then select Appearance.” Text and examples
The text is set in this type, whereas examples are shown in a called a fixed-width font):
monospaced font
(also
$ cat practice This is a small file I created with a text editor. Items you enter
Everything you enter at the keyboard is shown in a bold typeface. Within the text, this bold typeface is used; within examples and screens, this one is used. In the previous example, the dollar sign ($) on the first line is a prompt that Linux displays, so it is not bold; the remainder of the first line is entered by a user, so it is bold.
Utility names
Names of utilities are printed in this bold sans serif typeface. This book references the emacs text editor and the ls utility or ls command (or just ls) but instructs you to enter ls –a on the command line. In this way the text distinguishes between utilities, which are programs, and the instructions you give on the command line to invoke the utilities.
Filenames
Filenames appear in a bold typeface. Examples are memo5, letter.1283, and reports. Filenames may include uppercase and lowercase letters; however, Linux is case sensitive (page 1027), so memo5, MEMO5, and Memo5 name three different files.
Character strings
Within the text, characters and character strings are marked by putting them in a bold typeface. This convention avoids the need for quotation marks or other delimiters before and after a string. An example is the following string, which is displayed by the passwd utility: Sorry, passwords do not match.
Buttons and labels
Words appear in a bold typeface in the sections of the book that describe a GUI. This font indicates that you can click a mouse button when the mouse pointer is over these words on the screen or over a button with this name: Click Next.
Keys and characters
This book uses SMALL CAPS for three kinds of items: • Keyboard keys, such as the SPACE bar and the RETURN,8 ESCAPE, and TAB keys. • The characters that keys generate, such as the SPACEs generated by the SPACE bar. • Keyboard keys that you press with the CONTROL key, such as CONTROL-D. (Even though D is shown as an uppercase letter, you do not have to press the SHIFT key; enter CONTROL-D by holding the CONTROL key down and pressing d.)
8. Different keyboards use different keys to move the cursor (page 1032) to the beginning of the next line. This book always refers to the key that ends a line as the RETURN key. Your keyboard may have a RET, NEWLINE, ENTER, RETURN , or other key. Use the corresponding key on your keyboard each time this book asks you to press RETURN.
Conventions Used in This Book 19 Prompts and RETURNs
Most examples include the shell prompt—the signal that Linux is waiting for a command—as a dollar sign ($), a pound sign (#), or sometimes a percent sign (%). The prompt is not in a bold typeface because you do not enter it. Do not type the prompt on the keyboard when you are experimenting with examples from this book. If you do, the examples will not work. Examples omit the RETURN keystroke that you must use to execute them. An example of a command line is $ vim memo.1204
To use this example as a model for running the vim text editor, give the command vim memo.1204 and press the RETURN key. (Press ESCAPE ZZ to exit from vim; see page 172 for a vim tutorial.) This method of entering commands makes the examples in the book correspond to what appears on the screen. Definitions
optional
All glossary entries marked with FOLDOC are courtesy of Denis Howe, editor of the Free Online Dictionary of Computing (foldoc.org), and are used with permission. This site is an ongoing work containing definitions, anecdotes, and trivia.
Optional Information Passages marked as optional appear in a gray box. This material is not central to the ideas presented in the chapter but often involves more challenging concepts. A good strategy when reading a chapter is to skip the optional sections and then return to them when you are comfortable with the main ideas presented in the chapter. This is an optional paragraph.
URLs (Web addresses)
Web addresses, or URLs, have an implicit http:// prefix, unless ftp:// or https:// is shown. You do not normally need to specify a prefix when the prefix is http://, but you must use a prefix from a browser when you specify an FTP or secure HTTP site. Thus you can specify a URL in a browser exactly as shown in this book.
Tip, caution, and security boxes
The following boxes highlight information that may be helpful while you are using or administrating a Linux system.
This is a tip box tip A tip box may help you avoid repeating a common mistake or may point toward additional information. This box warns you about something caution A caution box warns you about a potential pitfall. This box marks a security note security A security box highlights a potential security issue. These notes are usually for system administrators, but some apply to all users.
20 Chapter 1 Welcome to Linux
Chapter Summary The Linux operating system grew out of the UNIX heritage to become a popular alternative to traditional systems (that is, Windows) available for microcomputer (PC) hardware. UNIX users will find a familiar environment in Linux. Distributions of Linux contain the expected complement of UNIX utilities, contributed by programmers around the world, including the set of tools developed as part of the GNU Project. The Linux community is committed to the continued development of this system. Support for new microcomputer devices and features is added soon after the hardware becomes available, and the tools available on Linux continue to be refined. Given the many commercial software packages available to run on Linux platforms and the many hardware manufacturers offering Linux on their systems, it is clear that the system has evolved well beyond its origin as an undergraduate project to become an operating system of choice for academic, commercial, professional, and personal use.
Exercises 1. What is free software? List three characteristics of free software. 2. Why is Linux popular? Why is it popular in academia? 3. What are multiuser systems? Why are they successful? 4. What is the Free Software Foundation/GNU? What is Linux? Which parts of the Linux operating system did each provide? Who else has helped build and refine this operating system? 5. In which language is Linux written? What does the language have to do with the success of Linux? 6. What is a utility program? 7. What is a shell? How does it work with the kernel? With the user? 8. How can you use utility programs and a shell to create your own applications? 9. Why is the Linux filesystem referred to as hierarchical? 10. What is the difference between a multiprocessor and a multiprocessing system? 11. Give an example of when you would want to use a multiprocessing system. 12. Approximately how many people wrote Linux? Why is this project unique? 13. What are the key terms of the GNU General Public License?
I
PART I Installing Ubuntu Linux CHAPTER 2 Installation Overview
23
CHAPTER 3 Step-by-Step Installation
45
21
This page intentionally left blank
2 Installation Overview In This Chapter More Information . . . . . . . . . . . . . . 24 Planning the Installation . . . . . . . . 25 Setting Up the Hard Disk . . . . . . . . 30 LVM: Logical Volume Manager . . . . 35 The Installation Process . . . . . . . . . 36 Downloading and Burning a CD/DVD . . . . . . . . . . . . . . . . . . . 37 Using BitTorrent . . . . . . . . . . . . . . . 39 Gathering Information About the System . . . . . . . . . . . . . . . . . . 41
Installing Ubuntu Linux is the process of copying operating system files from a CD or DVD to hard drive(s) on a system and setting up configuration files so that Linux runs properly on the hardware. Several types of installations are possible, including fresh installations, upgrades from older releases of Ubuntu Linux, and dual-boot installations. Chapter2 2
This chapter discusses the installation process in general: planning, partitioning the hard disk, obtaining the files for the installation, burning a CD or a DVD, and collecting information about the hardware that may be helpful for installation and administration. Chapter 3 covers the process of installing Ubuntu. The ubiquity utility is a user-friendly, graphical tool that installs Ubuntu. To install Ubuntu Linux on standard hardware, you can typically insert the live/install Desktop CD or DVD, boot the system, and double-click Install. After you answer a few questions, you are done. However, you may want to customize the system or you may be installing on nonstandard hardware: the installer gives you choices as the installation process unfolds. Ubuntu also provides a textual installer that gives you more control over the
23
24 Chapter 2 Installation Overview
installation. Refer to “Basic Installation from the Live/Install Desktop CD/DVD” (page 46) and “Advanced Installation” (page 62) for information about installing and customizing Ubuntu Linux.
The Live/Install Desktop CD/DVD A live/install Desktop CD/DVD runs Ubuntu without installing it on the system. When you boot a live/install Desktop CD/DVD, it brings up a GNOME desktop: You are running a live session. When you exit from the live session, the system is as it was before you booted from the CD/DVD. If the system has a swap partition (most Linux systems have one; see page 32), the live session uses it to improve its performance but does not otherwise write to the hard disk. You can also install Ubuntu from a live session. Booting a live/install Desktop CD/DVD is a good way to test hardware and fix a system that will not boot from the hard disk. A live session is ideal for people who are new to Ubuntu or Linux and want to experiment with Ubuntu but are not ready to install Ubuntu on their system.
More Information In addition to the following references, see “Where to Find Documentation” on page 124 and refer to Appendix B for additional resources. Web memtest86+
www.memtest.org
gparted (GNOME Partition Editor)
gparted.sourceforge.net Hardware compatibility wiki.ubuntu.com/HardwareSupport Swap space help.ubuntu.com/community/SwapFaq Partition HOWTO tldp.org/HOWTO/Partition Upgrading www.ubuntu.com/getubuntu/upgrading Boot command line parameters help.ubuntu.com/community/BootOptions and The Linux BootPrompt-HowTo RAID en.wikipedia.org/wiki/RAID LVM Resource Page (includes many links) sourceware.org/lvm2 LVM HOWTO www.tldp.org/HOWTO/LVM-HOWTO BitTorrent help.ubuntu.com/community/BitTorrent BitTorrent azureus.sourceforge.net X.org release information wiki.x.org
Download Ubuntu
Easiest download www.ubuntu.com/getubuntu Released versions releases.ubuntu.com Older versions old-releases.ubuntu.com/releases Development images and unsupported releases cdimage.ubuntu.com Mac (PowerPC) wiki.ubuntu.com/PowerPCDownloads BitTorrent torrent files torrent.ubuntu.com/releases
Planning the Installation
25
Planning the Installation The major decision when planning an installation is determining how to divide the hard disk into partitions or, in the case of a dual-boot system, where to put the Linux partitions. Once you have installed Ubuntu, you can decide which software packages you want to add to the base system (or whether you want to remove some). In addition to these topics, this section discusses hardware requirements for Ubuntu Linux and fresh installations versus upgrades.
Considerations GUI
On most systems, except for servers, you probably want to install a graphical user interface (a desktop). Ubuntu installs GNOME by default. See page 60 for information about installing KDE.
Software and services
As you install more software packages on a system, the number of updates and the interactions between the packages increase. Server packages that listen for network connections make the system more vulnerable by increasing the number of ways the system can be attacked. Additional services can also slow the system down. For a system to learn on, or for a development system, additional packages and services may be useful. However, for a more secure production system, it is best to install and maintain the minimum number of packages required and enable only needed services. See page 507 for information on starting and stopping system services.
Requirements Hardware
This chapter and Chapter 3 cover installing Ubuntu on 32-bit Intel and compatible processor architectures such as AMD as well as 64-bit processor architectures such as AMD64 processors and Intel processors with Intel EM64T technology. Within these processor architectures, Ubuntu Linux runs on much of the available hardware. You can view Ubuntu’s list of compatible and supported hardware at wiki.ubuntu.com/HardwareSupport. Many Internet sites discuss Linux hardware; use Google (www.google.com/linux) to search for linux hardware, ubuntu hardware, or linux and the specific hardware you want more information on (for example, linux sata or linux a8n). In addition, many HOWTOs cover specific hardware. There is also a Linux Hardware Compatibility HOWTO, although it becomes dated rather quickly. Ubuntu Linux usually runs on systems that Windows runs on, unless the system includes a very new or unusual component. The hardware required to run Ubuntu depends on what kind of system you want to set up. A very minimal system that runs a textual (command line) interface and has very few software packages installed requires very different hardware from a system that runs a GUI, has many installed packages, and supports visual effects (page 103). Use the Alternate CD (page 28) if you are installing Ubuntu on a system with less than 320 megabytes of RAM. If you want to run visual effects on the system, see gentoo-wiki.com/HARDWARE_Video_Card_Support_Under_XGL for a list of supported graphics cards.
26 Chapter 2 Installation Overview
A network connection is invaluable for keeping Ubuntu up-to-date. A sound card is nice to have for multimedia applications. If you are installing Ubuntu on old or minimal hardware and want to run a GUI, consider installing Xubuntu (www.xubuntu.org), as it provides a lightweight desktop and uses system resources more efficiently than Ubuntu does. RAM (memory)
An extremely minimal textual (command line) system requires 32 megabytes of RAM. A standard desktop system requires 320 megabytes, although you may be able to use less if you install Xubuntu. Installing Ubuntu from a live session requires 320 megabytes. Use the textual installer (page 67) if the system has less than 320 megabytes of RAM. Linux makes good use of extra memory: The more memory a system has, the faster it runs. Adding memory is one of the most cost-effective ways you can speed up a Linux system.
CPU
Ubuntu Linux requires a minimum of a 200-megahertz Pentium-class processor or the equivalent AMD or other processor for textual mode and at least a 400-megahertz Pentium II processor or the equivalent for graphical mode.
Hard disk space
The amount of hard disk space Ubuntu requires depends on which edition of Ubuntu Linux you install, which packages you install, how many languages you install, and how much space you need for user data (your files). The operating system typically requires 2–8 gigabytes, although a minimal system can make due with much less space. Installing Ubuntu from a live session requires 4 gigabytes of space on a hard disk.
BIOS setup
Modern computers can be set to boot from a CD/DVD or hard disk. The BIOS determines the order in which the system tries to boot from each device. You may need to change this order: Make sure the BIOS is set up to try booting from the CD/DVD before it tries to boot from the hard disk.
CMOS
CMOS is the persistent memory that stores hardware configuration information. To change the BIOS setup, you need to edit the information stored in CMOS. When the system boots, it displays a brief message about how to enter System Setup or CMOS Setup mode. Usually you need to press Del or F2 while the system is booting. Press the key that is called for and move the cursor to the screen and line that deal with booting the system. Generally there is a list of three or four devices that the system tries to boot from; if the first attempt fails, the system tries the second device, and so on. Manipulate the list so that the CD/DVD is the first choice, save the list, and reboot. Refer to the hardware/BIOS manual for more information.
Processor Architecture Ubuntu CDs and DVDs hold programs compiled to run on a specific processor architecture (class of processors, or CPUs). The following list describes each of the architectures Ubuntu is compiled for. See help.ubuntu.com/community/ProcessorArch for a detailed list of processors in each architecture. Because Linux source code is available to everyone, a knowledgeable user can compile Ubuntu Linux to run on other processor architectures.
Planning the Installation
27
PC (Intel x86)
Software on an Ubuntu PC (Intel x86) CD/DVD is compiled to run on Intel x86compatible processors, including most machines with Intel and AMD processors, almost all machines that run MS Windows, and newer Apple Macintosh machines that use Intel processors. If you are not sure which type of processor a machine has, assume it has this type of processor.
64-bit PC (AMD64)
Software on an Ubuntu 64-bit PC (AMD64) CD/DVD is compiled to run on AMD64 processors, including the Athlon64, Opteron, and Intel 64-bit processors that incorporate EM64T technology, such as the EMT64 Xeon. Because some features of proprietary third-party applications are not available for 64-bit architecture, you may want to run Ubuntu compiled for a 32-bit (Intel x86) processor on a system with a 64-bit processor.
SPARC
Software on an Ubuntu SPARC CD (there is no DVD for this architecture) is compiled to run on UltraSPARC machines, including those based on the multicore UltraSPARC T1 (Niagara) processors.
Mac (PowerPC)
Ubuntu does not officially support the PowerPC, but there is extensive community support for this processor architecture. See wiki.ubuntu.com/PowerPCFAQ for more information about running Ubuntu on a PowerPC. You can download PowerPC versions of Ubuntu from wiki.ubuntu.com/PowerPCDownloads.
Interfaces: Installer and Installed System When you install Ubuntu, you have a choice of interfaces to use while you install it (to work with the installer) and a choice of interfaces to use to work with the installed system. This section describes the two basic interfaces: textual and graphical. Textual (CLI)
A textual interface, also called a command line interface (CLI) or character-based interface, displays characters and some simple graphical symbols. It is line oriented; you give it instructions using a keyboard only.
Graphical (GUI)
A graphical user interface (GUI) typically displays a desktop (such as GNOME) and windows; you give it instructions using a mouse and keyboard. You can run a textual interface within a GUI by opening a terminal emulator window (page 114). A GUI uses more computer resources (CPU time and memory) than a textual interface does.
Pseudographical
A pseudographical interface is a textual interface that takes advantage of graphical elements on a text-based display device such as a terminal. It may also use color. This interface uses text elements, including simple graphical symbols, to draw rudimentary boxes that emulate GUI windows and buttons. The TAB key frequently moves the cursor from one element to the next and the RETURN key selects the element the cursor is on.
Advantages
A GUI is user friendly, whereas the textual interface is compact, uses fewer system resources, and can work on a text-only terminal or over a text-only connection. Because it is more efficient, a textual interface is useful for older, slower systems and systems with minimal amounts of RAM. Server systems frequently use a textual interface because it allows the system to dedicate more resources to the job it is set up to do and fewer resources to pleasing the system administrator. Not running a GUI can also improve system security.
28 Chapter 2 Installation Overview
Figure 2-1 Installer interfaces
Graphical (left) and textual (pseudographical, right) installers
Ubuntu provides a user-friendly, graphical installer (ubiquity) and an efficient, pseudographical installer that offers more options and gives you greater control over the installation (Figure 2-1). Both interfaces accomplish the same task: They enable you to tell the installer how you want it to configure Ubuntu.
Ubuntu Releases Ubuntu distributes a new release about every six months. Each release has both a number and a name. In sequence, recent releases are 6.06 (Dapper Drake), 6.10 (Edgy Eft), 7.04 (Feisty Fawn), and 7.10 (Gutsy Gibbon). Ubuntu supports (i.e., provides updates for, including security updates) each release for at least 18 months. LTS releases
Ubuntu supports releases of its operating system marked LTS (long-term support— Dapper is an LTS release) for three years for a desktop system and for five years for a server system. LTS releases are designed for people who are more interested in having a stable, unchanging operating system rather than the latest, fastest version. Large and corporate installations frequently fall into this category. You can install and upgrade an LTS release just as you would any other release.
Ubuntu Editions Desktop CD
The Desktop CD is a live/install CD (page 24); you can use it to boot into a live session. You can install Ubuntu from a live session (page 48). This CD is available for PC and 64-bit PC architectures (page 26), uses the graphical installer, and installs a graphical (desktop) Ubuntu system.
Alternate CD
The Alternate Install CD is not a live CD; it is for special installations only. It presents more advanced installation options than the Desktop CD does. This CD is available for PC and 64-bit PC architectures (page 26), uses the textual installer, and installs an Ubuntu system that displays either a graphical or a textual interface. You can use this CD to
Planning the Installation
29
• Upgrade from older releases of Ubuntu on systems without an Internet connection. • Rescue a broken system (page 67). • Install Ubuntu on systems with less than 256 megabytes of RAM. These systems may work best from a textual interface; they may not be able to run a graphical interface fast enough to be usable. • Set up RAID (page 34) and/or LVM (page 35) partitions. • Create preconfigured OEM systems. • Set up automated deployments (having the installer answer installation questions automatically; also called preseeding). Server CD
The Server CD is not a live CD; it is for installation only. This CD is available for PC, 64-bit PC, and SPARC architectures (page 26). It uses the textual installer and installs an Ubuntu system that displays a textual interface (no desktop). During installation, the Server CD gives you the option of installing DNS and/or LAMP (Linux, Apache, MySQL, and PHP). A system installed using this CD has no open ports (page 383) and includes only software essential to a server.
DVD
The DVD is a live/install DVD (page 24); you can use it to boot into a live session. You can install Ubuntu from a live session (page 48). The DVD is available for PC and 64-bit PC architectures (page 26), uses the graphical or textual installer, and installs an Ubuntu system that displays either a graphical or a textual interface. The DVD includes all software packages supported by Ubuntu, not just those installed by default. It is an excellent resource for someone with a system that has no Internet connection.
Installing a Fresh Copy or Upgrading an Existing Ubuntu System? Clean install
An installation, sometimes referred to as a clean install, writes all fresh data to a disk. The installation program overwrites all system programs and data as well as the kernel. You can preserve some user data during an installation depending on where it is located and how you format/partition the disk. Alternatively, you can perform a clean install on an existing system without overwriting data by setting up a dual-boot system (page 61).
Upgrade
An upgrade replaces the Linux kernel and utilities on an installed release of Ubuntu Linux with a newer release. During an upgrade, the installation program preserves both system configuration and user data files. An upgrade brings utilities that are present in the old release up-to-date and installs new utilities. Before you upgrade a system, back up all files on the system. Because an upgrade preserves the desktop, an upgraded system may not display or take advantage of new features that a clean install would display. See page 59 for instructions on upgrading an Ubuntu system to a new release.
30 Chapter 2 Installation Overview
Setting Up the Hard Disk Formatting and free space
Hard disks must be prepared in several ways so an operating system can write to and read from them. Low-level formatting is the first step in preparing a disk for use. Normally you do not need to low-level format a hard disk, as this task is done at the factory. The next steps in preparing a hard disk for use are to write a partition table to it and to create partitions on the disk. The area of the disk not occupied by partitions is called free space. A new disk has no partition table and no partitions. Under DOS/Windows, the term formatting means creating a filesystem on a partition; see “Filesystems” below.
Partitions
A partition, or slice, is a logical section of a hard disk that has a device name, such as /dev/sda1, so you can address it separately from other sections. From a live session, and after you install Ubuntu, you can use the GNOME Partition Editor (page 53) to view and resize partitions on an existing system. During installation, you can use the ubiquity partitioner (pages 50 and 56) to create partitions. After installation, you can use parted (page 673) to manipulate partitions. See /dev on page 554 for more information on device names.
Partition table
A partition table holds information about the partitions on a hard disk. Before the first partition can be created on a disk, the program creating the partition must set up an empty partition table on the disk. As partitions are added, removed, and modified, information about these changes is recorded in the partition table. If you remove a partition table, you can no longer access information on the disk except by extraordinary means.
Filesystems
Before most programs can write to a partition, a data structure (page 1032), called a filesystem, needs to be written to the partition. When the Ubuntu installer creates a partition, it writes a filesystem to the partition. You can use the mkfs (make filesystem; page 525) utility, which is similar to the DOS/Windows format utility, to manually create a filesystem on a partition. Table 13-1 on page 570 lists some common types of filesystems. Ubuntu Linux typically creates ext3 filesystems for data, whereas Windows uses FAT16, FAT32, and NTFS filesystems. Apple uses HFS (Hierarchical Filesystem) and HFS+. OS X uses either HFS+ or UFS. Under Linux, typical filesystem names are / (root), /boot, /var, /home, and /usr. Under DOS/Windows, filesystems are labeled C:, D:, and so on (sometimes a whole disk is a single partition). Different types of partitions can coexist on the same hard disk, including both Windows and Linux partitions. Under Linux, the fsck (filesystem check; page 577) utility checks the integrity of filesystem data structures.
Mount point
A partition holds no information about where it will reside in a system’s directory structure. When you use the installer to create most partitions, you specify the name of a directory that Ubuntu associates with the partition. For example, you might create a partition and associate it with the /var directory. The location you specify is the mount point for the partition. As part of the boot process, Ubuntu consults the fstab (filesystem table; page 576) file which associates each partition with its mount point. This association, called mounting, enables you to access the filesystem on a partition using the name of the directory it is mounted on.
Planning the Installation
31
For example, the second partition on the first hard disk, with the device name /dev/sda2, might hold the filesystem that normally is mounted on the /home directory. This association is normal, but not mandatory. When you work in recovery mode, you may mount this filesystem on the /target directory so you can repair the filesystem. A partition is frequently referred to by the name of its normal mount point: Thus “the /home partition” refers to the partition that holds the filesystem normally mounted on the /home directory. See page 572 for more information on mount points. Filesystem independence
The state of one filesystem does not affect other filesystems: One filesystem on a drive may be corrupt and unreadable while other filesystems function normally. One filesystem may be full so you cannot write to it while others have plenty of room for more data.
Primary, Extended, and Logical Partitions You can divide an IDE/ATA/SATA disk into a maximum of 63 partitions and a SCSI disk into a maximum of 15 partitions. You can use each partition independently for swap devices, filesystems, databases, other resources, and even other operating systems. Unfortunately disk partitions follow the template established for DOS machines a long time ago. At most, a disk can hold four primary partitions. You can divide one (and only one) of these primary partitions into multiple logical partitions; this divided primary partition is called an extended partition. If you want more than four partitions on a drive—and you frequently do—you must set up an extended partition. A typical disk is divided into three primary partitions (frequently numbered 1, 2, and 3) and one extended partition (frequently numbered 4). The three primary partitions are the sizes you want the final partitions to be. The extended partition occupies the rest of the disk. Once you establish the extended partition, you can subdivide it into additional logical partitions (numbered 5 or greater) that are each the size you want. You cannot use the extended partition (number 4, above), only the logical partitions it holds. Figure 17-5 on page 674 illustrates the disk described in this paragraph.
Partitioning a Disk During installation, the installer calls a partitioner to set up disk partitions. This section discusses how to plan partition sizes. Although this section uses the term partition, planning and sizing LVs (logical volumes; page 35) works the same way. For more information refer to pages 53 and 56 and to the Linux Partition HOWTO at www.tldp.org/HOWTO/Partition.
Planning Partitions Guided partitioning
It can be difficult to plan partition sizes appropriately if you are not familiar with Linux. For this reason Ubuntu provides guided partitioning. Without asking any questions, guided partitioning divides the portion of the disk allotted to Ubuntu
32 Chapter 2 Installation Overview
into two partitions. One partition is the swap partition, which can be any size from 512 megabytes to 2 or more gigabytes. The other partition is designated as / (root) and contains the remainder of the disk space. Having only two partitions makes managing disk space quite easy. But if a program runs amok or if the system is subjected to a DoS attack (page 1034), the entire disk can fill up. System accounting and logging information, which may contain data that can tell you what went wrong, may be lost.
Partition Suggestions A Linux system must have a / (root) partition. It is advisable to set up a swap partition as well. You can create additional partition/mount point pairs; this section lists some of the more common ones. Any standard directories you do not create partitions/mount points for automatically become subdirectories of the / (root) directory and reside on the / (root) partition. For example, if you do not create a partition to hold the /home filesystem, the installer creates home as a subdirectory of / and the home directory resides on the / (root) partition. (swap) Linux temporarily stores programs and data on a swap partition when it does not
have enough RAM to hold all the information it is processing. The size of the swap partition should be between one and two times the size of the RAM in the system, with a minimum size of 256 megabytes. For example, a system with 1 gigabyte of RAM should have a 1- to 2-gigabyte swap partition. Although a swap partition is not required, most systems perform better with one. A swap partition is not mounted so it is not associated with a mount point. See swap on page 564 for more information. /boot This partition holds the kernel and other data the system needs when it boots. The
/boot partition is typically about 100 megabytes, although the amount of space required depends on how many kernel images you want to keep on hand. This partition can be as small as 50 megabytes. Although you can omit the /boot partition, it is useful in many cases. Many administrators put an ext2 filesystem on this partition because the data on it does not change frequently enough to justify the added overhead of the ext3 journal. Some older BIOSs require the /boot partition [or the / (root) partition if there is no /boot partition] to appear near the beginning of the disk.
Where to put the /boot partition tip On older systems, the /boot partition must reside completely below cylinder 1023 of the hard disk. When a system has more than one hard disk, the /boot partition must also reside on a drive on: • Multiple IDE or EIDE drives: the primary controller • Multiple SCSI drives: ID 0 or ID 1 • Multiple IDE and SCSI drives: the primary IDE controller or SCSI ID 0
Planning the Installation
33
/var The name var is short for variable: The data in this partition changes frequently.
Because it holds the bulk of system logs, package information, and accounting data, making /var a separate partition is a good idea. In this way, if a user runs a job that consumes all of the user’s disk space, system logs will not be affected. The /var partition can occupy from 500 megabytes up to several gigabytes for extremely active systems with many verbose daemons and a lot of printer activity (files in the print queue are stored on /var). Systems that are license servers for licensed software often qualify as extremely active systems. By default, Apache content (Web pages it serves) is stored on /var under Ubuntu. /home It is a common strategy to put user home directories on their own disk or partition.
This partition is usually named /home. Having /home in a separate partition allows you to perform a clean install without overwriting user files.
Set up partitions to aid in making backups tip Plan partitions around which data you want to back up and how often you want to back it up. One very large partition can be more difficult to back up than several smaller ones. / (root) Some administrators choose to separate the / (root), /boot, and /usr partitions.
When you have Ubuntu decide how to partition the disk (guided partitioning), it puts all directories in the root partition. By itself, the root partition usually consumes less than 30 megabytes of disk space. However, /lib, which can consume more than 300 megabytes, is part of the root partition. On occasion, you may install a special program that has many kernel drivers that consume a lot of space in the root partition. Allot 1 gigabyte to the root partition at a minimum. /usr Separating the /usr partition can be useful if you plan to export /usr to another sys-
tem and want the security that a separate partition can give. Many administrators put an ext2 filesystem on this partition because the data on it does not change frequently enough to justify the added overhead of the ext3 journal. The size of /usr depends on the number of packages you install. On a default system, it is typically 2–4 gigabytes. /usr/local Both /usr/local and /opt are candidates for separation. If you plan to install many and /opt packages in addition to Ubuntu Linux, you may want to keep them on a separate
partition. If you install the additional software in the same partition as the users’ home directories, for example, it may encroach on the users’ disk space. Many sites keep all /usr/local or /opt software on one server and export it to other systems. If you choose to create a /usr/local or /opt partition, its size should be appropriate to the software you plan to install. Table 2-1 (next page) gives guidelines for minimum sizes for partitions used by Linux. Set the sizes of other partitions, such as /home, /opt, and /usr/local, according to need and the size of the hard disk. If you are not sure how you will use additional disk space, you can create extra partitions using whatever names you like (for example, /b01, /b02, and so on) or wait until later to divide the space into partitions.
34 Chapter 2 Installation Overview
Table 2-1
Example minimum partition sizesa
Partition
Example size
/boot
50–100 megabytes
/ (root)
1 gigabyte
(swap)
One to two times the amount of RAM in the system with a minimum of 256 megabytes
/home
As large as necessary; depends on the number of users and the type of work they do
/tmp
Minimum of 500 megabytes
/usr
Minimum of 2–16 gigabytes, depending on which and how many software packages you install
/var
Minimum of 500 megabytes
a. The sizes in this table assume you create all partitions separately. For example, if you create a 1-gigabyte / (root) partition and do not create a /usr partition, in most cases you will not have enough room to store all the system programs.
RAID RAID (Redundant Array of Inexpensive/Independent Disks) employs two or more hard disk drives or partitions in combination to improve fault tolerance and/or performance. Applications and utilities see these multiple drives/partitions as a single logical device. RAID, which can be implemented in hardware or software (Ubuntu gives you this option), spreads data across multiple disks. Depending on which level you choose, RAID can provide data redundancy to protect data in the case of hardware failure. Although it can improve disk performance by increasing read/write speed, software RAID uses quite a bit of CPU time, which may be a consideration. True hardware RAID requires hardware designed to implement RAID and is not covered in this book (but see “Fake RAID” on the next page).
Do not replace backups with RAID caution Do not use RAID as a replacement for regular backups. If the system undergoes a catastrophic failure, RAID is useless. Earthquake, fire, theft, and other disasters may leave the entire system inaccessible (if the hard disks are destroyed or missing). RAID also does not take care of the simple case of replacing a file when a user deletes it by accident. In these situations, a backup on a removable medium (which has been removed) is the only way you will be able to restore a filesystem.
RAID can be an effective addition to a backup. Ubuntu offers RAID software that you can install either when you install an Ubuntu system or as an afterthought. The Linux kernel automatically detects RAID arrays (sets of partitions) at boot time if the partition ID is set to 0xfd (raid autodetect). Software RAID, as implemented in the kernel, is much cheaper than hardware RAID. Not only does this approach avoid the need for specialized RAID disk controllers, but it also works with the less expensive ATA disks as well as SCSI disks.
Planning the Installation
Disk A 40 GB
Disk B 80 GB
Disk C 40 GB
Disk D 20 GB
Physical volumes (PVs)
boot 40 + 80 + 40 + 20 GB (– boot partition)
/ (root)
Figure 2-2 Fake RAID
home
var
35
Boot partition Volume group (VG)
usr
(swap)
Logical volumes (LVs)
LVM: Logical Volume Manager
Ubuntu provides support for motherboard-based RAID (known as fake RAID) through the dmraid driver set. Linux software RAID is almost always better than fake RAID. For more information see help.ubuntu.com/community/FakeRaidHowto. The partitioner on the Alternate CD gives you the choice of implementing RAID level 0, 1, or 5: • RAID level 0 (striping) Improves performance but offers no redundancy. The storage capacity of the RAID device is equal to that of the member partitions or disks. • RAID level 1 (mirroring) Provides simple redundancy, improving data reliability, and can improve the performance of read-intensive applications. The storage capacity of the RAID device is equal to one of the member partitions or disks. • RAID level 5 (disk striping with parity) Provides redundancy and improves (most notably, read) performance. The storage capacity of the RAID device is equal to that of the member partitions or disks, minus one of the partitions or disks (assuming they are all the same size). For more information refer to the Software-RAID HOWTO.
LVM: Logical Volume Manager The Logical Volume Manager (LVM2, which this book refers to as LVM) allows you to change the size of logical volumes (LVs, the LVM equivalent of partitions) on the fly. With LVM, if you make a mistake in setting up LVs or your needs change, you can make LVs smaller or larger without affecting user data. You must choose to use LVM at the time you install the system or add a hard disk; you cannot retroactively apply it to a disk full of data. LVM supports IDE and SCSI drives as well as multiple devices such as those found in RAID arrays. LVM groups disk components (partitions, hard disks, or storage device arrays), called physical volumes (PVs), into a storage pool, or virtual disk, called a volume group (VG). See Figure 2-2. You allocate a portion of a VG to create a logical volume.
36 Chapter 2 Installation Overview
An LV is similar in function to a traditional disk partition in that you can create a filesystem on an LV. It is much easier, however, to change and move LVs than partitions: When you run out of space on a filesystem on an LV, you can grow (expand) the LV and its filesystem into empty or new disk space, or you can move the filesystem to a larger LV. LVM’s disk space manipulation is transparent to users; service is not interrupted. LVM also eases the burden of storage migration. When you outgrow or need to upgrade PVs, LVM can move data to new PVs. To read more about LVM, refer to the resources listed on page 24.
The Installation Process The following steps outline the process of installing Ubuntu Linux from a CD/DVD. See Chapter 3 for installation specifics. 1. Insert the installation CD/DVD in and reset the computer. The computer boots from the CD/DVD and displays the initial install screen (Figure 3-1, page 46). 2. You can press function keys to display options, select an item from the initial install screen menu, and begin bringing up a live session or installing Ubuntu when you are ready. Or you can do nothing. A live/install Desktop CD/DVD starts to bring up the system after 30 seconds; an installationonly CD waits for you to select an item from the menu. One of the menu items checks the installation medium. 3. As part of the process of bringing up a live session or installing Ubuntu, Ubuntu Linux creates RAM disks (page 1056) that it uses in place of a hard disk used for a normal boot operation. The installer copies tools required for the installation or to bring up a system from a live/install Desktop CD/DVD to the RAM disks. The use of RAM disks allows the installation process to run through the specification and design phases without writing to the hard disk and enables you to opt out of the installation at any point before the system warns you it is about to write to the hard disk (or you complete the installation). If you opt out before this point, the system is left in its original state. The RAM disks also allow a system booted from a live/install Desktop CD to leave the hard disk untouched. 4. The installer prompts you with questions about how you want to configure Ubuntu Linux. 5. When the installer is finished collecting information, it displays the Ready to install screen (Figure 3-7, page 53). When you click Install, it writes the operating system files to the hard disk.
Downloading and Burning a CD/DVD
37
6. The installer prompts you to remove the CD/DVD and press RETURN; it then reboots the system. 7. The Ubuntu Linux system is ready for you to log in and use.
Downloading and Burning a CD/DVD There are several ways to obtain an Ubuntu CD/DVD. Ubuntu makes available releases of Linux as CD and DVD ISO image files (named after the ISO9660 standard that defines the CD filesystem). This section describes how to download one of these images and burn a CD/DVD. You can also point a browser at shipit.ubuntu.com to display a Web page with links that enable you to request a free CD from Ubuntu or purchase a CD/DVD from a Web site.
The Easy Way to Download a CD ISO Image File This section explains the easiest way to download a CD ISO image file. This technique works in most situations; it is straightforward but limited. For example, it does not allow you to use BitTorrent to download the file nor does it download a DVD image. To begin, point a browser at www.ubuntu.com and click Download Now or Get Ubuntu. Select the release (page 28) and edition (page 28) you want to download. Then select the type of system you want to install it on (see “Processor Architecture” on page 26). Finally select a location from the drop-down list labeled Choose a location near you and click Start Download. If the browser gives you a choice of what to do with the file, save it to the hard disk. The browser saves the ISO image file to the hard disk. Continue reading at “Burning the CD/DVD” on page 40.
Other Ways to Download a CD/DVD ISO Image File This section explains how to download a release that is not listed on the Ubuntu download page or a DVD image, and how to download a torrent that enables you to use BitTorrent to download the ISO image file. See “Download Ubuntu” on page 24 for other locations you can download Ubuntu from. Browser
When you use a Web browser to download a file, the browser contacts a Web (HTTP) or FTP server and downloads the file from that server. If too many people download files from a server at the same time, the downloads become slower.
BitTorrent
BitTorrent efficiently distributes large amounts of static data, such as ISO image files. Unlike using a browser to download a file from a single server, BitTorrent distributes the functions of a server over its clients. As each client downloads a file, it becomes a server for the parts of the file it has downloaded. To use BitTorrent, you must download a small file called a torrent (or have a Web browser do it for you). This file, which holds information that allows clients to communicate with one another, has a filename extension of .torrent. As more people use a torrent to download a file at the
38 Chapter 2 Installation Overview
Figure 2-3
An Ubuntu mirror I
same time, the downloads become faster. Downloading an ISO image file using BitTorrent is covered later in this section. Mirrors
Many sites mirror (hold copies of) the Ubuntu ISO image files and BitTorrent torrents. Some mirrors use HTTP while others use FTP; you can use a browser to download files from either. FTP and HTTP appear slightly different. Point a browser at www.ubuntu.com/getubuntu/downloadmirrors to locate a mirror site. Scroll through the list of mirror sites, find a site near you, and click that site’s URL. The browser displays a page similar to the one shown in Figure 2-3. Click any link on the page that includes the name or release number of the version of Ubuntu you want to install. The browser displays a page similar to the one shown in Figure 2-4.
Downloading an ISO image file
You can click the links at the top of the page, although there is usually a better selection of versions in the list of files at the bottom of the page. Click the number or name of the release you want to download (e.g., gutsy or 7.10). At this point, some sites display a page with two links: Parent Directory and release. If the browser displays this page, click release. The browser displays a page with the name and number of the release at the top, followed by a description of the different types of CDs. At the bottom of the page is a list of files, with each line showing the name of the file, the date it was created, its size, and a short description. Each filename is a link. The following two lines describe the Intel x86 desktop ISO image file for Gutsy (7.10) and the torrent file that enables you to use BitTorrent to download the same ISO image file. The ISO image file is almost 700 megabytes; the torrent file is 27 kilobytes.
ubuntu-7.10-desktop-i386.iso ... 687M Desktop CD for PC (Intel x86) computers (standard download) ubuntu-7.10-desktop-i386.iso.torrent..27k Desktop CD for PC (Intel x86) computers (BitTorrent download)
Downloading and Burning a CD/DVD
39
Click the filename/link that specifies the release, edition, and architecture you want. For example, clicking gutsy-desktop-i386.iso downloads the CD ISO image for Gutsy (release 7.10) desktop (edition) for the i386 architecture. Save the file to the hard disk. Next, download the file named MD5SUMS.htm (at the top of the list) to the same directory. An easy way to save a file is to right-click it, select Save Link/Target As, and save the file to a directory with enough space for the file. See page 40 for an explanation of how to use the MD5SUMS.htm file to verify the ISO image file you download. Downloading a DVD
To download a DVD ISO image file, go to cdimage.ubuntu.com/releases and follow the instructions under “Downloading an ISO image file.” You can identify DVD ISO image files by the string dvd in their names. Make sure you have room for the file on the hard disk: A DVD ISO image file occupies about 4 gigabytes.
Using BitTorrent
You can use BitTorrent to obtain an ISO image file. Because BitTorrent is available for both Windows and Mac OS X (www.bittorrent.com), you can download and burn the Ubuntu CD/DVD under either of these operating systems. To
Figure 2-4
An Ubuntu mirror II
40 Chapter 2 Installation Overview
download a torrent, point a browser at releases.ubuntu.com and click the filename of the torrent. You can identify a torrent file by its filename extension of .torrent. A BitTorrent client should start automatically and ask where to put the downloaded file. You can also download the torrent manually; follow the instructions under “Downloading an ISO image file” on page 38. You can then start downloading the file from the command line (page 604) or by clicking it in a File Browser such as Nautilus (page 96).
You can download and burn the CD/DVD on any operating system tip You can download and burn the CD/ DVD on any computer that is connected to the Internet, has a browser, has enough space on the hard disk to hold the ISO image file (about 700 megabytes for a CD and 4 gigabytes for a DVD), and can burn a CD/DVD. You can frequently use ftp (page 732) or, on a Linux system, Nautilus menubar: FileDPlacesDConnect to Server (page 263) in place of a browser to download the file.
Verifying an ISO Image File This section assumes you have an ISO image file and a MD5SUMS.htm file saved on the hard disk and explains how to verify that the ISO IMAGE file is correct. The MD5SUMS.htm file contains the MD5 (page 1047) sums for each of the available ISO image files. When you process a file using the md5sum utility, md5sum generates a number based on the file. If that number matches the corresponding number in the MD5SUMS.htm file, the downloaded file is correct. You can run the following commands from a terminal emulator: $ grep desktop-i386 MD5SUMS.htm;md5sum gutsy-desktop-i386.iso 198fc031e7e482514eb57a2a7890dcac *gutsy-desktop-i386.iso 198fc031e7e482514eb57a2a7890dcac gutsy-desktop-i386.iso
Computing an MD5 sum for a large file takes a while. The two long strings that the preceding command displays must be identical: If they are not, you must download the file again.
Make sure the software is set up to burn an ISO image tip Burning an ISO image is not the same as copying files to a CD/DVD. Make sure the CD/DVD burning software is set up to burn an ISO image. If you simply copy the ISO file to a CD/DVD, it will not work when you try to install Ubuntu Linux.
Burning the CD/DVD An ISO image file is an exact image of what needs to be on the CD/DVD. Putting that image on a CD/DVD involves a different process than copying files to a CD/DVD. The CD/DVD burning software you use has a special selection for burning an ISO image. It has a label similar to Record CD from CD Image or Burn CD Image. Refer to the instructions for the software you are using for information on how to burn an ISO image file to a CD/DVD.
Gathering Information About the System
41
You must use 700-megabyte CD-ROM blanks tip When you burn an Ubuntu Linux CD from an ISO image, you must use a 700-megabyte blank. A 650-megabyte blank will not work because there is too much data to fit on it.
Gathering Information About the System It is not difficult to install and bring up an Ubuntu Linux system. Nevertheless, the more you know about the process before you start, the easier it will be. The installation software collects information about the system and can help you make decisions during the installation process. However, the system will work better when you know how you want your disk partitioned rather than letting the installation program create partitions without your input. There are many details, and the more details you take control of, the more pleased you are likely to be with the finished product. Finding the information that this section asks for will help ensure you end up with a system you understand and know how to change when necessary. To an increasing extent, the installation software probes the hardware and figures out what you have. Newer equipment is more likely to report on itself than older equipment is.
Test the ISO file and test the CD/DVD tip It is a good idea to test the ISO image file and the burned CD/DVD before you use it to install Ubuntu Linux. When you boot the system from the CD/DVD, Ubuntu gives you the option of checking the CD/DVD for defects (page 47). A bad file on a CD may not show up until you finish installing Ubuntu Linux and have it running. At that point, it may be difficult and time-consuming to figure out where the problem lies. Testing the file and CD/DVD takes a few minutes, but can save you hours of trouble if something is not right. If you want to perform one test only, test the CD/DVD.
It is critical to have certain pieces of information before you start. One thing Linux can never figure out is all the relevant names and IP addresses (unless you are using DHCP, in which case the addresses are set up for you). Following is a list of items you may need information about. Get as much information on each item as you can: manufacturer, model number, size (megabytes, gigabytes, and so forth), number of buttons, chipset (for cards), and so on. Some items, such as the network interface card, may be built into the motherboard. • Hard disks. • Memory. You don’t need it for installation, but it is good to know. • SCSI interface card. • Network interface card (NIC).
42 Chapter 2 Installation Overview
• Video interface card (including the amount of video RAM/memory). • Sound card and compatibility with standards, such as SoundBlaster. • Mouse (PS/2, USB, AT, and number of buttons). • Monitor (size and maximum resolution). • IP addresses and names, unless you are using DHCP (page 538), in which case the IP addresses are automatically assigned to the system. Most of this information comes from the system administrator or ISP. ◆
System hostname (anything you like).
◆
System address.
◆
Network mask (netmask).
◆
Gateway address (the connecting point to the network or Internet) or a phone number when you use a dial-up connection.
◆
Addresses for nameservers, also called DNS addresses.
◆
Domain name (not required).
Chapter Summary A live/install Desktop CD runs a live Ubuntu session without installing Ubuntu on the system. You can install Ubuntu from a live session. Booting a live/install Desktop CD is a good way to test hardware and fix a system that will not boot from the hard disk. Before you download or otherwise obtain an Ubuntu CD or DVD, make sure you are using medium that is appropriate to the hardware you are installing it on and to what the system will be used for. Ubuntu has three editions: Desktop (the most common), Alternate (for special cases), and Server. The Ubuntu live DVD combines features of all three of these editions. When you install Ubuntu Linux, you copy operating system files from a CD or DVD to hard disk(s) on a system and set up configuration files so Linux runs properly on the hardware. Operating system files are stored as CD or DVD ISO image files. You can use a Web browser or BitTorrent to download an ISO image file. It is a good idea to test the ISO image file when it is downloaded and the burned CD/DVD before you use it to install Ubuntu Linux. When you install Ubuntu, you can let the installer decide how to partition the hard disk (guided partitioning) or you can manually specify how you want to partition it.
Advanced Exercises 43
Exercises 1. Briefly, what does the process of installing an operating system such as Ubuntu Linux involve? 2. What is an installer? 3. Would you set up a GUI on a server system? Why or why not? 4. A system boots from the hard disk. To install Linux, you need it to boot from a CD/DVD. How can you make the system boot from a CD/DVD? 5. What is free space on a hard disk? What is a filesystem? 6. What is an ISO image? How do you burn an ISO image to a CD/DVD?
Advanced Exercises 7. List two reasons why RAID cannot replace backups. 8. What are RAM disks? How are they used during installation? 9. What is MD5? How does it work to ensure that an ISO image file you download is correct?
This page intentionally left blank
3 Step-by-Step Installation In This Chapter Basic Installation from the Live/Install Desktop CD/DVD . . . 46 The Ubuntu Graphical Installer . . . 48 Graphical Partitioners. . . . . . . . . . . 53 Setting Up a Dual-Boot System . . . 61 The live/Install Desktop CD: The Initial Install Screen . . . . . . . 62 The Alternate CD Initial Install Screen Menu . . . . . . . . . . . . . . . . 65 The Server CD Initial Install Screen Menu . . . . . . . . . . . . . . . . 66
Chapter 2 covered planning the installation of Ubuntu Linux: determining the requirements; performing an upgrade versus a clean installation; planning the layout of the hard disk; obtaining the files you need for the installation, including how to download and burn CD/DVD ISO images; and collecting information about the system. This chapter focuses on installing Ubuntu. Frequently the installation is quite simple, especially if you have done a good job of planning. Sometimes you may run into a problem or have a special circumstance; this chapter gives you tools to use in these cases. Read as much of this chapter as you need to; once you have installed Ubuntu, continue with Chapter 4, which covers getting started using the Ubuntu desktop. If you install a textual (command line) system, continue with Chapter 5. Chapter3 3
The Ubuntu Textual Installer. . . . . . 67 Manual Partitioning . . . . . . . . . . . . 70 Setting Up a RAID Array . . . . . . . . . 73 The xorg.conf File . . . . . . . . . . . . . . 77
45
46 Chapter 3 Step-by-Step Installation
Basic Installation from the Live/Install Desktop CD/DVD To begin installing Ubuntu from a live/install Desktop CD/DVD, insert the disk in the computer and boot the system. The system displays the initial install screen (Figure 3-1). Refer to “BIOS setup” on page 26 if the system does not boot from the CD/DVD. See “The Function Keys” on page 62 for information about changing the language, keyboard, and accessibility features the live session uses. The menu on the initial install screen differs depending on which edition of Ubuntu (page 28) you are installing; along the bottom of the screen, the labels for the function keys remain the same. To the left of the menu, the live (desktop) CD/DVD displays a counter that counts down from 30 to 1; when the counter reaches 0, Ubuntu boots the system. When you press a key (other than RETURN) before the counter reaches 0, the counter stops and the system waits for you to make a selection from the menu. The installation-only (Alternate and Server) CDs do not have a counter, but rather wait for you to make a selection. This section describes how to boot into a live session and how to install Ubuntu from that session.
Booting the System Before Ubuntu can display a desktop from a live/install Desktop CD/DVD or install itself on a hard disk, the Ubuntu operating system must be read into memory
Figure 3-1
The initial install screen for the live/install Desktop CD
Basic Installation from the Live/Install Desktop CD/DVD
47
(booted). This process can take a few minutes on older, slower systems or systems with minimal RAM (memory). Each of the menu selections on the initial install screen, except the memory test, boots the system.
Checking the CD/DVD for Defects Whether you burned your own CD/DVD, purchased it, or are using the one included with this book, it is a good idea to verify that the contents of the CD/DVD is correct. On the initial install screen, use the ARROW keys to highlight Check the CD for Defects (this selection checks DVDs too) and press RETURN. Checking the CD/DVD takes a few minutes—Ubuntu keeps you apprised of its progress. When Ubuntu finishes checking the CD/DVD, it displays the result of its testing. Press RETURN to redisplay the initial install screen.
Test the CD/DVD tip Testing the CD/DVD takes a few minutes but can save you much aggravation if the installation fails or you run into problems after installing Ubuntu owing to bad media.
Live Session In most cases, you can boot Ubuntu to run a live session that displays a desktop without doing anything after you boot from the live/install Desktop CD/DVD: Ubuntu displays the initial install screen, counts down from 30, boots the system, displays the Ubuntu logo while an orange cursor moves back and forth on the progress bar, and finally displays the GNOME desktop (Figure 3-2). To speed up this process, you can
Install object
Figure 3-2
The GNOME desktop displayed by a live session
48 Chapter 3 Step-by-Step Installation
press RETURN when Ubuntu displays the initial install screen. The first time you use a CD/DVD, it is a good idea to check it for defects (see the previous page). If you encounter problems with the display while you are bringing up the desktop from a live/install Desktop CD/DVD or during installation, reboot the system and select Start Ubuntu in safe graphics mode (page 62) from the initial install screen. If that does not work, install Ubuntu using the textual installer on the Alternate CD (page 65) or the DVD. The live/install Desktop CD/DVD gives you a chance to preview Ubuntu without installing it. Boot the live/install Desktop CD/DVD to begin a live session and work with Ubuntu as explained in Chapter 4. When you are finished, remove the CD/DVD and reboot the system. The system boots as it did before the live session. Because a live session does not write to the hard disk (other than using a swap partition if one is available), none of the work you save will be available once you reboot. You can use Webmail or another method to transfer files you want to preserve to another system.
optional
Seeing What Is Going On If you are curious and want to see what Ubuntu is doing as it boots, remove quiet and splash from the boot command line (Figure 3-16, page 64): With the initial install screen displayed, press F6 to display the boot command line. Press BACKSPACE or DEL to back up and erase quiet and splash from the boot command line. If you have not added anything to this line, you can remove the two hyphens at the end of the line. If you have added to this line, use the BACK ARROW key to back up over—but not remove—whatever you added, the hyphens, and the SPACE on each side of them. Then remove quiet and splash. As Ubuntu boots, it displays information about what it is doing. Text scrolls on the screen, although sometimes too rapidly to read.
The Ubuntu Graphical Installer ubiquity
The ubiquity utility is a graphical installer, written mostly in Python, which installs Ubuntu from a live session. You can use the Alternate or Server CD or the DVD to install Ubuntu using the textual installer (page 67).
Before you start, see what is on the hard disk tip Unless you are certain you are working with a new disk, or you are sure the data on the disk is of no value, it is a good idea to see what is on the disk before you start installing Ubuntu. You can use the GNOME Partition Editor to examine the contents of a hard disk. See page 53 for more information. Welcome screen
To install Ubuntu from the live/install Desktop CD/DVD, start a live session and double-click (use the left mouse button) the object on the desktop labeled Install (Figure 3-2, page 47). After a few moments Ubuntu displays the Welcome screen of the Install window (Figure 3-3). This screen displays a welcome message and a query about which language you would like ubiquity to use. The language you choose will be the default
Basic Installation from the Live/Install Desktop CD/DVD
49
List box Scrollbar Forward button
Figure 3-3
The Install window, Welcome screen
language for the installed system; you can change this default once the system is installed (page 132).
Using the Mouse to Work with the Install Window You can use the mouse or keyboard to make selections from the Install window screens. To select a language from the Welcome screen using the mouse, left-click the language you want to use in the list box at the left. If the language you want does not appear on the displayed portion of the list, click or drag the scrollbar (Figure 3-3) to display more languages; then click the language of your choice. Ubuntu highlights the language you click. Once you select a language, you are finished working with the Welcome screen; click the Forward button to display the next screen.
Using the Keyboard to Work with the Install Window To use the keyboard to make selections, first use the TAB key to move the highlight to the object you want to work with. On the Welcome screen, the objects are the selected item in the list box and the buttons labeled Release Notes, Cancel, and Forward. With a language in the list box highlighted, use the UP ARROW and DOWN ARROW keys to move the highlight to the language you want to use. The list scrolls automatically when you move the highlight to the next, undisplayed entry in the list. See “F3 Keymap” on page 63 to change the layout of the keyboard ubiquity uses during installation. Once you select a language, you are finished working with the Welcome screen; use the TAB key to highlight the Forward button. The border of a button becomes thicker and darker when it is highlighted. With the Forward button highlighted, press RETURN to display the next screen.
50 Chapter 3 Step-by-Step Installation
Figure 3-4
The ubiquity partitioner showing one empty hard disk
This book describes using the mouse to make selections from a graphical interface; you can use the keyboard if you prefer. Where are you?
Next, ubiquity displays the Where are you? screen. This screen allows you to specify the time zone the computer is in. You can use the map or the drop-down list labeled Selected city to specify the time zone. Initially, when it is over the map, the mouse pointer appears a magnifying glass with a plus sign in it. Left-click the map near a city that is in the same time zone as the computer; the map zooms in on that area. Left-click again to choose a city; the name of the city appears in the box labeled Selected city. To use the drop-down list, click anywhere in the box labeled Selected city; ubiquity expands the box into a list of cities. Use the mouse or ARROW keys to select a city and then either click the city or press RETURN. Click Forward.
Keyboard layout
The Keyboard layout screen allows you to specify the type of keyboard to be used by the installed system. (See “F3 Keymap” on page 63 to change the layout of the keyboard ubiquity uses during installation.) Select the country you are in or the language you will be using with the installed system from the list box on the left. Then select the type of keyboard you will be using from the list box on the right. Click the empty text box near the bottom of the window and enter some characters to test your selection. Click Forward. The installer displays the Setting up the partitioner window while it gets ready for the next step.
Prepare disk space
The Prepare disk space screen controls how ubiquity partitions the hard disk. See page 31 for a discussion of some of the issues involved in partitioning a hard disk. With a single, clean hard disk—a hard disk with nothing installed on it, as it comes from the factory (i.e., no partition table)—the ubiquity partitioner displays a Prepare disk space screen similar to the one shown in Figure 3-4. In this case, the simplest way to partition the disk is to have ubiquity do it for you. By default, the radio button labeled Guided – use entire disk and the radio button next to the name of the only hard disk in the system are selected. If the system has two or more clean hard disks, the ubiquity partitioner displays a line for each hard disk; click the radio button next to the one you want to install Ubuntu on. Click Forward and ubiquity creates two partitions on the hard disk: a small swap partition (page 32) and a root partition (/, page 33) that occupies the rest of the disk. The installer displays the Starting Up the Partitioner window while it gets ready for the next step. If the Prepare disk space screen includes Guided - resize... and Guided - use the largest continuous free space selections, there is probably at least one partition on the
Basic Installation from the Live/Install Desktop CD/DVD
Figure 3-5
51
Write to disk warning window
hard disk (there could just be an empty partition table). If you are sure you do not want to keep any of the information on the hard disk, you can select Guided - use entire disk. To find out more about what is on the disk, see the section on the Partition Editor on page 53. For more information on guided partitioning, see page 56. For information on manual partitioning, see page 57. The ubiquity partitioner displays a warning window (Figure 3-5) if it is going to write to the hard disk before it displays the Ready to install screen (Figure 3-7, page 53). If it does not display this window, ubiquity will not make changes to the hard disk until you click Install on the Ready to install screen. Migrate documents and settings
If you are installing Ubuntu on a system that already has one or more operating systems installed on it, and you are not overwriting those operating systems, the Migrate documents and settings screen displays a list of accounts and settings from the existing operating systems. For example, if you are creating a dual-boot system on a system that already has Windows installed on it, this screen shows the accounts from the Windows system and a list of programs and settings. It might show your name from the Windows system and, under that, Internet Explorer and My Documents. Put ticks in the check boxes adjacent to the items you want to migrate to the Ubuntu system. On the lower portion of the screen, enter the information necessary to create an Ubuntu user to receive the migrated information.
Who are you?
The Who are you? screen (Figure 3-6 on the next page) sets up the first Ubuntu user. This user can use sudo (page 88) to administer the system, including setting up additional users (page 658). Enter the full name of the user in the text box labeled What is your name?. When you press RETURN, ubiquity enters the first name from the name you just entered in the box labeled What name do you want to use to log in?. Press RETURN to accept this name or backspace (page 137) over it and enter a different name. Enter the same password in the next two (adjacent) boxes. Although ubiquity accepts any password, it is a good idea to choose a more secure password if the system is connected to the Internet. See “Changing Your Password” on page 135 for a discussion of password security. The final text box specifies the name of the computer. For use on a local network and to connect to the Internet with a Web browser or other client, you can use a simple name such as tiny. If you are setting up a system that is to function as a server, see “FQDN” on page 847 for information on names that are valid on the Internet. Click Forward.
52 Chapter 3 Step-by-Step Installation
Figure 3-6 Ready to install
The Install window, Who are you? screen
The final screen ubiquity displays is the Ready to install screen (Figure 3-7). Unless ubiquity asked your permission to write to the hard disk during the partitioning phase of the installation, it has not written to the disk yet. If you click Cancel at this point, the hard disk will remain untouched. This screen summarizes your answers to the questions ubiquity asked in the previous screens. Click Advanced to display the Advanced Options window, which allows you to choose whether to install a boot loader (normally you want to) and whether you want the system to participate in an automatic, informal package usage survey. Click OK to close the Advanced Options window. If everything looks right in the summary in the Ready to install screen, click Install. The installer begins installing Ubuntu on the hard disk.
This is when ubiquity writes to the hard disk caution You can abort the installation by clicking the Cancel button at any point up to and including the Ready to install screen (Figure 3-7) without making any changes to the system. Once you click Next in this screen, ubiquity writes to the hard disk. However, if ubiquity displayed the warning window shown in Figure 3-5 on page 51 and you clicked Continue, it wrote to the hard disk at that time.
The ubiquity installer displays a series of windows to keep you informed of its progress. When the new system is installed, Ubuntu displays the Installation Complete window, which gives you the choice of continuing the live session or rebooting the system so you can use the newly installed copy of Ubuntu. Click Restart now to reboot the system. Ubuntu displays its logo and a progress bar. When it has finished shutting down the system, it asks you to remove the disk (so you do not reboot from the live/install Desktop CD/DVD) and press RETURN. When you do so, it reboots the system and displays the Ubuntu GNOME login screen (Figure 4-1, page 90).
Graphical Partitioners
Figure 3-7
53
The Install window, Ready to install screen
Graphical Partitioners A partitioner displays and can add, delete, and modify partitions on a hard disk. This section describes two graphical partitioners you can use to configure a hard disk so you can install Ubuntu Linux. One partitioner, gparted, is available on the live/install Desktop CD desktop. The other partitioner is part of the ubiquity installer and is not available by itself. See page 57 for information on using the textual partitioner, which is available when you use the textual installer. After you install Ubuntu Linux, you can use parted (page 673) to manipulate partitions. If you want a basic set of partitions, you can allow ubiquity to partition the hard disk automatically using guided partitioning. See “Setting Up the Hard Disk” on page 30 for a discussion of free space, partitions, partition tables, and filesystems. “Partition Suggestions” on page 32 discusses some of the filesystems you may want to set up partitions for.
gparted: the GNOME Partition Editor Unless you know the hard disk you are installing Ubuntu Linux on has nothing on it (it is a new disk) or you are sure the disk holds no information of value, it is a good idea to examine the contents of the disk before you start the installation. The GNOME Partition Editor (gparted), which is available from a live session, is a good
54 Chapter 3 Step-by-Step Installation
Figure 3-8
Selecting the Partition Editor from the Main menu
tool for this job. Open the Partition Editor window by selecting Main menu: AdministrationDPartition Editor as shown in Figure 3-8. The Partition Editor displays the layout of a hard disk and can resize partitions, such as when you are setting up a dual-boot system by adding Ubuntu to a Windows system (page 61). Although you can create partitions using the Partition Editor, you cannot specify the mount point (page 30) for a partition—this step must wait until you are installing Ubuntu and using the ubiquity partitioner. You can save time if you use the Partition Manager to examine a hard disk and the ubiquity partitioner to set up the partitions that you install Ubuntu on.
An Empty Hard Disk The Partition Editor shows one large unallocated space for a new hard disk (empty, with no partition table). If you have more than one hard disk, use the list box in the upper-right corner of the screen to select which disk the Partition Editor displays information about. Figure 3-9 shows an empty 200-gigabyte hard disk on the device named /dev/sda. Figure 3-4 on page 50 shows the ubiquity partitioner ready to partition an empty drive similar to the one shown in Figure 3-9.
Figure 3-9
The Partition Editor displaying an empty disk drive
Graphical Partitioners
Figure 3-10
55
The Partition Editor displaying a disk drive holding a Windows system
Deleting a Partition Before deleting a partition, make sure it does not contain any data you need. To use the Partition Editor to delete a partition, highlight the partition you want to delete and click Delete and then Apply on the toolbar.
Resizing a Partition Figure 3-10 shows the Partition Editor displaying information about a hard disk with a single partition that occupies the entire disk. It shows a single 200-gigabyte NTFS filesystem. The process of resizing a partition is the same regardless of the type of partition: You can use the following technique to resize Windows, Linux, or other types of partitions.
Always back up the data on a hard disk caution If you are installing Ubuntu on a disk that holds data that is important to you, always back up the data before you start the installation. Things can and do go wrong. The power may go out in the middle of an installation, corrupting the data on the hard disk. There may be a bug in the partitioning software that destroys a filesystem. Although it is unlikely, you might make a mistake and format a partition holding data you want to keep.
To install Ubuntu on this system, you must resize (shrink) the partition to make room for Ubuntu. Before you resize a Windows partition, you must boot Windows and defragment the partition using the Windows defragmenter; see the tip on page 61. Although you can resize a partition with the ubiquity partitioner while you are installing Ubuntu, it is easier to see what you are doing when you use the Partition Editor
56 Chapter 3 Step-by-Step Installation
for this task. Also, the ubiquity partitioner will not resize a partition on a hard disk with more than one partition. To resize the partition, right-click to highlight the line that describes the partition and select Resize/Move on the toolbar. The Partition Editor opens a small Resize/Move window, as shown in Figure 3-10 on page 55. At the top of the Resize/Move window is a graphical representation of the partition. Initially, the partition occupies the whole disk. The spin box labeled New Size (MiB) shows the number of megabytes occupied by the partition—in this case the whole disk. The two spin boxes labeled Free Space show no free space. Back up the partition before you begin resizing. You can specify how you want to resize the partition by (right-clicking and) dragging one of the triangles at the ends of the graphical representation of the partition or by entering the number of megabytes you want to shrink the Windows partition to in the spin box labeled New Size. The value in one of the spin boxes labeled Free Space increases. Click Resize/Move to add the resize operation to the list of pending operations at the bottom of the window. Click Apply on the toolbar to resize the partition. Although you can use the Partition Editor to create partitions to install Ubuntu on, it may be easier to create partitions using ubiquity while you are installing Ubuntu. The ubiquity partitioner allows you to specify mount points for the partitions; the Partition Editor does not.
ubiquity: Setting Up Partitions While you are installing Ubuntu, ubiquity offers two ways to partition a disk: guided and manual. Guided partitioning sets up two partitions, one for swap space (page 32) and one for / (root, where the entire Ubuntu filesystem gets mounted; page 33). The amount of space occupied by root depends on which guided option you select. Manual partitioning enables you to set up partitions of any type and size, and to specify the mount point for each partition.
Advanced Guided Partitioning “Prepare disk space” on page 50 explained how to use guided partitioning to partition an empty disk. This section explains how guided partitioning works on a disk that is already partitioned. Installing Ubuntu on a partitioned disk gives you a few options: • You can install Ubuntu on the entire hard disk; by doing so you delete any information that was on the hard disk. • If the disk has enough free space, you can install Ubuntu in the free space, typically creating a dual-boot system. • If one partition has enough unused space, you can resize (shrink) the partition, creating free space in the process. You can then install Ubuntu in the
Graphical Partitioners
57
free space. It it easier to see what you are doing if you use the Partiton Editor to resize a partition before you begin installing Ubuntu. Also, the ubiquity partitioner will not resize a partition on a hard disk with more than one partition. For more information refer to “Resizing a Partition” on page 55. Figure 3-11 shows the Prepare disk space screen for a hard disk with one partition and some free space. If the disk had no free space, the partitioner would not display Guided - use the largest continuous free space. If the disk had two or more partitions, the partitioner would not give you the option of resizing a partition—you must use the Partition Editor to resize a partition on a hard disk with more than one partition. Using the whole disk for Ubuntu is easy. Before you start, make certain the disk does not contain any information you need. Once you rewrite the partition table, the data is gone for good. If you are not sure what is on the disk, use the Nautilus File Browser to take a look. (See page 96; select Main menu: PlacesDComputer and double-click one or more of the Filesystem objects.) To use guided partitioning to partition the whole disk, click the radio button labeled Guided - use entire disk and click Forward. To use the free space, select Guided - use the largest continuous free space and click Forward. If you want to use the ubiquity partitioner to resize a partition, click the radio button labeled Guided - resize ... and drag the slider until the numbers above it show the size you would like the new partition to be. Click Forward.
Manual Partitioning This section explains how to use the ubiquity partitioner to create a partition on an empty hard disk. Figure 3-4 on page 50 shows the Prepare disk space screen for an empty hard disk. To create partitions manually, click the radio button labeled Manual and click Forward. The ubiquity partitioner displays a Prepare partitions screen that shows a device without any partitions. Before you can create partitions, you
Figure 3-11
The Prepare disk space screen showing a hard disk with one partition and some free space
58 Chapter 3 Step-by-Step Installation
Figure 3-12
An empty hard disk with a partition table
must set up a partition table (page 30): Highlight the device name (e.g., /dev/sda) and click New partition table. The partitioner asks you to confirm you want to create a new empty partition table. Click Continue to create a partition table that contains only free space. Now ubiquity displays a screen that looks similar to the one in Figure 3-12. The device (hard disk) at /dev/sda has a partition table without any partitions—it contains only free space. To create a partition, highlight the line with free space in the Device column and click New partition. The ubiquity partitioner displays a Create Partition window (Figure 3-13), which asks you to specify whether you want to create a primary or a logical partition (page 31), what size you want to make the partition (in megabytes), whether you want the partition to appear at the beginning or end of the free space, what type you want to make the partition (Use as), and the name of the mount point (page 30) for the partition. Because Linux does not mount a swap partition, you cannot specify a mount point for a type swap partition. If you are unsure of which type a partition should be, choose ext3 (page 571). Click OK. After a few moments the Prepare partitions screen displays the new partition (Figure 3-14). To create another partition, highlight free space and repeat the preceding steps. Remember to create a swap partition (page 32). When you have finished creating partitions, click Forward. The Prepare partitions screen displays two or three buttons immediately below the frame that lists the disks and partitions. The labels on these buttons change depending on what is highlighted. This screen always displays a button labeled Undo
Figure 3-13
The Create Partition window
Upgrading to a New Release 59
Figure 3-14
The Prepare partitions screen displays a new partition
changes to partitions. When the device is highlighted, the Prepare partitions screen displays a New partition table button. Clicking this button creates a new partition table, destroying any existing partition table. Highlighting a partition gives you the choice of editing or deleting the partition. Editing a partition you just created allows you to change only its type and mount point. You must delete and recreate a partition to change any of its other attributes. As mentioned earlier, highlighting free space allows you to create a new partition.
Upgrading to a New Release Upgrading a system is the process of installing a new release of Ubuntu over an older one. All user and configuration files are preserved and all software is upgraded to the most recent version consistent with the new release of Ubuntu. Ubuntu cautions that you must not skip releases when you upgrade; doing so can cause irreparable damage to the system, requiring a clean install and potentially losing data. For example, you can upgrade from Feisty Fawn (7.04) to Gutsy Gibbon (7.10), but not from Edgy Eft (6.10) to Gutsy Gibbon. Ubuntu also advises against upgrading systems that have had packages installed from repositories (page 588) that it does not control. These packages may corrupt the software package database, causing the upgrade to fail. Before you upgrade a system, it is a good idea to back up all user files on the system. The following procedure assumes that you have a desktop system that is connected to the Internet. Even with a fast Internet connection, this process takes a long time. Follow these steps to upgrade a system: 1. Open the Update Manager window (Figure 4-10, page 101) by selecting Main menu: SystemDAdministrationDUpdate Manager. 2. Regardless of whether the window says You can install nn updates or not, click Check. This step ensures the software package database is up-to-date. 3. If the window displays You can install nn updates, click Install Updates. This step ensures all software packages on the system are up-to-date.
60 Chapter 3 Step-by-Step Installation
4. At this point, if a new release is available, the window displays the message New distribution release 'X.XX' is available. Click Upgrade. 5. The utility displays the Release Notes window. Read the release notes and then click Upgrade. 6. The utility downloads the upgrade tool and updates some files. 7. You are asked if you want to start the upgrade. Click Start Upgrade. 8. When the upgrade is complete, reboot the system. See www.ubuntu.com/getubuntu/upgrading for instructions on upgrading other editions of Ubuntu.
Installing KDE You can install KDE in one of two ways. The first approach installs KDE only: Follow the instructions in Chapter 2 and this chapter but instead of downloading and burning an Ubuntu CD/DVD, download a Kubuntu CD/DVD from www.kubuntu.org, burn it, and use that disk to install Linux. The second approach requires the system to be connected to the Internet and installs KDE in addition to GNOME. After you install Ubuntu as explained in this chapter, use Synaptic (page 121) or aptitude (page 592) to perform the following steps. This process takes a while; you will be downloading and installing more than 200 software packages. 1. Ensure the software package database is up-to-date: From Synaptic, click Reload. To use aptitude, give the command sudo aptitude update from a command line, terminal emulator, or Run Application window (ALT-F2). 2. Ensure all software packages on the system are up-to-date: From Synaptic, click Mark All Upgrades and then click Apply. To use aptitude, give the command sudo aptitude safe-upgrade from a command line, terminal emulator, or Run Application window (ALT-F2). 3. Install the KDE software: From Synaptic, search for and install the kubuntu-desktop virtual package (page 592). To use aptitude, give the command sudo aptitude install kubuntu-desktop from a command line, terminal emulator, or Run Application window (ALT-F2). After the software is downloaded, while it is being installed, debconf asks if you want to use the gdm (page 82, GNOME) or kdm (KDE) display manager. Either one works with either desktop. One way to choose which display manager to use is to select the one associated with the desktop you will be using most often. Once KDE is installed, reboot the system. From the Login screen, follow the instructions on page 132 to display the Action menu and select the session you want to run (GNOME or KDE).
Setting Up a Dual-Boot System 61
Setting Up a Dual-Boot System A dual-boot system is one that can boot one of two (or more) operating systems. This section describes how to add Ubuntu to a system that can boot Windows, creating a system that can boot Windows or Linux. You can use the same technique for adding Ubuntu to a system that runs a different version or distribution of Linux. One issue in setting up a dual-boot system is finding disk space for the new Ubuntu system. The next section discusses several ways to create the needed space.
Creating Free Space on a Windows System Typically you install Ubuntu Linux in free space on a hard disk. To add Ubuntu Linux to a Windows system, you must have enough free space on a hard disk that already holds Windows. There are several ways to provide or create this free space. The following paragraphs discuss these options in order from easiest to most difficult: Add a new disk drive
Add another disk drive to the system and install Linux on the new disk, which contains only free space. This technique is very easy and clean but requires a new disk drive.
Use existing free space
If there is sufficient free space on the Windows disk, you can install Linux there. This technique is the optimal choice, but there is rarely enough free space on an installed hard disk.
Always defragment before resizing caution You must boot Windows and defragment a Windows partition before you resize it. Sometimes you may need to run the Windows defragmenter several times to consolidate most file fragments. Not only will defragmenting give you more space for a Linux partition, but it may also keep the process of setting up a dual-boot system from failing. Resize Windows partitions
Windows partitions typically occupy the entire disk, making resizing a Windows partition the most common technique to free up space. Windows systems typically use NTFS, FAT32, and/or FAT16 filesystems. You can use the Ubuntu Partition Editor to examine and resize an existing Windows partition to open up free space in which to install Linux (page 55).
Remove a Windows partition
If you can delete a big enough Windows partition, you can install Linux in its place. To delete a Windows partition, you must have multiple partitions under Windows and be willing to lose the data in the partition you delete. In many cases, you can move the data from the partition you will delete to another Windows partition. Once you are sure a partition contains no useful information, you can use the Partition Editor to delete it (page 55). After deleting the partition, you can install Ubuntu Linux in the free space left by the partition you removed.
Installing Ubuntu Linux as the Second Operating System After creating enough free space on a Windows system (see the previous section), you can install Ubuntu Linux. On the ubiquity Prepare disk space screen, select
62 Chapter 3 Step-by-Step Installation
Guided - use the largest continuous free space. Or, if you are installing Ubuntu on its own hard disk, select Guided - use entire disk and click the radio button next to the disk you want to install Ubuntu on. Click Forward. When you boot from the hard disk, you will be able to choose which operating system you want to run.
Advanced Installation This section discusses the live/install Desktop CD initial install screen, using the Alternate and Server CDs as well as the live/install DVD to install Ubuntu, and the Ubuntu textual installer.
The Live/Install Desktop CD: The Initial Install Screen This section covers some of the things you can do from the initial install screen (Figure 3-1, page 46) other than simply booting to a live session.
Menu Selections Start or install Ubuntu Start Ubuntu in safe graphics mode
Install with driver update CD OEM install (for manufacturers)
Boots to a live session (page 47). If you encounter problems with the display while you are bringing up a live session or during installation, choose this menu selection. It adds xforcevesa to the boot parameters, causing Ubuntu to use the generic vesa driver in place of the driver for the graphics chip in the system. The vesa driver is slow and does not support high resolutions, but it works with almost any graphics chip. Installs Ubuntu with an updated driver. Allows a manufacturer or reseller to preinstall Ubuntu but leave some configuration details, such as creating a user account, to the purchaser.
Check CD for defects
Verifies the contents of the CD/DVD you are booting from (page 47).
Memory test
Runs memtest86+, a GPL-licensed, stand-alone memory test utility for x86-based computers. Press C to configure the test; press ESCAPE to exit and reboot. See www.memtest.org for more information.
Boot from first hard disk
Boots the system from the first hard disk. This selection frequently has the same effect as booting the system without the CD/DVD (depending on how the BIOS [page 26] is set up).
The Function Keys Along the bottom of the initial install screen is a row of labeled function key names (Figure 3-1, page 46). Pressing these function keys displays information that may be helpful if you are having a problem booting Ubuntu or working in a live session. Some of the keys allow you to change boot parameters.
Advanced Installation 63
Figure 3-15
Initial install screen, F1 help window
F1 Help
The F1 key displays the help window shown in Figure 3-15. Pressing a function key while this window is displayed displays yet another help window. Pressing a function key when this window is not displayed has the effect described in the following paragraphs. Press ESCAPE to close the help window.
F2 Language
The F2 key displays a menu of languages. Use the ARROW keys to highlight the language you want the live session to use and then press RETURN. This language is not necessarily the language the installed system displays.
F3 Keymap
The F3 key displays a menu of countries and languages. Use the ARROW keys to highlight the country/language of the keyboard you want the live session to use; press RETURN. This keyboard is not necessarily the keyboard the installed system uses.
F4 VGA
The ubiquity installer normally detects the characteristics of the monitor attached to the system. The F4 key displays a list of monitor resolutions and color depths (page 1029). For example, 640 x 480 x 16 specifies a resolution of 640 x 480 dots per inch (dpi) and a color depth of 16. Use the ARROW keys to highlight the resolution and color depth you want the live session to use and then press RETURN. This selection is not necessarily the resolution and color depth the installed system uses.
F5 Accessibility
The F5 key displays a list of features, such as a high-contrast display and a Braille terminal, that can make Ubuntu more accessible for some people. Use the ARROW keys to highlight the feature you want the live session to use and then press RETURN.
F6 Other Options
The F6 key displays the boot command line (Figure 3-16 on the next page). Type the parameters you want to add to the boot command line (discussed in the next section) after the double hyphen and press RETURN to boot the system. If you remove quiet and splash from this line, Ubuntu displays what it is doing while it boots (page 48).
Boot Command Line Parameters (Boot Options) Following are some of the parameters you can add to the boot command line (see “F6 Other Options” above). You can specify multiple parameters separated by SPACEs.
64 Chapter 3 Step-by-Step Installation
Boot command line
Figure 3-16
Initial install screen, F6 boot command line
See help.ubuntu.com/community/BootOptions and The Linux BootPrompt-HowTo for more information. noacpi
Disables ACPI (Advanced Configuration and Power Interface). Useful for systems that do not support ACPI or that have problems with their ACPI implementation. Also acpi=off. The default is to enable ACPI.
noapic
Disables APIC (Advanced Programmable Interrupt Controller). The default is to enable APIC.
noapm
Disables APM (Advanced Power Management). Also apm=off. The default is to enable APM.
irqpoll
Changes the way the kernel handles interrupts.
nolapic
Disables local APIC (above). The default is to enable local APIC.
Virtual Consoles While it is running, ubiquity opens a shell on each of the six virtual consoles (also called virtual terminals; page 136). You can display a virtual console by pressing CONTROL-ALT-Fx, where x is the virtual console number and Fx is the function key that corresponds to the virtual console number. At any time during the installation, you can switch to a virtual console and give shell commands to display information about processes and files. Do not give commands
Advanced Installation 65
Figure 3-17
The list of rescue operations
that change any part of the installation process. To switch back to the graphical installation screen, press CONTROL-ALT-F7. To switch back to the textual (pseudographical) installation screen, press CONTROL-ALT-F1.
The Alternate CD Initial Install Screen Menu The Alternate CD uses the textual installer (page 67) to install a system that uses a graphical interface or one that uses a textual interface. It is not a live CD (does not bring up a desktop to install from), does not require as much RAM to install Ubuntu, and presents more installation options. The Alternate CD initial install screen takes advantage of the functions keys described on page 62 and accepts the boot parameters described on page 63. This screen has the following selections that are not present on the live/install Desktop CD initial install screen (page 62): Install in text mode
Installs a graphical Ubuntu system using the textual installer. For more information refer to “The Ubuntu Textual Installer” on page 67.
Install a commandline system
Installs a textual Ubuntu system (no graphical interface, no desktop, only a command line interface) using the textual installer. For more information refer to “The Ubuntu Textual Installer” on page 67.
Rescue a broken system
Brings up Ubuntu but does not install it. After detecting the system’s disks and partitions, the system enters recovery mode and allows you to select the device you want to mount as the root filesystem. Once you select a device, recovery mode displays a list of rescue operations (Figure 3-17): • Execute a shell in /dev/xxx Mounts the device you selected (/dev/xxx) as / (root) and spawns a root shell (e.g., dash or bash; Chapter 7) if a shell is available on the mounted device. You are working with root privileges (page 88) and can make changes to the filesystem on the device you selected. You have access only to the shell and utilities on the mounted filesystem. You may be able to mount other filesystems. If the mounted filesystem does not include a shell, you must use the next selection. Give an exit command to return to the list of rescue operations. • Execute a shell in the installer environment Mounts the device you selected as /target and spawns a root dash shell (Chapter 7). You are
66 Chapter 3 Step-by-Step Installation
working in the installer environment with root privileges (page 88). You have access to dash and the many utilities available in the installer environment. The root filesystem is on a RAM disk (page 1056) and you can use nano to edit files. You can make changes to the filesystem on the device you selected, which is mounted on /target. You can mount other filesystems. Give an exit command to return to the list of rescue operations. • Choose a different root file system Returns to the previous step where you can select a filesystem to work with. • Reboot the system Reboots the system. Remove the CD if you want to boot from the hard disk.
The Server CD Initial Install Screen Menu The Server CD uses the textual installer (page 67) to install a minimal system with a textual interface and no open ports. The installed system is appropriate for a server. The initial install screen takes advantage of the functions keys described on page 62 and accepts the boot parameters described on page 63. The Server CD initial install
Figure 3-18
The DVD initial install screen
Advanced Installation 67
screen has the following selections that are not present on the live/install Desktop CD initial install screen (page 62): Install to the hard disk
Rescue a broken system
Installs a textual Ubuntu server system using the textual installer. For more information refer to “The Ubuntu Textual Installer” on page 67. At the end of the normal installation, the installer displays the Software selection screen, which asks if you want to install a DNS server (Chapter 25) and/or a LAMP server. LAMP stands for Linux (which you are installing), Apache (Chapter 27), MySQL, and PHP. Use the ARROW keys to move the highlight to the space between the brackets ([ ]) and press the SPACE BAR to select either or both of the choices. Brings Ubuntu up in recovery mode (page 65).
The DVD The Ubuntu DVD does everything each of the CDs does and includes all software packages supported by Ubuntu, not just those installed by default. If the system you are installing is not connected to the Internet, you can install software packages from the DVD but you will have no way to update the system. The initial install screen takes advantage of the functions keys described on page 62 and accepts the boot parameters described on page 63. Figure 3-18 shows the DVD initial install screen. See the descriptions of the CD initial install screens on pages 62, 65, and 66 for information on the selections on this screen.
The Ubuntu Textual Installer The Ubuntu textual installer gives you more control over the installation process than the Ubuntu graphical installer does (page 48). The textual installer displays a pseudographical interface and uses fewer system resources, including less RAM than the graphical installer does. You can install either a graphical (desktop) or textual (command line) system using the textual installer, depending on which CD/DVD you use and which selection you make from the initial install screen: Install in text mode installs a graphical system; Install a server and Install a command-line system install textual systems. Many of the screens that the textual installer displays parallel the screens displayed by the graphical installer. Within the textual installer’s screens, TAB moves between items, ARROW keys move between selections on a list, and RETURN activates the highlighted selection and causes the installer to display the next screen. A few screens include brackets ([ ]) that function similarly to check boxes; they use an asterisk in place of a tick. Use the ARROW keys to move the highlight to the space between the brackets and press the SPACE BAR to place an asterisk between the brackets and select the adjacent choice. Press the SPACE bar again to remove the asterisk.
68 Chapter 3 Step-by-Step Installation
Figure 3-19
The Ubuntu installer main menu
The Ubuntu installer main menu (the contents of this menu varies—Figure 3-19 shows an example) allows you to go directly to any step of the installation process or enter recovery mode (see “Rescue a broken system” on page 65). At the lower left of most textual installer screens is . See Figure 3-20 for an example. Use the TAB key to highlight this item and press RETURN to display the Ubuntu installer main menu. You may have to back up through several screens to display this menu. The first screen the textual installer displays is Choose a language (Figure 3-20). Use the UP and DOWN arrow keys to select the language you want the installer to use. You can type the first letter of the language to move the highlight to the vicinity of the language you want to choose. This language will be the default language for the installed system; you can change the default once the system is installed (page 132). Press RETURN to select the highlighted language and display the next screen. The installer steps through a series of screens, each of which has an explanation and asks a question. Use the ARROW keys and/or TAB key to highlight an answer or selection and press RETURN on each of the screens. After a few screens, the installer detects and installs programs from the CD/DVD, detects the network hardware, and configures it with DHCP (if available). As it is configuring the network, the installer asks you for the hostname of the system you are installing. For use on a local network and to connect to the Internet with a Web browser or other client, you can make up a simple name. If you are setting up a server, see “FQDN” on page 847 for information on names that are valid on the Internet.
Advanced Installation 69
Figure 3-20
The Choose a language screen
After this step, the installer continues detecting hardware, starts the partitioner, and displays the Partitioning method screen (Figure 3-21). Many of the selections available from the textual partitioner parallel those available from the graphical partitioner. This section describes how to use the textual partitioner to partition a hard disk manually. See page 56 for a description of guided partitioning.
Figure 3-21
The Partitioning method screen
70 Chapter 3 Step-by-Step Installation
Figure 3-22
The Partition overview screen I
Manual Partitioning When you select Manual from the Partitioning method screen (Figure 3-21), the textual partitioner displays the Partition overview screen, which lists the hard disks in the system and partitions on those disks. If a hard disk has no partitions, the partitioner displays only information about the hard disk. Figure 3-22 shows a single 200+-megabyte hard disk (highlighted) that has no partition table (and no partitions). If you want to set up RAID, see page 73 before continuing. Creating a partition table
If the Partition overview screen shows no partitions and no free space on a hard disk, as it does in Figure 3-22, the hard disk does not have a partition table: You need to create one. If this screen shows at least one partition or some free space, the disk has a partition table and you can skip this step and continue with “Creating a partition” below. To create a partition table, highlight the disk you want to create a partition table on and press RETURN. The installer asks if you want to create a new partition table on the device and warns that doing so will destroy all data on the disk. Highlight Yes and press RETURN. The installer displays the Partition disks screen showing the disk with a single block of free space as large as the disk (Figure 3-23).
Creating a partition
To create a partition, highlight the line with FREE SPACE on it and press RETURN. The partitioner asks how you want to use the free space; highlight Create a new partition and press RETURN. Next the partitioner asks you to specify the size of the new partition. You can enter either a percentage (e.g., 50%) or a number of gigabytes followed by GB (e.g., 30 GB). Press RETURN. The partitioner then asks you to specify the type of the new partition (primary or logical; page 31) and asks whether you want to create the partition at the beginning or the end of the free space. It does not usually matter where you create the partition. After answering each of these questions, press RETURN. The partitioner then displays the Partition settings screen (Figure 3-24). To change a setting on the Partition settings screen, use the ARROW keys to move the highlight to the setting you want to change and press RETURN. The partitioner displays a screen that allows you to change the setting.
Advanced Installation 71
Figure 3-23
The Partition overview screen II
Specifying a partition type (Use as)
The first line, labeled Use as, allows you to specify the type of filesystem the installer creates on the partition. This setting defaults to ext3, which is a good choice for most normal filesystems. If you want to change the filesystem type, move the highlight to this line and press RETURN; the installer displays the How to use this partition screen (Figure 3-25 on the next page). You can select swap area (page 32), RAID (next), LVM (page 35), or another type of filesystem. Table 13-1 on page 570 lists some common types of filesystems. Move the highlight to the selection you want and press RETURN. The partitioner returns to the Partition settings screen, which now reflects the selection you made. For a swap area, there is nothing else to set up; skip to “Done setting up the partition” on the next page.
Specifying a mount point
The mount point defaults to / (root). To change the mount point for the filesystem, highlight the line labeled Mount point and press RETURN. The partitioner displays a
Figure 3-24
The Partitions settings screen
72 Chapter 3 Step-by-Step Installation
Figure 3-25
How to use this partition screen
screen that allows you to specify a mount point (Figure 3-26). Select a mount point; if the mount point you want to use is not listed, select Enter manually. Press RETURN. The bootable flag
Typically the only other setting you need to change is the bootable flag. Turn this flag on for the /boot partition if the system has one; otherwise, turn it on for the / (root) partition. To change the state of the bootable flag, highlight the line labeled Bootable flag on the Partition settings screen and press RETURN. After a moment, the partitioner redisplays the screen showing the changed state of this flag.
Done setting up the partition
Once the partition settings are satisfactory, highlight Done setting up the partition and press RETURN. The partitioner displays the Partition overview screen showing the new partition setup. To create another partition, repeat the steps starting with “Creating a partition” on page 70. To modify a partition, highlight the partition and press RETURN.
Write the partitions to disk
When you are satisfied with the design of the partition table(s), highlight Finish partitioning and write changes to disk and press RETURN. After giving you another chance to back out, the partitioner writes the partitions to the hard disk.
Figure 3-26
Mount point screen
Advanced Installation 73
Figure 3-27 Time zone, user account, and video modes
The partitioner ready to set up RAID
The installer continues by asking which time zone the computer is in and if the system clock is set to UTC (page 1067). It then asks you to set up a user account and continues installing the system. Finally the installer asks you to select which video modes the X server will use. If you leave all entries unmarked, the X server uses the highest resolution the monitor is capable of displaying. The installer continues to install software and then finishes the installation. When the installer displays the Installation Complete window, remove the CD/DVD and click Restart now to reboot the system.
Setting Up a RAID Array To set up a RAID array (page 34), first create two or more partitions of the same size. Usually, these partitions will be on different hard disks. You create RAID partitions as explained in the preceding section, except instead of making the partitions type ext3 or swap, you declare each to be a RAID volume. (RAID partitions are referred to as volumes.) Once you have two or more RAID volumes, the partitioner allows you to combine these volumes into a RAID array that looks and acts like a single partition. The following example uses 100 gigabytes from each of two new hard disks to set up a 100-gigabyte RAID 1 array that is mounted on /home. Follow the instructions on page 70 to create a new partition table on each hard disk. Then create two 100gigabyte partitions, one on each disk. When the partitioner displays the How to use this partition screen (Figure 3-25, page 72), follow the instructions on page 71 and specify a partition type of physical volume for RAID. Figure 3-27 shows the partitioner screen after setting up the RAID volumes. Once you have at least two RAID volumes, the partitioner adds the Configure software RAID selection as the top line of its menu (highlighted in Figure 3-27).
74 Chapter 3 Step-by-Step Installation
Figure 3-28
Specifying the active devices in the RAID array
Highlight Configure software RAID, press RETURN, and confirm you want to write changes to the hard disk. From the next screen, select Create MD device (MD stands for multidisk) and press RETURN. Then select RAID 0, 1, or 5 and press RETURN. The different types of RAID arrays are described on page 35. The partitioner then asks you to specify the number of active devices (2) and the number of spares (0) in the RAID array. The values the partitioner enters in these fields are based on your previous input and are usually correct. Next select the active devices for the RAID array (use the SPACE BAR to put an asterisk before each device; Figure 3-28) and press RETURN. Select Finish from the next screen (the one that asks if you want to create an MD device again) and press RETURN. Now you need to tell the installer where to mount the RAID array. Highlight the RAID array. In the example, this line contains #1 100.0 GB FREE SPACE (this line is highlighted in Figure 3-29, but shown after the partition is created). Press RETURN. (If the RAID array line does not include the words FREE SPACE and does not show a partition, highlight the RAID array line, press RETURN, highlight Delete the Partition, and press RETURN. The RAID array line should now include FREE SPACE.) Set up this partition as you would any other by following the instructions under “Creating a partition” on page 70. In the example, the full 100 gigabytes is used for an ext3 filesystem mounted on /home. To complete this example, create a bootable / (root) partition using the rest of the free space on the first drive and a 4-gigabyte swap partition on the second drive. Figure 3-29 shows the Partition overview screen that includes these changes. Highlight Finish partitioning and write changes to disk and press RETURN.
The X Window System If you are installing a graphical desktop environment such as GNOME, you installed the X.org (x.org and freedesktop.org) implementation of the X Window System when you installed Ubuntu. The X Window System release X11R7.2 comprises almost 50 software packages. The X configuration files are kept in /etc/X11; the configuration file that guides the initial setup is /etc/X11/xorg.conf. You can edit
The X Window System
Figure 3-29
75
The finished partition tables
xorg.conf graphically using the Screen and Graphics Preferences window (discussed next) or you can edit it manually using a text editor (page 77).
displayconfig-gtk: Configures the Display Once the (graphical) system is installed, the Screen and Graphics Preferences window (Figure 3-30 on the next page) enables you to configure X.org, including specifying a monitor type and video (graphics) card. To display this window, select Main menu: SystemDAdministrationDScreens and Graphics or give the command gksudo displayconfig-gtk from a terminal emulator or Run Application window (ALT-F2). This utility modifies the xorg.conf file.
Back up xorg.conf tip Before you make any changes to /etc/X11/xorg.conf, whether graphically or manually, make a backup copy of this file. If you run into problems with the graphical interface, you can bring the system up in recovery mode (page 512), copy the backup over the new xorg.conf, and reboot the system. Specifying monitors
The Screen tab of the Screen and Graphics Preferences window allows you to specify the model, resolution, and frequency of one or two monitors. If you specify two monitors, it enables you to specify one as the primary monitor and to describe the spacial relationship of the two monitors. Click Screen 1 on the left of the window to specify the characteristics of one monitor; click Screen 2 to specify the other. If there is only one monitor, click the radio button labeled Disabled for one of the monitors.
76 Chapter 3 Step-by-Step Installation
Figure 3-30
The Screen and Graphics Preferences window, Screen tab
Normally the system probes the monitors and fills in the values in this window. If these values are missing, click the box labeled Model. The displayconfig-gtk utility displays the Choose window. Specify the manufacturer and model of the monitor in this window. If an appropriate model is not listed, scroll to the top of the Manufacturer list and click Generic. From the Model list, select an LCD or conventional monitor with the maximum resolution of the monitor attached to the system. Click OK. You can specify a lower default resolution and the frequency of the monitor from the two spin boxes labeled Resolution and at. No harm is done if you specify a lower resolution than the monitor is capable of displaying, but you can damage an older monitor by specifying a resolution higher than the monitor is capable of displaying. When you are done, click Test at the bottom of the window to check whether the new settings work. The displayconfig-gtk utility displays the desktop using the new settings with a dialog box asking Do you want to keep the current configuration? Click Cancel or wait 15 seconds to keep the old configuration; click Keep configuration to keep the new configuration. Specifying a graphics card
Next click the Graphics Card tab (Figure 3-31). The system normally probes for the model of video card and enters an appropriate selection in the box labeled Driver. You can manually select a graphics card by clicking the box labeled Driver; displayconfiggtk opens Choose Graphics Card Driver window (also in Figure 3-31). Near the top of this window are two radio buttons that enable you to select a driver by specifying the manufacturer and model of the graphics card in the system or by specifying the name of the driver you want to use. Click OK. The displayconfig-gtk utility generates an xorg.conf file with the information from the window.
The X Window System
Figure 3-31
77
The Screen and Graphics Preferences window, Graphics Card tab
The xorg.conf File If you choose to edit /etc/X11/xorg.conf manually, read the notes at the top of the file. You may also want to refer to the xorg.conf man page. The xorg.conf file comprises sections that can appear in any order. Each section is formatted as follows: Section "name" entry ... EndSection where name is the name of the section. A typical entry occupies multiple physical lines but is one logical line, consisting of multiple sets of a keyword followed by zero or more integer, real, or string arguments. Keywords in these files are not case sensitive; underscores (_) within keywords are ignored. Most strings are not case sensitive, and SPACEs and underscores in most strings are ignored. All strings must appear within double quotation marks. The Option keyword provides free-form data to server components and is followed by the name of the option and optionally a value. All Option values must be enclosed within double quotation marks. Boolean Options take a value of TRUE (1, on, true, yes) or FALSE (0, off, false, no); no value is the same as TRUE. You can prepend No to the name of a Boolean Option to reverse the sense of the Option.
78 Chapter 3 Step-by-Step Installation
The following sections can appear in an xorg.conf file: ServerFlags ServerLayout Files Module InputDevice Monitor Device Screen VideoAdaptor Modes DRI Vendor
Global Options (optional) Binds Screen(s) and InputDevice(s) Locations of configuration files Modules to be loaded (optional) Keyboard(s) and pointer(s) Monitor(s) Video card(s) Binds device(s) and monitor(s) Configures the Xv extension (optional) Video modes (optional) Direct Rendering Infrastructure (optional) Vendor-specific information (optional)
This chapter covers the sections you most likely need to work with: ServerLayout, InputDevice, Monitor, Device, and Screen.
ServerLayout Section The ServerLayout section appears first in some xorg.conf files because it summarizes the other sections that specify the server. The following ServerLayout section names the server single head configuration and specifies that the server comprises the sections named Screen0, Mouse0, Keyboard0, and DevInputMice. The term core in this file means primary; there must be exactly one CoreKeyboard and