• Master Linux for desktops, servers, and workstations • Find, install, and use loads of free and open source software • Create your own cool apps with useful programming tools • Launch
Trang 1Shelving Category:
COMPUTERS/
Operating Systems/Linux Reader Level:
Beginning to Advanced www.wiley.com/go/linuxbible2009
Start up a Linux desktop
or server computer
Migrate easily from
Try tons of Linux apps,
then install to hard disk
Negus
Run the world’s most popular free
operating system on your own computer
Get in on the Linux phenomenon! Play music and games,
publish on paper or on the Web, and communicate
step-by-step instructions and software for 18 diff erent
Linux distributions Whether you are an enterprising
do-it-yourselfer or an aspiring Linux professional, you
can start here on your path to software freedom.
• Master Linux for desktops, servers, and workstations
• Find, install, and use loads of free and open source software
• Create your own cool apps with useful programming tools
• Launch all your music, video, images, and documents in Linux
• Browse, e-mail, or chat over the Internet from a Linux desktop
• Set up your own e-mail and Web (LAMP) servers
• Make safe connections with fi rewalls and other security tools
DVD and CD-ROM Included
DVD Includes
• Ubuntu Linux (live/install)
• Fedora Linux (install)
• openSUSE (live/install)
• KNOPPIX (live/install)
• Freespire (live/install)
• Gentoo Linux (live/install)
• Slackware ® Linux (install)
• Debian GNU/Linux (live/install)
• Damn Small Linux (live/install)
• All software built for x86 computers
• See chapters on each distribution for system requirements
A total of 18 different Linux distributions are included
on the DVD and CD-ROM
• To try out Linux, boot directly KNOPPIX, openSUSE, Ubuntu, Gentoo, BackTrack,
and other live Linux distributions
• To keep Linux permanently, install Fedora, Ubuntu, openSUSE, Debian GNU,
Damn Small Linux, Slackware Linux, and other distributions to your hard disk
2009 Edition
Christopher Negus
DVD and CD-ROM Included
Run or install 18 different Linux distributions from the multi-boot DVD and CD-ROM!
Trang 32009 Edition
Trang 610475 Crosspoint Boulevard
Indianapolis, IN 46256
www.wiley.com
Copyright © 2009 by Wiley Publishing, Inc., Indianapolis, Indiana
Published simultaneously in Canada
ISBN: 978-0-470-37367-5
Manufactured in the United States of America
10 9 8 7 6 5 4 3 2 1
Library of Congress Cataloging-in-Publication Data is available from the publisher.
No part of this publication may be reproduced, stored in a retrieval system or transmitted in any form or by any means,
electronic, mechanical, photocopying, recording, scanning or otherwise, except as permitted under Sections 107 or 108
of the 1976 United States Copyright Act, without either the prior written permission of the Publisher, or authorization
through payment of the appropriate per-copy fee to the Copyright Clearance Center, 222 Rosewood Drive, Danvers, MA
01923, (978) 750-8400, fax (978) 646-8600 Requests to the Publisher for permission should be addressed to the Legal
Department, Wiley Publishing, Inc., 10475 Crosspoint Blvd., Indianapolis, IN 46256, (317) 572-3447, fax (317) 572-4355,
or online at http://www.wiley.com/go/permissions.
Limit of Liability/Disclaimer of Warranty: The publisher and the author make no representations or warranties with
respect to the accuracy or completeness of the contents of this work and specifically disclaim all warranties, including
without limitation warranties of fitness for a particular purpose No warranty may be created or extended by sales or
promotional materials The advice and strategies contained herein may not be suitable for every situation This work
is sold with the understanding that the publisher is not engaged in rendering legal, accounting, or other professional
services If professional assistance is required, the services of a competent professional person should be sought Neither
the publisher nor the author shall be liable for damages arising herefrom The fact that an organization or Web site is
referred to in this work as a citation and/or a potential source of further information does not mean that the author or
the publisher endorses the information the organization or Web site may provide or recommendations it may make
Further, readers should be aware that Internet Web sites listed in this work may have changed or disappeared between
when this work was written and when it is read.
For general information on our other products and services please contact our Customer Care Department within the
United States at (800) 762-2974, outside the United States at (317) 572-3993 or fax (317) 572-4002.
Trademarks: Wiley, the Wiley logo, Wrox, the Wrox logo, Wrox Programmer to Programmer, and related trade dress
are trademarks or registered trademarks of John Wiley & Sons, Inc and/or its affiliates, in the United States and other
countries, and may not be used without written permission Linux is a registered trademark of Linus Torvalds All other
trademarks are the property of their respective owners Wiley Publishing, Inc., is not associated with any product or
vendor mentioned in this book.
Wiley also publishes its books in a variety of electronic formats Some content that appears in print may not be available
in electronic books.
Trang 9Chris Negus has written or co-written dozens of books on Linux and UNIX, including Red
Hat Linux Bible (all editions), Fedora and Red Hat Enterprise Linux Bible, Linux Troubleshooting Bible, Linux Toys, and Linux Toys II Last year, Chris co-authored four books for the new Tool-
box series for power users: Fedora Linux Toolbox, SUSE Linux Toolbox, Ubuntu Linux Toolbox, and BSD UNIX Toolbox
For eight years, Chris worked with the organization at AT&T that developed UNIX before ing to Utah to help contribute to Novell’s UnixWare project in the early 1990s When not writing about Linux, Chris enjoys playing soccer and just hanging out with his family
Trang 11I consider anyone who has contributed to the free and open source software community to be a contributor to the book you are holding The backbone of any Linux distribution is formed by the organizations that produce the distributions, the major projects included in Linux, and the thou-sands of people who give their time and code to support Linux So, thanks to you all!
I’d like to acknowledge several contributors for their participation in previous editions Wayne Tucker wrote and then updated the chapters on Debian, LAMP servers, and mail servers Bill von Hagen contributed updates to the SUSE, Yellow Dog, and Ubuntu chapters Emmett Dulaney served as technical editor to this edition
Thanks to the folks at Wiley for helping me press through the project Jenny Watson helped me schedule the project so I could do the major rewrite needed to get all the latest Linux innovations
in the book Sara Shlaer did her usual great job keeping the project moving under a very ing schedule Liz Britten shepherded the book through the production process Thanks to Margot Maley Hutchison and Maureen Maloney from Waterside Productions for contracting the book for
challeng-me with Wiley
And finally, special thanks to my wife, Sheree There’s no way I could do the work I do without the solid support I get on the home front I love you, and thanks for taking such good care of Seth, Caleb, and me
Trang 13Part I: Getting off the Ground with Linux 1
Chapter 1: Starting with Linux 3
Chapter 2: Linux Projects, Activities, and Careers 15
Part II: Running a Linux Desktop 33
Chapter 3: Getting into the Desktop 35
Chapter 4: Playing Music and Video 81
Chapter 5: Working with Words and Images 117
Chapter 6: E-Mailing and Web Browsing 147
Chapter 7: Gaming with Linux 179
Part III: Learning System Administration Skills 205
Chapter 8: Installing Linux 207
Chapter 9: Running Commands from the Shell 237
Chapter 10: Learning Basic Administration 285
Chapter 11: Getting on the Internet 335
Chapter 12: Securing Linux 359
Part IV: Setting Up Linux Servers 407
Chapter 13: Running a Linux, Apache, MySQL, and PHP (LAMP) Server 409
Chapter 14: Running a Mail Server 431
Chapter 15: Running a Print Server 447
Chapter 16: Running a File Server 469
Part V: Choosing and Installing Different Linux Distributions 503
Chapter 17: Running Ubuntu Linux 505
Chapter 18: Running Fedora and Red Hat Enterprise Linux 523
Chapter 19: Running Debian GNU/Linux 547
Chapter 20: Running SUSE and openSUSE Linux 571
Chapter 21: Running KNOPPIX 585
Chapter 22: Running Yellow Dog Linux 607
Chapter 23: Running Gentoo Linux 619
Chapter 24: Running Slackware Linux 641
Trang 14Chapter 25: Running Freespire and Xandros 657
Chapter 26: Running Mandriva 667
Chapter 27: Running a Linux Firewall/Router 681
Chapter 28: Running Bootable Linux Distributions 707
Part VI: Programming in Linux 727
Chapter 29: Programming Environments and Interfaces 729
Chapter 30: Programming Tools and Utilities 759
Appendix A: Media 789
Appendix B: Linux History and Background 799
Index 819
Trang 15Part I: Getting off the Ground with Linux 1
Chapter 1: Starting with Linux 3
Taking Your First Step 4
What Comes in Linux Systems? 4
What Do You Need to Get Started? 5
Starting Right Now 6
Understanding Linux 10
What’s So Great About Linux? 13
Summary 14
Chapter 2: Linux Projects, Activities, and Careers 15
Making Things with Linux 16
Linux in Outer Space 16
Linux in Gadgets 17
Linux in Projects 19
Getting Involved with Linux 21
Joining a Linux User Group 21
Joining Linux Communities 22
Companies and Groups Supporting Linux 22
Keeping Up with Linux 23
Major Linux Projects 24
Exploring Linux Distributions 25
Linux in the Real World 27
Linux in Schools 27
Linux in Small Business 28
Linux in the Enterprise 29
Becoming a Linux Professional 30
Summary 31
Trang 16Part II: Running a Linux Desktop 33
Chapter 3: Getting into the Desktop 35
Understanding Your Desktop 35
Starting the Desktop 36
Boot to the Desktop 36
Boot to a Graphical Login 37
Boot to a Text Prompt 39
K Desktop Environment 39
Using the KDE Desktop 40
Managing Files with the Dolphin and Konqueror 44
Using the Dolphin File Manager 44
Using the Konqueror Web Browser/File Manager 49
Managing the KDE Desktop 52
Confi guring the Desktop 54
The GNOME Desktop 56
Using the Metacity Window Manager 58
Using the GNOME Panels 60
Using the Nautilus File Manager 64
3D Effects with AIGLX 67
Changing GNOME Preferences 69
Exiting GNOME 70
Confi guring a GNOME Online Desktop 71
Confi guring Your Own Desktop 73
Confi guring X 73
Choosing a Window Manager 77
Choosing Your Personal Window Manager 79
Getting More Information 79
Summary 80
Chapter 4: Playing Music and Video 81
Playing Digital Media and Obeying the Law 82
Copyright Protection Issues 82
Exploring Codecs 84
Playing Music 85
Using Sound Systems in Linux 86
Adjusting Sound with PulseAudio 86
Setting Up Audio Cards 88
Choosing an Audio CD Player 89
Using MIDI Audio Players 96
Performing Audio File Conversion and Compression 96
Recording and Ripping Music 99
Creating an Audio CD with cdrecord 100
Ripping CDs with Grip 101
Creating CD Labels with cdlabelgen 103
Trang 17Working with TV, Video, and Digital Imaging 104
Watching TV with tvtime 104
Video Conferencing with Ekiga 106
Watching Movies and Video 108
Watching Video with xine 108
Using Totem Movie Player 112
Using a Digital Camera 113
Displaying Images in gThumb 113
Using Your Camera as a Storage Device 114
Summary 115
Chapter 5: Working with Words and Images 117
Desktop Publishing in Linux 117
Using Text Editors and Notepads 118
Using Word Processors 119
Transitioning Documents from Windows 124
Converting Documents 126
Building Structured Documents 128
Doing Page Layout with Scribus 132
Working with Graphics 134
Manipulating Images with GIMP 134
Creating Vector Graphic Images with Inkscape 136
Acquiring Screen Captures 138
Viewing Images 139
Displaying PDF and PostScript Documents 141
Using the ghostscript and gv Commands 141
Using Adobe Reader 141
Using Scanners with SANE 143
Web Publishing 144
Summary 145
Chapter 6: E-Mailing and Web Browsing 147
Using E-Mail 147
Choosing an E-Mail Client 147
Getting Here from Windows 149
Getting Started with E-Mail 150
Tuning Up E-Mail 151
Reading E-Mail with Thunderbird 152
Managing E-Mail in Evolution 158
Reading E-Mail with SeaMonkey Mail 162
Working with Text-Based E-Mail Readers 162
Choosing a Web Browser 164
Exploring the SeaMonkey Suite 165
Using Firefox 166
Setting Up Firefox 168
Securing Firefox 172
Trang 18Tips for Using Firefox 173
Using Firefox Controls 174
Improving Firefox Browsing 175
Doing Cool Things with Firefox 176
Using Text-Based Web Browsers 177
Summary 178
Chapter 7: Gaming with Linux 179
Jumping into Linux Gaming 179
Overview of Linux Gaming 181
Basic Linux Gaming Information 182
Choosing Gaming Hardware for Linux 184
Running Open Source Linux Games 185
GNOME Games 186
KDE Games 187
Games in Fedora 188
Commercial Linux Games 195
Getting Started with Commercial Games in Linux 195
Playing Commercial Linux Games .196
id Software Games 197
Playing TransGaming and Cedega Games 198
Loki Software Game Demos 200
Summary 204
Part III: Learning System Administration Skills 205 Chapter 8: Installing Linux 207
Choosing a Linux Distribution 208
Linux at Work 208
Other Distributions 209
Getting Your Own Linux Distribution 209
Finding Another Linux Distribution 210
Understanding What You Need 210
Downloading the Distribution 211
Burning the Distribution to CD 212
Exploring Common Installation Topics 213
Knowing Your Computer Hardware 213
Upgrading or Installing from Scratch 215
Dual Booting with Windows or Just Linux? 215
Using Installation Boot Options 217
Partitioning Hard Drives 217
Using LILO or GRUB Boot Loaders 225
Confi guring Networking 235
Confi guring Other Administrative Features 235
Installing from the Linux Bible CD or DVD 236
Trang 19Chapter 9: Running Commands from the Shell 237
Starting a Shell 238
Using the Shell Prompt 238
Using a Terminal Window 239
Using Virtual Terminals 240
Choosing Your Shell 240
Using bash (and Earlier sh) Shells 241
Using tcsh (and Earlier csh) Shells 241
Using ash 242
Using ksh 242
Using zsh 242
Exploring the Shell 242
Checking Your Login Session 242
Checking Directories and Permissions 243
Checking System Activity 245
Exiting the Shell 246
Using the Shell in Linux 247
Locating Commands 248
Rerunning Commands 250
Connecting and Expanding Commands 256
Creating Your Shell Environment 259
Confi guring Your Shell 259
Using Shell Environment Variables 263
Managing Background and Foreground Processes 266
Working with the Linux File System 268
Creating Files and Directories 270
Moving, Copying, and Deleting Files 278
Using the vi Text Editor 278
Starting with vi 279
Moving Around the File 282
Searching for Text 282
Using Numbers with Commands 283
Summary 283
Chapter 10: Learning Basic Administration 285
Graphical Administration Tools 286
Using Web-Based Administration 286
Graphical Administration with Different Distributions 287
Using the root Login 291
Becoming Root from the Shell (su Command) 292
Allowing Limited Administrative Access 293
Exploring Administrative Commands, Confi guration Files, and Log Files 294
Administrative Commands 294
Administrative Confi guration Files 295
Administrative Log Files 299
Trang 20Using sudo and Other Administrative Logins .300
Administering Your Linux System 303
Creating User Accounts 303
Adding Users with useradd 303
Setting User Defaults 307
Modifying Users with usermod 309
Deleting Users with userdel 310
Confi guring Hardware 310
Managing Removable Hardware 311
Working with Loadable Modules 314
Managing File Systems and Disk Space 317
Mounting File Systems 319
Using the mkfs Command to Create a File System 326
Adding a Hard Disk 327
Checking System Space 330
Monitoring System Performance 332
Summary 333
Chapter 11: Getting on the Internet 335
Connecting to the Network 336
Connecting via Dial-Up Service 336
Connecting a Single Computer to Broadband 337
Connecting Multiple Computers to Broadband 338
Connecting Servers 339
Connecting Other Equipment 341
Using Ethernet Connections to the Internet 342
Confi guring Ethernet During Installation 342
Confi guring Ethernet from the Desktop 342
Using Network Confi guration GUI in Fedora 344
Identifying Other Computers (Hosts and DNS) 345
Using the Network Settings GUI in Ubuntu 347
Understanding Your Internet Connection 348
Using Dial-Up Connections to the Internet 351
Getting Information 351
Setting Up Dial-Up PPP 352
Creating a Dial-Up Connection with the Internet Confi guration Wizard 353
Launching Your PPP Connection 355
Launching Your PPP Connection on Demand 355
Checking Your PPP Connection 356
Checking That Your Modem Was Detected 356
Connecting to the Internet with Wireless 357
Summary 358
Chapter 12: Securing Linux 359
Linux Security Checklist 360
Finding Distribution-Specifi c Security Resources 363
Trang 21Using Linux Securely 365
Using Password Protection 365
Choosing Good Passwords 365
Using a Shadow Password File 367
Using Log Files 369
The Role of syslogd 372
Redirecting Logs to a Loghost with syslogd 372
Understanding the messages Log File 374
Using Secure Shell Tools 374
Starting the SSH Service 375
Using the ssh, sftp, and scp Commands 375
Using ssh, scp, and sftp without Passwords 377
Securing Linux Servers 378
Controlling Access to Services with TCP Wrappers 378
Understanding Attack Techniques 381
Protecting Against Denial-of-Service Attacks 382
Protecting Against Distributed DoS Attacks 385
Protecting Against Intrusion Attacks 389
Securing Servers with SELinux 392
Protecting Web Servers with Certifi cates and Encryption .393
Using Linux Live CD Security Tools 403
Advantages of Security Live CDs 403
Using INSERT to Check for Rootkits 403
Summary 405
Part IV: Setting Up Linux Servers 407 Chapter 13: Running a Linux, Apache, MySQL, and PHP (LAMP) Server 409
Components of a LAMP Server 410
Apache 410
MySQL 410
PHP 411
Setting Up Your LAMP Server 411
Installing Apache 412
Installing PHP 412
Installing MySQL 414
Operating Your LAMP Server 414
Editing Your Apache Confi guration Files 415
Adding a Virtual Host to Apache 417
User Content and the userdir Setting 418
Installing a Web Application: Coppermine Photo Gallery 419
Troubleshooting 422
Confi guration Errors 422
Access Forbidden and Server Internal Errors 424
Trang 22Securing Your Web Traffi c with SSL/TLS 425Generating Your Keys 427Confi guring Apache to Support SSL/TLS 428Summary 429
Chapter 14: Running a Mail Server 431
Internet E-Mail’s Inner Workings 431About the System and the Software Used 433Preparing Your System 433Confi guring DNS for Direct Delivery 434Confi guring for Retrieval from a Mail Host 435Installing and Confi guring the Mail Server Software 435Installing Exim and Courier 435Installing ClamAV and SpamAssassin 438Testing and Troubleshooting 440Checking Logs 440Common Errors (and How to Fix Them) 441Confi guring Mail Clients 444Confi guring Fetchmail 444Confi guring Web-Based Mail 445Securing Communications with SSL/TLS 445Summary 446
Chapter 15: Running a Print Server 447
Common UNIX Printing Service .448Setting Up Printers 449Using Web-Based CUPS Administration 449Using the Printer Confi guration Window 452Working with CUPS Printing 459Confi guring the CUPS Server (cupsd.conf) 460Starting the CUPS Server 461Confi guring CUPS Printer Options Manually 462Using Printing Commands 463Printing with lpr 463Listing Printer Status with lpc 464Removing Print Jobs with lprm 464Confi guring Print Servers 465Confi guring a Shared CUPS Printer 465Confi guring a Shared Samba Printer 467Summary 468
Chapter 16: Running a File Server 469
Setting Up an NFS File Server 470Getting NFS 472Sharing NFS File Systems 472Using NFS File Systems 477
Trang 23Setting Up a Samba File Server 484Getting and Installing Samba 485Confi guring Samba with SWAT 486Working with Samba Files and Commands 495Using Samba Shared Directories 498Troubleshooting Your Samba Server 499Summary 501
Part V: Choosing and Installing Different Linux Distributions 503
Chapter 17: Running Ubuntu Linux 505
Overview of Ubuntu 506Ubuntu Releases 506Ubuntu Installer 507Ubuntu as a Desktop 508Ubuntu as a Server 508Ubuntu Spin-Offs 510Challenges Facing Ubuntu 510Installing Ubuntu 512Starting with Ubuntu 516Trying Out the Desktop 517Adding More Software 518Getting More Information about Ubuntu 521Summary 521
Chapter 18: Running Fedora and Red Hat Enterprise Linux 523
Digging into Features 525Red Hat Installer (Anaconda) 525Custom Spins, Install Sets, and Live CDs 526RPM Package Management 526Latest Desktop Technology 527System Confi guration Tools 528Going Forward with Fedora 529Growing Community Support for Fedora 530Joining Fedora Special Interest Groups 530Forums and Mailing Lists 531Fedora Comes of Age 531Installing Fedora 533Choosing Computer Hardware 533Choosing an Installation Method 534Choosing to Install or Upgrade 535Beginning the Installation 537Running the Fedora Firstboot 545Adding Cool Stuff to Your Fedora Desktop 545Summary 546
Trang 24Chapter 19: Running Debian GNU/Linux 547
Inside Debian GNU/Linux 548Debian Packages 548Debian Package Management Tools 549Debian Releases 551Getting Help with Debian 551Installing Debian GNU/Linux 552Hardware Requirements and Installation Planning 552Running the Installer 553Managing Your Debian System 557Confi guring Network Connections 558Package Management Using APT 561Package Management Using dpkg 564Installing Package Sets (Tasks) with tasksel 567Alternatives, Diversions, and Stat Overrides 567Managing Package Confi guration with debconf 569Summary 569
Chapter 20: Running SUSE and openSUSE Linux 571
Understanding SUSE Linux Enterprise and openSUSE 572What’s in SUSE Distributions 573Installation and Confi guration with YaST 574RPM Package Management 576Automated Software Updates 577Managing Software with zypper 578Getting Support for SUSE Linux Enterprise and openSUSE 578Installing openSUSE 579Before You Begin 579Starting Installation 580Starting with openSUSE 584Summary 584
Chapter 21: Running KNOPPIX 585
KNOPPIX Features 586Understanding KNOPPIX 586Looking Inside KNOPPIX 586What’s Cool About KNOPPIX 588Examining Challenges with KNOPPIX 589Seeing Where KNOPPIX Comes From 590Exploring Uses for KNOPPIX 591Starting KNOPPIX 592Getting a Computer 592Booting KNOPPIX 593Correcting Boot Problems 593
Trang 25Using KNOPPIX 598Getting on the Network 599Installing Software in KNOPPIX 600Saving Files in KNOPPIX 601Keeping Your KNOPPIX Confi guration 603Restarting KNOPPIX 604Summary 605
Chapter 22: Running Yellow Dog Linux 607
Understanding Yellow Dog Linux 608Going Forward with Yellow Dog 609Digging into Yellow Dog 610Installing Yellow Dog Linux 611Hardware Support 612Installing Yellow Dog Linux on a PowerStation 613Updating Yellow Dog Linux 614Running Mac Applications with Mac-on-Linux 616Support Options 616Summary 617
Chapter 23: Running Gentoo Linux 619
Understanding Gentoo 619Gentoo’s Open Source Spirit 620The Gentoo Community 621Building, Tuning, and Tweaking Linux 621Where Gentoo Is Used 622What’s in Gentoo 623Managing Software with Portage 624Finding Software Packages 624New Gentoo Features .625Installing Gentoo 626Getting Gentoo 626Starting Gentoo Installation from a Live CD 627Starting Gentoo Installation from a Minimal CD 629Getting Software with emerge 638Summary 639
Chapter 24: Running Slackware Linux 641
Getting into Slackware 641Characterizing the Slackware Community 643The Slackware Creator 643Slackware Users 645Slackware Internet Sites 645Challenges of Using Slackware 646Using Slackware as a Development Platform 646
Trang 26Installing Slackware 647Getting Slackware 647New Features in Slackware 12.1 648Hardware Requirements 648Starting Installation 649Starting with Slackware 653Summary 655
Chapter 25: Running Freespire and Xandros 657
Understanding Freespire 658Freespire’s Roots in Linspire 658Installing Software with Click-N-Run 660Freespire Support .661Installing Freespire .661Hardware Requirements 661Trying Out Freespire 662Starting a Freespire Install 662Summary 666
Chapter 26: Running Mandriva 667
Mandriva Features 667Exploring Mandriva 669Mandriva Installer (DrakX) 670RPM Package Management with RPMDrake 671Mandriva Linux Control Center 672The Mandriva Community 673RPM Repository on Mandriva Club 674Mandriva Forums 674Installing Mandriva Limited Edition 674The Right Hardware for Mandriva 675Installing Mandriva with the DrakX Installer 676Summary 679
Chapter 27: Running a Linux Firewall/Router 681
Understanding Firewalls 682Protecting Desktops with Firewalls 683Starting Your Firewall in Fedora 683Confi guring a Firewall in Mandriva 685Using Firewalls with iptables 686Starting with iptables 687Using iptables to Do SNAT or IP Masquerading 692Adding Modules with iptables 693Using iptables as a Transparent Proxy 693Using iptables for Port Forwarding 694Making a Coyote Linux Bootable Floppy Firewall 695Creating a Coyote Linux Firewall 695
Trang 27Running the Coyote Linux Floppy Firewall 702Managing the Coyote Linux Floppy Firewall 703Using Other Firewall Distributions 704Summary 706
Chapter 28: Running Bootable Linux Distributions 707
Overview of Bootable Linux Distributions 708Trying a Bootable Linux 709Showcasing Linux from a live CD 710Security and Rescue Bootables 711Demonstration Bootables 716Multimedia Bootables 716Tiny Desktops 719Special-Purpose Bootables 722Customizing a Bootable Linux 723Building a Live CD with Fedora 725Summary 726
Part VI: Programming in Linux 727
Chapter 29: Programming Environments and Interfaces 729
Understanding Programming Environments 729Using Linux Programming Environments 730The Linux Development Environment 731Graphical Programming Environments 739The Command-Line Programming Environment 744Linux Programming Interfaces 745Creating Command-Line Interfaces 746Creating Graphical Interfaces 752Application Programming Interfaces 753Summary 758
Chapter 30: Programming Tools and Utilities 759
The Well-Stocked Toolkit 759Using the GCC Compiler 760Compiling Multiple Source Code Files 762GCC Command-Line Options 764Automating Builds with make 766Library Utilities 768The nm Command 770The ar Command 771The ldd Command 771The ldconfi g Command 772Environment Variables and Confi guration Files 772
Trang 28Source Code Control 773Source Code Control Using RCS 773Source Code Control with CVS 777Debugging with GNU Debugger 780Starting GDB 781Inspecting Code in the Debugger 784Examining Data 785Setting Breakpoints 786Working with Source Code 788Summary 788
Appendix A: Media 789 Appendix B: Linux History and Background 799
Index 819
Trang 29of us who have been bitten by the Linux bug, you won’t ever look back
Linux Bible 2009 Edition is here to open your eyes to what Linux is, where it came from, and
where it’s going But, most of all, the book is here to hand you Linux and help you get started
Because Linux is the operating system of free speech and free choice, Linux Bible gives you
choices in selecting the Linux that is right for you
On the DVD and CD that come with this book are 18 different Linux distributions that you are free to install, try out, and keep You learn how those distributions are alike or different, and the book leads you through the basics of installing and setting up your Linux system as a:
Desktop computer user
■ — You have a full range of office, music, gaming, graphics, and other applications to use
Linux system administrator
■ — Learn how to install software, use shell commands, configure system services, and secure your computers and networks
Linux server administrator
■ — Using some of the world’s best server software, you can set up your computer to be a Web server, file server, mail server, or print server
Software developer
■ — You can draw on thousands of open source programming tools
to develop your own software applications
The Linux systems you have in your hand don’t contain trialware or otherwise hobbled software
On the contrary, they feature software created by world-class development projects, the same teams that build the software that powers many professional businesses, schools, home desktops, and Internet service providers In other words, this is truly first-rate software from develop-ers who have made a commitment to producing software that can be used in the ways that you choose to use it
Most of the Linux distributions offered on the DVD and CD that come with this book are live CDs that let you try a Linux distribution without installing Almost all of those live CDs include features that let you install the contents of those live CDs to your hard disk For example, you can try out Fedora, Gentoo, Ubuntu, and Mandriva as live CDs, and then install those distributions permanently to your hard drive from icons on the desktops of those live CDs
Unlike some other books on Linux, this book doesn’t tie you to one Linux distribution The book teaches you the essentials of Linux graphical desktop interfaces, shell commands, and basic
Trang 30available today Then descriptions of the major software projects in most Linux distributions (KDE and GNOME desktops, Apache Web servers, Samba file and printer sharing, and so on) guide you in setting up and using those features, regardless of which Linux you choose.
Understanding the Linux Mystique
This book is designed to spark your imagination about what is possible with Linux, and then give you the software and instructions to jump right into Linux From there, the approach is to help you learn by using it
In the first two chapters, you’ll learn a lot of exciting ways Linux is being used today and see who many of the major players are in the free and open source software (FOSS) world You will see how people are adapting Linux to run on handhelds, mini laptops, 32- and 64-bit PCs, Macs, main-frames, and super computers Linux is truly everywhere!
However, if you are concerned that somehow “free” software is too good to be true, skip ahead for the moment to the brief history of Linux in Appendix B, which guides you through the strange and circuitous path of open source software development that led to the Linux phenomenon
If you are intrigued by what you learn, Chapter 2 tells you how you can become part of the open source and free software communities, whose stars are known by a single name (such as Linus) or a few initials (such as rms) You’ll find a staggering number of open source projects, forums, and mail-ing lists that are thriving today (and always looking for more people to get involved)
How This Book Is Organized
Learn the basics of what goes into Linux and you will be able to use all sorts of devices and ers in the future The book is organized in a way that enables you to start off at the very beginning with Linux, but still grow to the point where you can get going with some powerful server and pro-gramming features, if you care to
comput-Part I includes two short chapters designed to open your eyes to what you can do with Linux, and
then get your hands on it quickly Those two chapters describe:
How others use Linux, how to transition to Linux from Windows, and how to start with
■
Linux using the CD and DVD inside this book (Chapter 1)
What you can do, what you can make, and what you can become with Linux (Chapter 2)
Trang 31Desktop publishing and Web publishing using word processing, layout, drawing, and
In Part III, you learn how to administer Linux systems, including:
Installing Linux systems (Chapter 8)
Linux creates powerful servers, and in Part IV you learn to:
Set up a Web server using Apache, MySQL, and PHP in Linux (Chapter 13)
If you don’t have Linux installed yet, this book helps you understand the different Linux distributions,
and then install the systems you want from the DVD and CD included with this book Part V
(Chap-ters 17 through 28) describes each of those distributions and how to run them live or install them
If you are coming to Linux for its programming environment, Part VI provides chapters that
What You Will Get from This Book
By the time you finish this book, you’ll have a good basic understanding of many of the major tures in Linux and how you can use them If you decide then that you want to go a bit deeper into
fea-any Red Hat-sponsored distribution, Fedora 9 and Enterprise Linux Bible (Wiley, 2008) is a good
next step, with content that includes how to set up many different types of Linux servers You can find similar books for other distributions
Trang 32If you are more technically oriented, Linux Troubleshooting Bible (Wiley, 2004) can be a good way
to learn more advanced skills for securing and troubleshooting Linux systems Or a Linux Toolbox
book for Fedora, Ubuntu, BSD, or SUSE (Wiley, 2007 and 2008) can provide you with over 1000 Linux commands to help you become a Linux power user
If you are looking for some fun, try out some projects with an old PC and free software from Linux
Toys II (Wiley, 2005).
Conventions Used in This Book
Throughout the book, special typography indicates code and commands Commands and code are shown in a monospaced font:
This is how code looks.
In the event that an example includes both input and output, the monospaced font is still used, but input is presented in bold type to distinguish the two Here’s an example:
Name (home:jake): jake
Password: ******
As for styles in the text:
We highlight new terms and important words with italics when we introduce them
The following items are used to call your attention to points that are particularly important
A Note box provides extra information to which you need to pay special attention.
A Tip box shows a special way of performing a particular task.
A Caution box alerts you to take special care when executing a procedure, or damage to your computer hardware or software could result.
A Cross-Reference box refers you to further information on a subject that you can fi nd outside the current chapter.
A Coming from Windows box provides tips to help you transfer your knowledge of Windows systems to the Linux world.
The On the CD and On the DVD icons point out features related to the media that accompany the book
Trang 33IN THIS PART
Chapter 1 Starting with Linux Chapter 2 Linux Projects, Activities, and Careers
Getting off the Ground with Linux
Trang 35In only a few years, Linux has advanced from being considered a
specialty operating system into the mainstream Precompiled and
configured Linux systems can be installed with no technical
exper-tise Versions of Linux run on all kinds of devices, from PCs to handhelds
(see www.linuxdevices.com) to game consoles (such as PlayStation 3)
to supercomputers In short, Linux has become a system that can be run
almost anywhere by almost anyone
On both desktop and server computers Linux has become a formidable
operating system across a variety of business applications Today, large
enterprises can deploy thousands of systems using Linux distributions from
companies such as Red Hat, Inc and Novell, Inc Small businesses can put
together the mixture of office and Internet services they need to keep their
costs down
The free and open source software (FOSS) development model that espoused
sharing, freedom, and openness is now on a trajectory to surpass the quality
of other operating systems outside of the traditional Linux servers and
tech-nical workstations What were once weak components of Linux, such as
easy-to-use desktops and personal productivity applications, have improved at a
rapid pace In areas of security, usability, connectivity, and network services,
Linux has continued to improve and outshine the competition
Computer industry heavy-hitters such as Microsoft and Oracle have taken
notice of Linux Microsoft has struck agreements with Linux companies
including Novell and Xandros to form partnerships that primarily protect
those companies against threatened Microsoft lawsuits Oracle began
pro-ducing its own Linux system called Unbreakable Linux, to try to stem the
flow of customers to Red Hat Enterprise Linux
IN THIS CHAPTER
Getting started with Linux Understanding Linux Linux features and advantages
Trang 36What does this all add up to? A growing swirl of excitement around the operating system that the big guys can’t seem to get rid of For people like you, who want the freedom to use your computer software as you like, it means great prospects for the future.
Let this book help you grab your first look at the distributions, applications, services, and nity that make up the phenomenon that has become Linux
commu-Taking Your First Step
In your hands, you have 18 different Linux distributions (on CD and DVD), thousands of tions, and descriptions for getting it all running on your own computer For you right now, the worldwide Linux phenomenon is just a reboot away
applica-Linux Bible 2009 Edition brings you into the world of free and open source software that, through
some strange twists and turns, has fallen most publicly under the “Linux” banner Through tions and procedures, this book helps you:
descrip-Understand what people do with Linux and how you can use Linux for all your
high-quality software projects that are included with Linux
What Comes in Linux Systems?
Whether you are using Linux for the first time or just want to try out a new Linux distribution,
Linux Bible 2009 Edition is your guide to using Linux and the latest open source technology While
different Linux distributions vary in the exact software they include, this book describes the most popular software available for Linux to:
Manage your desktop (menus, icons, windows, and so on)
Trang 37Because most Linux distributions also include features that let them act as servers (in fact, that’s one
of the things Linux has always been best at), you’ll also learn about software available for Linux that lets you do the following:
Connect to the Internet or other network
Google and Amazon.com), universities, and businesses of all sizes
This book guides you through the basics of getting started with these Linux features, plus many more Once you’ve been through the book, you should be proficient enough in the basics to track down answers to your more advanced questions through the volumes of man pages, FAQs, HOW-TOs, and forums that cover different aspects of the Linux operating system
To get started with Linux right now, all you need is a standard PC with a bootable CD or DVD drive
What Do You Need to Get Started?
Although Linux will run great on many low-end computers (even some old 486s and early tiums), if you are completely new to Linux, I recommend that you start with a PC that has a little more muscle Here’s why:
Pen-Full-blown Linux operating systems with complete GNOME or KDE desktop environments
■
(see Chapter 3) perform poorly on slow CPUs and less than the recommended amount of RAM The bells and whistles come at the price of processing power Lighter-weight options
do exist if you have limited resources
You can use streamlined graphical Linux installations that will fit on small hard disks (as
■
small as 100MB) and run fairly well on slow processors Also, there are small live CD Linux distributions, such as Damn Small Linux (DSL), that can be copied to hard disk and run from there (read about some of these small “bootables” in Chapter 28) The 50MB DSL desktop system will run fine on old Pentium machines with little RAM But if you want to add some of the more demanding applications to these small systems, such as OpenOffice.org office applications, you will find you need more than minimal computer hardware
If you are starting with a 400 MHz Pentium II, your desktop will run slowly in default KDE or GNOME configurations with less than 128MB of RAM A simpler desktop system, with just X and a window manager, will work, but won’t give you the full flavor of a Linux desktop (See Chapter 3 for information about different desktop choices and features.)
Trang 38The good news is that cheap computers that you can buy from Wal-Mart or other retailers start at less than $300 Those systems will perform better than most PCs you have laying around that are more than a few years old, and some even come with Linux pre-installed The bottom line is that the less you know about Linux, the more you should try to have computer hardware that is up to spec in order to have a pleasant experience.
Starting Right Now
If you are anxious to get started, insert either the DVD or CD accompanying this book into the appropriate drive on your PC and reboot When you see the boot screen, press Enter When the DVD or CD boots, the following happens, respectively:
KNOPPIX starts up.
■ A fully functional KNOPPIX desktop Linux system will boot directly from the DVD From that Linux system, you can do everything you’d expect to do from a modern desktop computing system: write documents, play music, communicate over the Internet, work with images, and so on If you have a wired Ethernet connection that con-nects to the Internet when you start up Windows, most likely it will also connect automati-cally when KNOPPIX starts
Damn Small Linux (DSL) starts up.
starts up directly from the CD that comes with this book Besides being expandable and adaptable, DSL runs on everything from low-end PCs to powerful workstation hardware while being small enough to fit on a mini CD (only about 50MB in size)
What you have in front of you is a functioning desktop system that can be installed to your hard disk to use permanently, if you like Thousands of software packages available for Linux can be added Depending on your Linux system, installing extra software might just take a few clicks
The next sections step you through a few things you can do with KNOPPIX and DSL
Trying KNOPPIX
When KNOPPIX starts up, you bypass a login screen and go directly to a K Desktop Environment (KDE) that is loaded with free software for you to try Figure 1-1 shows an example of the KNOPPIX KDE desktop with several applications running
If you have any trouble starting KNOPPIX, refer to Chapter 21 for descriptions of boot options to help you overcome certain problems (such as a garbled screen or hanging when certain hardware is encountered) That chapter also describes other KNOPPIX features.
Here is a quick tour of the KNOPPIX desktop:
Browsing
■ — Select the Konqueror icon from the bottom panel to open the Konqueror Web browser/file manager The Konqueror window shown in Figure 1-1 displays the English version of the KNOPPIX Web site (http://knopper.net)
NOTE
Trang 39Accessing disks
■ — A live CD, such as KNOPPIX, is designed to run without touching the contents of your hard disk However, if you have something on your hard disk you want to use with KNOPPIX (such as a music file or document), KNOPPIX makes it easy to do that
Icons on the left side of the desktop appear, representing every partition on your hard disk,
as well as detected removable media (such as a USB flash drive) In Figure 1-1, Hard Disk icons hda1, hda2, and hda5 represent several partitions on your hard disk Select an icon to display the contents of the partition in a file manager window To be able to add content to that disk partition, right-click the partition and select Change Read/Write Mode
Trang 40Special Knoppix features
■ — Because of the temporary nature of a live CD, settings have
to be configured each time you boot, unless you take steps to save those settings From the small penguin icon on the left side of the bottom panel, you can see a menu of selections
to do special things to make the live CD work better Select Configure ➪ Save KNOPPIX Configuration to save your settings to your hard disk or a USB drive so you can use those settings later
Other KNOPPIX features are also available from that menu You can configure a persistent disk image, make a swap file, or configure printers, TV cards, or sound cards You can also configure different services Many of these features are described in Chapter 21
When you are done trying KNOPPIX, select Log Out from the K menu and choose Turn Off puter After KNOPPIX shuts down, it will eject the disc After you remove the disc, you can use your computer again with whatever operating system you have installed there
Com-Trying Damn Small Linux
Because Damn Small Linux (DSL) is based on KNOPPIX, you may notice some similarities DSL is smaller and faster, however, so you should get to the DSL desktop screen quicker Instead of KDE, the DSL desktop features a lightweight window manager Figure 1-2 shows an example of a DSL desktop with several applications open
Many of the same boot options that come with KNOPPIX will work with DSL, so check Chapter 21 if you have trouble booting DSL For other descriptions of DSL, see Chapter 28.
Here are some things to try on your DSL desktop:
Web browsing
■ — With an active wired Internet connection, you should be able to connect
to the Internet automatically when DSL boots up The Dillo Web browser opens to a page
of basic DSL information Continue to browse the Web from Dillo, or open the Firefox icon from the desktop to browse with Firefox instead
Install applications
■ — Open the MyDSL icon from the desktop and then, when prompted, download the applications database After that, select categories from the left column to look through listings of hundreds of applications you can add to DSL When you find one you like, choose Install Selected to download and install it
Check out the desktop
■ — On the desktop itself, view information about your computer (CPU Usage, RAM Usage, Swap Used, File systems, and so on) in the upper-right corner
Select DSL in the lower-left corner of the bottom panel to see a menu of available tions Then try a few applications You can view the same menu by right-clicking on the desktop
applica-NOTE