Ubuntu® 1.4inux Bible

William von Hagen

111c10,ITENNIAL. 18072 @WILEY 2007 •ICIOATENNIAl. Wiley Publishing, Inc. Acknowledgments xxi Introduction xxiii

Part 1: Getting Started with

Chapter 1: The Ubuntu Linux Project 3 Background 4 Why Use Linux 4 What Is a ? 5 Introducing Ubuntu Linux 6 The Ubuntu Manifesto 7 Ubuntu Linux Release Schedule 8 Ubuntu Update and Maintenance Commitments 9 Ubuntu and the Project 9 Why Choose Ubuntu? 10 Installation Requirements 11 Supported System Types 12 Hardware Requirements 12 Time Requirements 12 Ubuntu CDs 13 Support for Ubuntu Linux 14 Community Support and Information 14 Documentation 17 Commercial Support for Ubuntu Linux 18 Getting More Information About Ubuntu 19 Summary 20 Chapter 2: Installing Ubuntu 21 Getting a 64-bit or PPC Desktop CD 22 Booting the Desktop CD 22 Installing Ubuntu Linux from the Desktop CD 24 Booting Ubuntu Linux 33 Booting Ubuntu Linux an Dual-Boot Systems 33 The First Time You Boot Ubuntu Linux 34 Test-Driving Ubuntu Linux 34 Expioring the Desktop CD's Examples Folder 34 Accessing Your Hard Drive from the Desktop CD 36 Using Desktop CD Persistence 41 Copying Files to Other Machines Over a Network 43 Installing Windows Programs from the Desktop CD 43 Summary 45 ix

Contents

Chapter 3: Installing Ubuntu on Special-Purpose Systems 47 Overview of Dual-Boot Systems 48 Your Computer's Boot Process 48 Configuring a System for Dual-Booting 49 Repartitioning an Existing Disk 49 Getting a Different Install CD 58 Booting from a Server or Altemate Install CD 58 Install Options on the Server Install CD 59 Installing an Ubuntu Server 60 Manually Specifying Your Partition Layout 73 Installing an Ubuntu LAMP Server 81 Booting Your Server for the First Time 81 Install Options on the Altemate Install CD 82 Installing an Ubuntu Desktop System in Text Mode 83 Installing Ubuntu Linux in OEM Mode 84 Installing a Server from the Alternate Install CD 85 Summary 86

Part II: Ubuntu for Desktop Users

Chapter 4: Basic Linux System Concepts 89 Working with Files and Directories 89 Standard Linux Directories 90 Other Common Directories on Linux Systems 91 Introduction to Linux Filesystems 92 Disks, Partitions, and Mount Points 92 Local Filesystems: Standard and Journaling 93 Network Filesystems 95 Working with Partitions and Filesystems 95 Mounting Filesystems 96 Automatically Mounting Filesystems at Boot Time 98 Automatically Mounting Removable Media Filesystems 101 Understanding Linux Permissions 101 Basic Concepts: Users and Groups 102 File and Directory Permissions Under Linux 103 Default Permissions When Creating Files and Directories 104 Performing Privileged Operations in Ubuntu 104 Summary 106 Chapter 5: Using the GNOME Desktop 107 What's a Desktop? Graphical Environments for Linux 107 Using the Mouse 110 GNOME Desktop Overview 110 GNOME Application Windows 112 Menus in GNOME 113 Panel Menus 113 Context-Sensitive Menus 116 Customizing Menus 117

X Contents

Customizing Your Desktop 123 Customizing Mouse Behavior 123 Configuring Display Resolution 125 Customizing Panels 127 Configuring the Screensaver 132 Changing Desktop Backgrounds 133 Switching Themes 134 Assistive Technologies for Using GNOME 136 GNOME Keyboard Shortcuts 137 Introducing the Nautilus File Manager 138 Basic Operations in Nautilus 139 Examples of Using Nautilus 140 Getting More Information About Nautilus 143 Using a Window Manager 143 Summary 148 Chapter 6: Using Command-Line Tools 149 Why Use the Command Line? 150 Executing Commands from the Command Line 150 What's a Shell? 156 Getting to a Shell 158 Using the GNOME Terminal Application 158 Using the X Window System Terminal Application 160 Popular Command-Line Commands 163 Moving Around in the Linux Filesystem 163 Copying, Moving, Renaming, and Deleting Files and Directories 164 Changing File and Directory Permissions 168 Finding Commands That Do Specific Things 170 Working with the Shell 171 Using Command History 171 Using Command and Filename Completion 172 Using Wildcards 173 Pipes and Input and Output Redirection 174 Introducing Job Control 175 Exploring the Bash Configuration File 176 Using Environment Variables 177 Defining and Using Aliases 179 Summary 179 Chapter 7: Working with Text Files an Ubuntu 181 Introduction to Linux Text Editors 182 Using vi 183 Starting and Exiting vi 184 Inserting Text in vi 185 Moving Around in vi 186 Deleting and Changing Text in vi 187 Cutting, Copying, and Pasting in vi 187 Searching for and Replacing Text in vi 188 Undoing Changes in vi 190 Using Multiple Windows in vi 190 Customizing 191

XI Contents

Graphical Versions of vi 193 More Information About vi and vim 193 Using emacs 194 A Few Words About emacs Commands 197 Emacs Terminology 198 Starting and Exiting emacs 199 Moving Around in emacs 202 Cutting, Copying, and Pasting in emacs 203 Searching for and Replacing Text in emacs 203 Working with Multiple Windows and Buffers in emacs 203 Customizing emacs 204 Getting More Information About emacs 206 Using 206 Other Text Editors for Ubuntu 208 Summary 209 Chapter 8: Reading and Sending Mail with Evolution 211 Starting Evolution 212 Using the. Evolution Setup Assistant 213 Sending and Receiving Mail 222 Sending Mail in Evolution 225 Setting Evolution Preferences for Sending and Viewing Mail 227 Undeleting Mail Messages 229 Creating and Using Mail Folders 230 Using Search Folders 231 Filtering Incoming Mail 234 Automatically Processing Incoming Mail 234 Automatically Checking for Junk Mail 237 Additional Sources of Information About Evolution 238 Summary 239 Chapter 9: Surfing the Wels with Firefox 241 A Quick History of Firefox 241 Starting Firefox 242 The Firefox User Interface 244 Standard Parts of a Firefox Window 244 Using the Mouse in Firefox 245 Special and Not-So-Special Firefox Features 246 Configuring Firefox 248 Setting Your Home Page 248 Controlling Popups, JavaScript, and More 249 Configuring Your Privacy Settings 250 Workingwith ...... 253 Creating Bookmarks in Firefox 253 Managing Your Bookmarks 255 Creating Live Bookmarks 256 Enhancing Firefox 258 Adding Firefox Extension 258 Adding New Firefox Themes 261 Summary 263 xii Contents

Chapter 10: Creating and Publishing Documents 265 Using Document Markup Languages on Ubuntu 266 Installing TeX on Your Ubuntu System 266 Using TeX Markup 267 Introducing LaTeX Markup 269 Formatting and Previewing DVI Files 270 Using Graphical Tools to Work with TeX and LaTeX 271 More Information About TeX and LaTeX 273 Word Processing with OpenOffice.org Writer 274 Installing Files for Writer 275 Taking a Quick Tour of Writer 276 Personalizing Writer 279 Using Wizards to Create Documents 280 Modifying Document Styles and Layout 283 Creating and Using Templates 286 Importing Documents from Other Word Processors 288 More Information About Writer 291 Desktop Publishing with Scribus 291 Installing Scribus on Ubuntu 292 Taking a Quick Scribus Tutorial 293 More Information About Scribus 301 Other Word Processors and Office Suites for Linux 301 Summary 302 Chapter 11: Other Office : Spreadsheets and Presentations . . . 303 Introduction to Spreadsheets: A Quick Tutorial 304 Using 314 Starting Gnumeric 315 Taking a Quick Tour of Gnumeric 315 Invoking Functions in Gnumeric 317 Specifying the Type of Data in a Cell 318 Importing Existing Spreadsheets 321 Using OpenOffice.org Calc 322 Installing Files for OpenOffice.org Calc 322 Starting Calc 323 Taking a Quick Tour of Calc 324 Invoking Functions in Calc 326 Specifying the Type of Data in a Cell 326 Importing Existing Spreadsheets 328 Using OpenOffice.org Impress 332 Installing Files for Impress 332 Starting Impress 333 Taking a Quick Tour of Impress 336 Creating a Presentation 339 Importing Existing Presentations 340 Summary 341 Contents

Chapter 12: Working with Graphics 343 Overview of Digital Graphics Terminology 343 Using GIMP 346 Starting GIMP 347 A Quick Tour of GIMP 348 Sample GIMP Tasks 350 More Information About GIMP 356 Using OpenOffice.org Draw 356 Installing OpenOffice.org Draw 357 Starting Draw 358 A Quick Tour of Draw 358 More Information About OpenOffice.org Draw 360 Using for Vector Graphics 360 Installing Inkscape 361 Starting Inkscape 362 A Quick Tour of Inkscape 362 More Information About Inkscape 363 Summary 364 Chapter 13: Working with Multimedia 365 Overview of Digital Audio and Video Terminology 365 Configuring Sound Devices, Levels, and System Sounds 370 Testing and Customizing System Sounds 370 Setting System Sound Levels 372 Getting Detailed Information About Your Sound Hardware 376 Setting CD and DVD Preferences 377 Installing the Framework and Plug-ins 379 Working with CDs 382 Playing CDs Using 383 Ripping CDs Using Sound Juicer 384 Burning CDs Using Serpentine 386 Working with Other Audio Sources 388 Playing Audio Files and Internet Radio Using 388 Converting Audio File Formats 394 Working with DVDs an Ubuntu 398 Playing DVDs 398 Ripping DVDs 400 Copying DVDs and Burning DVD Images Using k3b 400 Summary 406 Chapter 14: Would You Like to Play a Garne? 409 Default GNOME Garnes 409 Card Garnes 410 Board Garnes 414 Video Garnes 419 Other Popular Garnes in the Ubuntu Repositories 424 Billions and Billions of Versions of Chess 424 Go 429 Monopoly Clones 430 Scrabble Clones 434 Summary 435 xiv Contents

Chapter 15: Connecting to Other Systems 437 Establishing Secure Connections to Other Systems 437 Logging in to Remote Systems Using ssh 438 Enabling the SSH Daemon on Your System 439 Connecting to Other Systems Using VNC 441 Getting VNC Client and Server Software for Your Other Platforms 441 Using vncviewer 445 Connecting to Remote Servers 448 Using for Terminal Server Connections 449 Using for Terminal Server Connections 452 Using Other Remote Connection Software 453 Summary 454 Chapter 16: File Transfer and Sharing on Ubuntu 455 Transferring Files to Other Systems 456 Using FTP 456 Accessing Shares on Remote Windows Systems 463 Accessing NFS Directories from Linux Systems 466 Peer-to-Peer File Sharing on Ubuntu 467 Installing and Using -gnutella 468 Using BitTorrent on Ubuntu 472 Summary 476 Chapter 17: Consumer Electronics and Ubuntu 477 Configuring Your System for Consumer Electronics Devices 478 Configuring Digital and Digital Video Camera Recognition 478 Configuring iPod and Other Digital Audio Player Recognition 479 Configuring PDA and Smart Phone Recognition 480 Configuring Flash Card and Other Digital Media Recognition 481 Digital Cameras and Ubuntu 482 PDAs, Smart Phones, and Ubuntu 485 Configuring and Synchronizing Palm OS Devices 486 Synchronizing Data with Microsoft Windows Devices 491 iPods, Other Digital Audio Players, and Ubuntu 496 Working with an iPod from Ubuntu 497 Working with Other Digital Audio Players 508 Reading CompactFlash and SD Cards 509 Summary 510 Chapter 18: Software Development on Ubuntu 513 Installing and Using Development Software on Ubuntu 514 Installing GCC Compilers, make, and Friends 514 GCC Compiler Overview 516 Using GCC's Compiler 516 Creating Simple Makefiles 517 Using an Integrated Development Environment 519 Popular IDEs for Linux 519 Installing Eclipse 521 Using Eclipse for C Application Development 522 Getting More Information About Eclipse 537

XV Contents

Source Code Control Software 538 The Concurrent Versioning System (CVS) 538 Installing and Using Subversion 539 Summary 547

Part III: Ubuntu for System Administrators

Chapter 19: Understanding the Ubuntu Startup and Shutdown Processes . 551 Overview of the Ubuntu Linux Startup Process 551 The Boot Monitor or BIOS 552 The Boot Loader 552 Loading the Kemel 554 Loading and Using an Initial RAM Disk or RAM Filesystem 555 The Init Process 557 Examining the Boot Process with Boot Chart 558 Optimizing the Ubuntu Boot Process 560 The Ubuntu Linux Shutdown Process 564 Summary 566 Chapter 20: Adding, Removing, and Updating Software 567 Overview of Ubuntu Package Management Software 568 Ubuntu Repositories and Components 570 Enabling Additional Repository Components 571 Enabling Additional Repository Sources Using a Text Editor 572 Enabling Additional Repository Sources Using the Software Properties Tool 573 Problems Adding or Accessing Nonstandard Repositories 577 Mixing Ubuntu and Debian Repositories 578 Exploring Your System Using and Friends 580 Listing the Packages that are Installed an Your System 581 Listing the Packages that are Available for Your System 582 Listing Information About a Package 585 Listing the Contents of a Package 586 Determining What Package Provides an Existing File 587 Determining What Package Provides a Missing File 588 Using -get to Add and Remove Software 588 Upgrading Your System Using apt-get 590 Smart System Upgrades Using apt-get 590 Retrieving Package Source Code Using apt-get 590 Satisfying Build Dependencies Using apt-get 592 Using to Add and Remove Software 592 Tips and Tricks for Using the aptitude User Interface 593 Using aptitude to Install Recommended Software 595 Advantages of Using aptitude to Install and Remove Software 596 Using to Add and Remove Software 597 Configuring Synaptic Preferences 599 Searching for Software in Synaptic 601 Installing Packages in Synaptic 603 Removing Packages in Synaptic 607 xvi Contents

Using the Ubuntu Update Manager 609 Converting Packages from Other Package Formats 610 Keeping your System Lean, Mean, and Pristine 613 Summary 614 Chapter 21: Managing Users, Groups, Authentication, and Advanced Permissions 615 Creating and Managing Users and Groups 616 Creating New Users 617 Managing Existing Users 622 Creating New Groups 624 Managing Existing Groups 625 PAMs and the Linux Authentication Process 626 PAM Configuration Files for Applications and Services 628 Example: PAMs Used by the Login Process 629 Configuration Files for Various PAMs 632 What If PAM Configuration Files Are Missing? 632 Customizing the sudo Command an Ubuntu Systems 633 Using ACLs for Sophisticated File Sharing 636 Overview of Linux ACLs 637 Installing ACL Commands an Ubuntu 637 Activating Filesystem Support for ACLs 638 Working with ACLs from the Command Line 639 Working with ACLs Using Graphical Tools 641 Summary 645 Chapter 22: Backing Up and Restoring Files 647 101 648 Why Do Backups? 648 Different Types of Backups 649 Verifying and Testing Backups 652 Deciding What to Back Up 653 Software for Linux 653 Local Backup and Restore Software for Linux 654 Network-Oriented Backup Software for Linux 656 Backing Up Files to Local, Removable Media 658 Archiving and Restoring Files Using 659 Making an Up-to-Date Copy of a Local Directory Using cp 660 Making an Up-to-Date Copy of a Remote Directory Using 661 Installing and Using the backuppc Utility 663 Installing backuppc 664 Configuring backuppc 665 Identifying Hosts to Back Up 666 Defining a Backup Using rsyncd 667 Defining a Backup Using SMB 669 Starting Backups in backuppc 670 Restoring from Backups in backuppc 672 Summary 676

xvii Contents

Chapter 23: Adding Hardware and Attaching Peripherals 677 Adding a Printer 678 Using a Scanner 683 Using External Disks and CD/DVD Drives 689 Configuring Automatic Device Detection 689 Troubleshooting Automatic Device Detection 690 Adding Internal Disks and CD/DVD Drives 691 Adding EIDE/ATA Drives 692 Adding SATA Drives 693 Adding SCSI Drives 693 Troubleshooting Boot Problems After Adding New Drives 694 Locating, Partitioning, and Formatting New Drives 696 Using PCMCIA Cards 704 Adding PCI Cards 705 Examining and Troubleshooting Devices Graphically 707 Summary 709 Chapter 24: Network Configuration and Security 711 Networking 101 712 Manually Configuring Your Network Hardware 715 Manually Configuring Modem Connections 719 Defining and Using Multiple Network Configurations 721 Network Testing with GNOME's Network Tools 723 Tips for Securing Your System 726 Installing a Firewall 727 Overview of Linux Firewalling and Packet Filtering 728 Installing and Configuring a Firewall Using Lokkit 729 Summary 734 Chapter 25: Going Wireless 735 Overview of Wireless Technologies 735 Configuring Wireless Ethernet Interfaces 738 Command-Line Tools for Wireless Networking 741 Installing and Using Windows Networking Drivers 742 Installing NDIS Wrapper and Friends 743 Installing Microsoft Windows Drivers 744 NDIS Wrapper Tips and Tricks 747 Summary 749 Part IV: Configuring Servers an Ubuntu

Chapter 26: Setting Up a Web Server 753 World Wide Web 101 753 Introduction to Web Servers and Apache 755 Installing Apache 756 Installing Apache from the Command Line 757 Installing Apache Using Synaptic 757

xviii Contents

Apache 2 File Locations 758 Configuring Apache 759 Troubleshooting 763 More Information 764 Summary 765 Chapter 27: Setting Up a Mail Server 767 Introduction to Mail Servers 768 Popular Linux Mail Transfer Agents 768 Why Run Your Own Mail Server? 770 Installing Postfix and Friends 771 Built-in Postfix Configuration Models 772 Installing Postfix and Friends from the Command Line 772 Installing Postfix and Friends Using Synaptic 775 Configuring Postfix 777 Postfix Configuration Files 778 Identifying Trusted Hosts and Domains 780 Rewriting Addresses in Outgoing Mail 780 Accepting Mail for an Entire Domain 781 Activating Qpopper for POP/POP3 Support 781 Adding SPAM Filtering and Virus Scanning to Postfix 782 Greylisting via postgrey 783 Adding Postfix Parameters to Reject Bogus Mail 784 Integrating MailScanner, SpamAssassin, and CIamAV with Postfix 786 More Information 788 Summary 788 Chapter 28: Setting Up a DHCP Server 791 Overview of DHCP 792 Installing a DHCP Server 795 Managing a DHCP Server from the Command Line 796 Creating DHCP Configuration Files Using a Text Editor 796 Specifying Additional DHCP Server Configuration File Entries 797 Managing a DHCP Server Graphically 798 Troubleshooting DHCP 803 Summary 803 Chapter 29: Setting Up a DNS Server 805 Overview of DNS and BIND 806 Installing a DNS Server Using Synaptic 808 Overview of BIND Configuration Files 809 Creating DNS Zone and Reverse Lookup Files 811 Using Common Entries for Zone and Reverse Lookup Files: SOA and $TTL 811 Creating Zone Files 813 Creating Reverse Lookup Files 815 Incorporating Zone and Reverse Lookup Files with BIND 816 Restarting and Testing Your Name Server 817 Troubleshooting DNS 818 Getting More Information about DNS and BIND 821 Summary 821

xx Contents

Chapter 30: Setting Up a Print Server ...... 823 Linux and Unix Printing History 823 Enabling Remote Hosts to Access Your CUPS Print Server 824 Enabling Administrative Operations via the CUPS Web Interface 826 Integrating Windows Printing with an Ubuntu Print Server 826 Integrating Mac OS X Printing with an Ubuntu Print Server 828 Troubleshooting Remote Printing 831 Checking the CUPS Log Files 831 Accessing Controls for Portions of the CUPS Web Interface 832 Handling Preformatted print Jobs 832 Getting More Information About CUPS 833 Summary 833 Chapter 31: Setting Up an NFS Server 835 Overview of the Network File System 836 Understanding how NFS Works 837 Comparing Different Versions of NFS 838 Installing an NFS Server and Related Packages 839 Using the Shared Folder Tool to Export Directories 840 Verifying NFS Operations 845 Manually Exporting Directories in Jetc/exports 847 Getting More Information About NFS and Related Software 848 Summary 849 Chapter 32: Setting Up a Samba Server 851 Overview of Microsoft Windows File Sharing 851 Introducing Samba 853 Installing the Samba Server and Friends 853 Samba Server Configuration Essentials 854 Identifying Your Workgroup or Domain 855 Configuring Samba Authentication 856 Sharing Printers and Home Directories Using Samba 856 Verifying the Samba Configuration File 858 Testing Samba Availability and Services 859 Using the Shared Folder Tool to Share Directories 861 Getting More Information About Samba 865 Summary 865

h-edex 000000•••••••• ...... 871 Contents

Chapter 30: Setting Up a Print Server ...... • • 0 • • • . 823 Linux and Unix Printing History 823 Enabling Remote Hosts to Access Your CUPS Print Server 824 Enabling Administrative Operations via the CUPS Web Interface 826 Integrating Windows Printing with an Ubuntu Print Server 826 Integrating Mac OS X Printing with an Ubuntu Print Server 828 Troubleshooting Remote Printing 831 Checking the CUPS Log Files 831 Accessing Controls for Portions of the CUPS Web Interface 832 Handling Preformatted print Jobs 832 Getting More Information About CUPS 833 Summary 833 Chapter 31: Setting Up an NFS Server 835 Overview of the Network File System 836 Understanding how NFS Works 837 Comparing Different Versions of NFS 838 Installing an NFS Server and Related Packages 839 Using the Shared Folder Tool to Export Directories 840 Verifying NFS Operations 845 Manually Exporting Directories in fetc/exports 847 Getting More Information About NFS and Related Software 848 Summary 849 Chapter 32: Setting Up a Samba Server 851 Overview of Microsoft Windows File Sharing 851 Introducing Samba 853 Installing the Samba Server and Friends 853 Samba Server Configuration Essentials 854 Identifying Your Workgroup or Domain 855 Configuring Samba Authentication 856 Sharing Printers and Horne Directories Using Samba 856 Verifying the Samba Configuration File 858 Testing Samba Availability and Services 859 Using the Shared Folder Tool to Share Directories 861 Getting More Information About Samba 865 Summary 865 ll dex . . . • . • ...... 871

xx