Register your product to gain access to bonus material or receive a coupon.
Ubuntu Unleashed 2010 Edition presents comprehensive coverage of the
popular Ubuntu Linux distribution. Windows users, Mac users, and Linux enthusiasts have been increasingly turning to Ubuntu for a user-friendly, easy-to-use Linux distribution.
This book provides detailed information on installing, using, and administering Ubuntu. You will learn how to set up a workstation or a server, and you will find complete details on Ubuntu’s easy-to-use desktop and productivity software.
Ubuntu Unleashed 2010 Edition includes a range of coverage: From the software you need in your everyday work, such as the OpenOffice.org productivity suite, to how to configure your Linux desktop to run smoothly using multiple printers, shell scripts, and more.
For the hardcore Linux enthusiast, there is complete coverage of the
X Window system, Linux programming, web server administration, and network administration.
Ubuntu 9.10 on DVD
DVD includes the full Ubuntu 9.10 distribution for Intel x86 computers as well as the complete OpenOffice.org office suite and hundreds of additional programs and utilities.
Free Upgrade!
Purchase this book anytime in 2010 and receive a free Ubuntu 10.04 Upgrade Kit by mail (U.S. or Canada only) after Ubuntu 10.04 is released.
See inside back cover for details.
à Install and configure Ubuntu
à Get all your system’s devices and peripherals up and running
à Configure and use the X Window System
à Manage Linux services and users
à Run a printer server
à Connect to a local network and the Internet
à Set up and administer a web server with Apache
à Secure your machine and your network from intruders
à Learn shell scripting
à Share files with Windows users using Samba
à Get productive with OpenOffice.org
à Play games on Linux
à Use Linux multimedia programs
à Create and maintain a MySQL database
à Configure a firewall
à Set up an FTP server
à Use Ubuntu’s development and programming tools
à Tune your Ubuntu system for maximum performance
à Learn to manage and compile the kernel and modules
Setting Up Hibernation on Linux SSD Netbooks Without Swap, Part 1
Setting Up Hibernation on Linux SSD Netbooks Without Swap, Part 2
Ubuntu Command Line Quickstart
Download the sample pages (includes Chapter 4 and Index)
Introduction 1
Part I Installation and Configuration
1 Installing Ubuntu 11
Before You Begin the Installation.................................................................11
Researching Your Hardware Specifications .........................................12
Installation Options.............................................................................12
Planning Partition Strategies ...............................................................12
The Boot Loader ..................................................................................13
Installing from CD or DVD .................................................................13
Step-by-Step Installation...............................................................................13
Starting the Install ...............................................................................14
First Update..........................................................................................20
Wubi–The Easy Installer for Windows ..............................................22
Shutting Down ....................................................................................24
Reference .......................................................................................................24
2 Post-Installation Configuration 25
Troubleshooting Post-Installation Configuration Problems ........................26
The sudo command ......................................................................................27
First Update...................................................................................................28
Configuring Software Repositories ...............................................................30
Installing Graphics Drivers ...........................................................................33
Changing Ubuntu’s Look and Feel...............................................................34
Changing the Desktop Background ....................................................34
Changing Colors..................................................................................35
Modifying System Fonts......................................................................36
Changing How Menus Look ...............................................................36
Visual Effects........................................................................................37
Preferred Behaviors .......................................................................................37
Preferred Applications .........................................................................37
Removable Drives and Media..............................................................39
Input Devices ................................................................................................39
Keyboard Shortcuts..............................................................................40
Keyboard Layout..................................................................................40
Mouse...................................................................................................41
Detecting and Configuring a Modem ..........................................................42
Configuring a Serial-Port Modem .......................................................42
Configuring WinModems for Laptops................................................42
Configuring Power Management in Ubuntu ...............................................43
Setting the Date and Time............................................................................44
Using the date Command ...................................................................45
Using the hwclock Command ............................................................45
Changing the Time and Date..............................................................46
Configuring and Using CD, DVD, and CD-RW Drives................................46
Checking Drive Assignment................................................................47
Configuring Wireless Networks ....................................................................48
Reference .......................................................................................................49
3 Working with Gnome 51
The Gnome Desktop Environment ..............................................................52
Gnome: The GNU Network Object Model Environment...................52
Eye Candy for the Masses.............................................................................54
Basic X Concepts...........................................................................................55
Using X..........................................................................................................56
Elements of the xorg.conf File ............................................................57
Configuring X......................................................................................62
Starting X ......................................................................................................64
Using a Display Manager.....................................................................65
Changing Window Managers..............................................................73
KDE–The Other Environment.....................................................................77
XFce...............................................................................................................78
Reference .......................................................................................................78
4 Command Line Quickstart 79
What Is the Command Line? .......................................................................79
Navigating Through the File System...................................................83
Managing Files with the Shell.............................................................85
Working with Compressed Files..........................................................86
Use Essential Commands from the /bin and /sbin Directories ..........87
Use and Edit Files in the /etc Directory ..............................................87
Protect the Contents of User Directories–/home ..............................87
Use the Contents of the /proc Directory to Interact
with the Kernel..................................................................................87
Work with Shared Data in the /usr Directory.....................................89
Temporary File Storage in the /tmp Directory....................................89
Access Variable Data Files in the /var Directory .................................89
Logging In to and Working with Linux .......................................................90
Text-based Console Login....................................................................90
Logging Out.........................................................................................90
Logging In and Out from a Remote Computer ..................................91
Using Environment Variables..............................................................92
Using the Text Editors ..................................................................................95
Working with vi...................................................................................96
Working with emacs............................................................................97
Working with Permissions............................................................................99
Assigning Permissions .......................................................................100
Directory Permissions........................................................................101
Understanding Set User ID and Set Group ID Permissions..............103
Working as Root..........................................................................................104
Creating Users....................................................................................105
Deleting Users....................................................................................106
Shutting Down the System ...............................................................106
Rebooting the System........................................................................107
Reading Documentation.............................................................................108
Using Man Pages................................................................................108
Reference .....................................................................................................110
Part II Desktop Ubuntu
5 On the Internet 113
Getting Started with Firefox .......................................................................114
Choosing an Email Client ..........................................................................115
Evolution ...........................................................................................116
Mozilla Thunderbird..........................................................................118
KMail..................................................................................................120
Other Mail Clients.............................................................................120
RSS Readers..................................................................................................120
Firefox ................................................................................................122
Liferea.................................................................................................122
Instant Messaging with Pidgin ...................................................................123
Internet Relay Chat.....................................................................................124
Usenet Network Newsgroups......................................................................127
The Pan News Client Newsreader...............................................................128
Videoconferencing with Ekiga....................................................................130
Reference .....................................................................................................132
6 Productivity Applications 133
Introducing OpenOffice.org .......................................................................134
Configuring OpenOffice.org .............................................................136
Working with OpenOffice.org Writer ...............................................137
Working with OpenOffice.org Calc...................................................140
Office Suites for Ubuntu .............................................................................144
Working with Gnome Office.............................................................146
Working with KOffice........................................................................149
Productivity Applications Written for Microsoft Windows.......................150
Reference .....................................................................................................152
7 Multimedia Applications 153
Sound and Music ........................................................................................153
Sound Cards.......................................................................................154
Adjusting Volume..............................................................................155
Sound Formats...................................................................................156
Listening to Music .............................................................................157
Graphics Manipulation...............................................................................163
The GNU Image Manipulation Program...........................................163
Using Scanners in Ubuntu ................................................................164
Working with Graphics Formats .......................................................166
Capturing Screen Images...................................................................168
Using Digital Cameras with Ubuntu ..........................................................168
Handheld Digital Cameras ................................................................168
Using F-Spot.......................................................................................169
Burning CDs and DVDs in Ubuntu............................................................170
Creating CDs and DVDs with Ubuntu’s Graphical Clients..............172
Creating CDs from the Command Line ...........................................174
Creating DVDs from the Command Line.........................................176
Viewing Video.............................................................................................178
TV and Video Hardware ....................................................................178
Video Formats....................................................................................180
Viewing Video in Linux.....................................................................181
Personal Video Recorders ..................................................................181
DVD and Video Players .....................................................................182
Reference .....................................................................................................182
8 Printing with Ubuntu 185
Overview of Ubuntu Printing.....................................................................185
Configuring and Managing Print Services .................................................187
GUI-Based Printer Configuration Quickstart ....................................187
Managing Printing Services ...............................................................188
Creating and Configuring Local Printers ...................................................189
Creating the Print Queue ..................................................................190
Editing Printer Settings......................................................................192
Reference .....................................................................................................195
9 Games 197
Linux Gaming.............................................................................................197
Installing Proprietary Video Drivers..................................................198
Installing Games in Ubuntu .......................................................................199
DOOM 3 ............................................................................................200
Unreal Tournament 2004 ..................................................................201
Quake 4..............................................................................................202
Wolfenstein: Enemy Territory ...........................................................203
Battle for Wesnoth.............................................................................204
Playing Windows Games with Cedega.......................................................204
Reference .....................................................................................................205
Part III System Administration
10 Managing Users 209
User Accounts .............................................................................................209
The Super User/Root User .................................................................210
User IDs and Group IDs ....................................................................212
File Permissions .................................................................................212
Managing Groups .......................................................................................213
Group Management Tools.................................................................214
Managing Users...........................................................................................216
User Management Tools ....................................................................216
Adding New Users .............................................................................218
Monitoring User Activity on the System ..........................................219
Managing Passwords...................................................................................220
System Password Policy .....................................................................220
The Password File ..............................................................................220
Shadow Passwords .............................................................................221
Managing Password Security for Users..............................................223
Changing Passwords in a Batch ........................................................224
Granting System Administrator Privileges to Regular Users......................224
Temporarily Changing User Identity with the su Command ..........225
Granting Root Privileges on Occasion–The sudo Command .........227
Disk Quotas.................................................................................................229
Implementing Quotas .......................................................................230
Manually Configuring Quotas ..........................................................230
Reference .....................................................................................................232
11 Automating Tasks 233
Running Services at Bootup........................................................................234
Beginning the Boot Loading Process..........................................................234
Loading the Linux Kernel..................................................................235
System Services and Runlevels ..........................................................236
Runlevel Definitions..........................................................................236
Booting into the Default Runlevel ....................................................237
Booting to a Non-Default Runlevel with GRUB ...............................237
Understanding init Scripts and the Final Stage of Initialization......238
Controlling Services at Boot with Administrative Tools ..................239
Changing Runlevels...........................................................................240
Troubleshooting Runlevel Problems .................................................240
Starting and Stopping Services Manually...................................................241
Scheduling Tasks .........................................................................................242
Using at and batch to Schedule Tasks for Later................................242
Using cron to Run Jobs Repeatedly...................................................245
Basic Shell Control......................................................................................248
The Shell Command Line .................................................................248
Shell Pattern-Matching Support........................................................250
Redirecting Input and Output...........................................................251
Piping Data ........................................................................................252
Background Processing ......................................................................252
Writing and Executing a Shell Script..........................................................253
Running the New Shell Program.......................................................254
Storing Shell Scripts for Systemwide Access......................................255
Interpreting Shell Scripts Through Specific Shells............................256
Using Variables in Shell Scripts .........................................................258
Assigning a Value to a Variable .........................................................258
Accessing Variable Values ..................................................................259
Positional Parameters ........................................................................259
A Simple Example of a Positional Parameter....................................259
Using Positional Parameters to Access and Retrieve
Variables from the Command Line ................................................260
Using a Simple Script to Automate Tasks..........................................261
Built-In Variables ...............................................................................263
Special Characters..............................................................................263
Use Double Quotes to Resolve Variables in Strings with
Embedded Spaces ............................................................................264
Using Single Quotes to Maintain Unexpanded Variables ................265
Using the Backslash as an Escape Character.....................................266
Using the Backtick to Replace a String with Output ........................266
Comparison of Expressions in pdksh and bash................................267
00_1091_fm.xml.qxp 11/16/09 6:16 PM Page x
Comparing Expressions with tcsh.....................................................272
The for Statement ..............................................................................276
The while Statement..........................................................................277
The until Statement...........................................................................279
The repeat Statement (tcsh) ..............................................................280
The select Statement (pdksh) ............................................................280
The shift Statement ...........................................................................281
The if Statement ................................................................................281
The case Statement ............................................................................283
The break and exit Statements..........................................................285
Using Functions in Shell Scripts........................................................285
Reference .....................................................................................................287
12 System-Monitoring Tools 289
Console-Based Monitoring .........................................................................289
Using the kill Command to Control Processes.................................291
Using Priority Scheduling and Control.............................................292
Displaying Free and Used Memory with free ...................................294
Disk Space ..........................................................................................295
Disk Quotas........................................................................................296
Graphical Process and System Management Tools ....................................296
KDE Process- and System-Monitoring Tools ..............................................298
Reference .....................................................................................................299
13 Backing Up 301
Choosing a Backup Strategy .......................................................................301
Why Data Loss Occurs.......................................................................302
Assessing Your Backup Needs and Resources ....................................303
Evaluating Backup Strategies.............................................................304
Making the Choice ............................................................................307
Choosing Backup Hardware and Media .....................................................307
Removable Storage Media .................................................................308
Network Storage.................................................................................309
Tape Drive Backup .............................................................................309
Using Backup Software ...............................................................................310
tar: The Most Basic Backup Tool .......................................................310
The GNOME File Roller .....................................................................312
Using the Amanda Backup Application............................................315
Alternative Backup Software..............................................................316
Copying Files...............................................................................................316
Copying Files Using tar .....................................................................317
Compressing, Encrypting, and Sending tar Streams ........................317
Copying Files Using cp......................................................................318
Copying Files Using mc.....................................................................318
System Rescue .............................................................................................319
The Ubuntu Rescue Disc....................................................................320
Backing Up and Restoring the Master Boot Record..........................320
Booting the System from a Generic Boot Floppy .............................320
Using a GRUB Boot Floppy ...............................................................321
Using the Recovery Facility ...............................................................322
Reference .....................................................................................................322
14 Networking 325
Laying the Foundation: The localhost Interface........................................326
Checking for the Availability of the Loopback Interface .................326
Configuring the Loopback Interface Manually ................................326
Networking with TCP/IP.............................................................................328
TCP/IP Addressing .............................................................................329
Using IP Masquerading in Ubuntu ...................................................331
Ports ...................................................................................................332
Network Organization ................................................................................333
Subnetting..........................................................................................333
Subnet Masks .....................................................................................334
Broadcast, Unicast, and Multicast Addressing ..................................334
Hardware Devices for Networking..............................................................335
Network Interface Cards....................................................................335
Network Cable ...................................................................................337
Hubs and Switches.............................................................................338
Routers and Bridges ...........................................................................339
Initializing New Network Hardware..................................................339
Using Network Configuration Tools...........................................................342
Command-Line Network Interface Configuration ...........................342
Network Configuration Files .............................................................347
Using Graphical Configuration Tools ...............................................349
Dynamic Host Configuration Protocol ......................................................351
How DHCP Works .............................................................................351
Activating DHCP at Installation and Boot Time ..............................352
DHCP Software Installation and Configuration ...............................353
Using DHCP to Configure Network Hosts........................................354
Other Uses for DHCP.........................................................................357
Wireless Networking ...................................................................................357
Support for Wireless Networking in Ubuntu ....................................357
Advantages of Wireless Networking..................................................358
Choosing from Among Available Wireless Protocols .......................359
Beyond the Network and onto the Internet ..............................................360
Common Configuration Information........................................................360
Configuring Digital Subscriber Line Access................................................362
Understanding Point-to-Point Protocol over Ethernet.....................363
Configuring a PPPoE Connection Manually.....................................363
Configuring Dial-Up Internet Access .........................................................365
Configuring a Dial-Up Connection Manually..................................365
Troubleshooting Connection Problems .....................................................368
Reference .....................................................................................................369
15 Remote Access with SSH and Telnet 371
Setting Up a Telnet Server...........................................................................371
Telnet Versus SSH........................................................................................372
Setting Up an SSH Server ............................................................................372
The SSH Tools..............................................................................................373
Using scp to Copy Individual Files Between Machines....................374
Using sftp to Copy Many Files Between Machines ..........................374
Using ssh-keygen to Enable Key-based Logins..................................375
Remote X.....................................................................................................377
XDMCP..............................................................................................377
VNC....................................................................................................378
Reference .....................................................................................................378
Part IV Ubuntu as a Server
16 File and Print 381
Using the Network File System...................................................................382
Installing and Starting or Stopping NFS ...........................................382
NFS Server Configuration..................................................................383
NFS Client Configuration..................................................................384
Putting Samba to Work...............................................................................385
Manually Configuring Samba with /etc/samba/smb.conf................387
Testing Samba with the testparm Command ...................................390
Starting the smbd Daemon ...............................................................390
Mounting Samba Shares....................................................................391
Configuring Samba Using SWAT.......................................................392
Network and Remote Printing with Ubuntu..............................................397
Creating Network Printers ..........................................................................397
Enabling Network Printing on a LAN ...............................................397
Session Message Block Printing.........................................................398
Using the Common UNIX Printing System GUI .......................................399
Creating a CUPS Printer Entry ..........................................................400
Avoiding Printer Support Problems............................................................403
All-in-One (Print/Fax/Scan) Devices .................................................403
Using USB and Legacy Printers .........................................................403
Reference .....................................................................................................405
17 Apache Web Server Management 407
About the Apache Web Server ....................................................................407
Installing the Apache Server.......................................................................409
Installing with APT............................................................................409
Building the Source Yourself .............................................................410
Starting and Stopping Apache ....................................................................413
Starting the Apache Server Manually................................................413
Using /etc/init.d/apache2..................................................................414
Runtime Server Configuration Settings......................................................416
Runtime Configuration Directives ....................................................416
Editing apache2.conf.........................................................................417
Apache Multiprocessing Modules .....................................................419
Using .htaccess Configuration Files ..................................................420
File System Authentication and Access Control ........................................422
Restricting Access with allow and deny............................................422
Authentication...................................................................................423
Final Words on Access Control .........................................................425
Apache Modules..........................................................................................426
mod_access ........................................................................................427
mod_alias ...........................................................................................427
mod_asis ............................................................................................427
mod_auth...........................................................................................428
mod_auth_anon.................................................................................428
mod_auth_dbm .................................................................................428
mod_auth_digest ...............................................................................428
mod_autoindex..................................................................................429
mod_cgi..............................................................................................429
mod_dir and mod_env ......................................................................429
mod_expires.......................................................................................429
mod_headers......................................................................................429
mod_include ......................................................................................429
mod_info and mod_log_config .........................................................430
mod_mime and mod_mime_magic ..................................................430
mod_negotiation ...............................................................................430
mod_proxy.........................................................................................430
mod_rewrite.......................................................................................430
mod_setenvif .....................................................................................430
mod_speling.......................................................................................431
mod_status.........................................................................................431
mod_ssl ..............................................................................................431
mod_unique_id..................................................................................431
mod_userdir .......................................................................................431
mod_usertrack....................................................................................431
mod_vhost_alias ................................................................................431
Virtual Hosting............................................................................................432
Address-Based Virtual Hosts ..............................................................432
Name-Based Virtual Hosts .................................................................432
Logging........................................................................................................434
Other Web Servers for Use with Ubuntu....................................................435
Sun ONE Web Server .........................................................................436
Zope ...................................................................................................436
Zeus Web Server.................................................................................436
Reference .....................................................................................................437
18 Remote File Serving with FTP 439
Choosing an FTP Server..............................................................................439
Choosing an Authenticated or Anonymous Server ..........................440
Ubuntu FTP Server Packages .............................................................440
Other FTP Servers ..............................................................................440
Installing FTP Software ...............................................................................441
The FTP User ...............................................................................................442
inetd Configuration for wu-ftpd ................................................................444
Starting the Very Secure FTP Server (vsftpd) Package.......................445
Configuring the Very Secure FTP Server.....................................................445
Controlling Anonymous Access........................................................445
Other vsftpd Server Configuration Files ...........................................446
Configuring the Server ...............................................................................448
Using Commands in the ftpaccess File to Configure wu-ftpd...................448
Configure Access Control..................................................................449
Configure User Information..............................................................452
Configure System Logging ................................................................456
Configure Permission Control ..........................................................457
Configure Commands Directed Toward the cdpath.........................459
Structure of the shutdown File..........................................................460
Configuring FTP Server File-Conversion Actions.......................................460
Strip Prefix .........................................................................................461
Strip Postfix........................................................................................461
Add-On Prefix ....................................................................................461
Add-On Postfix ..................................................................................461
External Command ...........................................................................461
An Example of Conversions in Action..............................................462
Using the ftphosts File to Allow or Deny FTP Server Connection ............463
Using Commands for Server Administration.............................................464
Display Information About Connected Users...................................464
Count the Number of Connections..................................................465
Use /usr/sbin/ftpshut to Schedule FTP Server Downtime ................466
Use /var/log/xferlog to View a Log of Server Transactions...............467
Reference .....................................................................................................470
19 Handling Electronic Mail 471
How Email Is Sent and Received ................................................................471
The Mail Transport Agent..................................................................472
Choosing an MTA..............................................................................474
The Mail Delivery Agent ...................................................................474
The Mail User Agent..........................................................................475
Basic Postfix Configuration and Operation ...............................................476
Configuring Masquerading ...............................................................477
Using Smart Hosts .............................................................................477
Setting Message Delivery Intervals....................................................477
Mail Relaying .....................................................................................478
Forwarding Email with Aliases ..........................................................478
Using Fetchmail to Retrieve Mail ...............................................................479
Installing Fetchmail...........................................................................479
Configuring Fetchmail ......................................................................480
Choosing a Mail Delivery Agent ................................................................483
Procmail .............................................................................................483
Spamassassin......................................................................................484
Squirrelmail........................................................................................484
Virus Scanners....................................................................................484
Mail Daemons.............................................................................................485
Alternatives to Microsoft Exchange Server.................................................485
Microsoft Exchange Server/Outlook Client ......................................486
CommuniGate Pro.............................................................................486
Oracle Collaboration Suite ................................................................486
Bynari.................................................................................................486
Open-Xchange...................................................................................486
phpgroupware....................................................................................487
PHProjekt ...........................................................................................487
Horde .................................................................................................487
Reference .....................................................................................................488
20 Proxying and Reverse Proxying 489
What Is a Proxy Server? ..............................................................................489
Installing Squid ...........................................................................................490
Configuring Clients ....................................................................................490
Access Control Lists ....................................................................................491
Specifying Client IP Addresses....................................................................495
Example Configurations .............................................................................496
Reference .....................................................................................................498
21 Administering Database Services 499
A Brief Review of Database Basics ..............................................................500
How Relational Databases Work .......................................................501
Understanding SQL Basics.................................................................503
Creating Tables ..................................................................................503
Inserting Data into Tables .................................................................504
Retrieving Data from a Database.......................................................505
Choosing a Database: MySQL Versus PostgreSQL......................................507
Speed..................................................................................................507
Data Locking......................................................................................508
ACID Compliance in Transaction Processing
to Protect Data Integrity .................................................................509
SQL Subqueries ..................................................................................509
Procedural Languages and Triggers ...................................................510
Configuring MySQL....................................................................................510
Setting a Password for the MySQL Root User ...................................511
Creating a Database in MySQL .........................................................511
Granting and Revoking Privileges in MySQL ...................................512
Configuring PostgreSQL .............................................................................513
Initializing the Data Directory in PostgreSQL ..................................514
Creating a Database in PostgreSQL ...................................................515
Creating Database Users in PostgreSQL ............................................516
Deleting Database Users in PostgreSQL ............................................517
Granting and Revoking Privileges in PostgreSQL .............................517
Database Clients..........................................................................................518
SSH Access to a Database...................................................................518
Local GUI Client Access to a Database .............................................520
Web Access to a Database..................................................................520
The MySQL Command-Line Client ..................................................521
The PostgreSQL Command-Line Client............................................523
Graphical Clients...............................................................................523
Reference .....................................................................................................524
22 LDAP 525
Configuring the Server ...............................................................................526
Populating Your Directory.................................................................528
Configuring Clients ....................................................................................530
Evolution ...........................................................................................531
Thunderbird.......................................................................................532
Administration............................................................................................532
Reference .....................................................................................................533
Part V Programming Linux
23 Using Perl 537
Using Perl with Linux.................................................................................537
Perl Versions ......................................................................................538
A Simple Perl Program.......................................................................538
Perl Variables and Data Structures..............................................................540
Perl Variable Types.............................................................................540
Special Variables.................................................................................541
Operators.....................................................................................................542
Comparison Operators ......................................................................542
Compound Operators........................................................................543
Arithmetic Operators.........................................................................544
Other Operators.................................................................................544
Special String Constants ....................................................................545
Conditional Statements: if/else and unless................................................545
if .........................................................................................................546
unless .................................................................................................546
Looping .......................................................................................................547
for.......................................................................................................547
foreach ...............................................................................................547
while ..................................................................................................548
until ...................................................................................................548
last and next ......................................................................................548
do ... while and do ... until ...............................................................549
Regular Expressions.....................................................................................549
Access to the Shell ......................................................................................550
Modules and CPAN.....................................................................................551
Code Examples............................................................................................552
Sending Mail......................................................................................552
Purging Logs ......................................................................................554
Posting to Usenet...............................................................................555
One-Liners .........................................................................................556
Command-Line Processing................................................................556
Reference .....................................................................................................557
24 Working with Python 561
Python on Linux.........................................................................................561
Getting Interactive.............................................................................562
The Basics of Python...................................................................................563
Numbers.............................................................................................563
More on Strings .................................................................................564
Lists ....................................................................................................567
Dictionaries........................................................................................569
Conditionals and Looping ................................................................570
Functions.....................................................................................................572
Object Orientation......................................................................................573
Class and Object Variables ................................................................574
Constructors and Destructors............................................................575
Class Inheritance ...............................................................................575
The Standard Library and the Vaults of Parnassus ....................................577
Reference .....................................................................................................577
25 Writing PHP Scripts 579
Introduction to PHP ...................................................................................580
Entering and Exiting PHP Mode .......................................................580
Variables.............................................................................................580
Arrays .................................................................................................582
Constants...........................................................................................584
References ..........................................................................................584
Comments .........................................................................................585
Escape Sequences ...............................................................................585
Variable Substitution .........................................................................587
Operators ...........................................................................................587
Conditional Statements.....................................................................589
Special Operators ...............................................................................591
Switching ...........................................................................................592
Loops..................................................................................................593
Including Other Files.........................................................................596
Basic Functions ...........................................................................................596
Strings ................................................................................................596
Arrays .................................................................................................600
Files ....................................................................................................602
Miscellaneous.....................................................................................604
Handling HTML Forms ...............................................................................607
Databases.....................................................................................................608
Introduction to PEAR::DB .................................................................608
Reference .....................................................................................................610
26 C/C++ Programming Tools for Ubuntu 613
Programming in C with Linux ...................................................................613
Using the C Programming Project Management Tools
Provided with Ubuntu..............................................................................614
Building Programs with make ...........................................................615
Using Makefiles..................................................................................615
Using the autoconf Utility to Configure Code .................................617
Managing Software Projects with Subversion...................................617
Debugging Tools ................................................................................618
Using the GNU C Compiler .......................................................................619
Graphical Development Tools ....................................................................620
Using the KDevelop Client................................................................620
The Glade Client for Developing in GNOME...................................621
Reference .....................................................................................................623
27 Mono 625
Why Use Mono? .........................................................................................625
Mono on the Command Line ....................................................................626
The Structure of a C# Program..........................................................628
Printing Out the Parameters..............................................................629
Creating Your Own Variables ............................................................629
Adding Some Error Checking............................................................630
Building on Mono’s Libraries .....................................................................631
Searching with Beagle........................................................................631
Creating a GUI with Gtk# .................................................................634
Reference .....................................................................................................636
Part VI Ubuntu Housekeeping
28 Securing Your Machines 639
Understanding Computer Attacks..............................................................639
Assessing Your Vulnerability.......................................................................641
Protecting Your Machine ............................................................................642
Securing a Wireless Network .............................................................642
Passwords and Physical Security .......................................................643
Configuring and Using Tripwire .......................................................644
Devices ...............................................................................................645
Viruses .........................................................................................................645
Configuring Your Firewall...........................................................................646
Forming a Disaster Recovery Plan ..............................................................647
Keeping Up-to-Date on Linux Security Issues............................................648
Reference .....................................................................................................649
29 Performance Tuning 651
Hard Disk ....................................................................................................651
Using the BIOS and Kernel to Tune the Disk Drives ........................652
The hdparm Command.....................................................................653
File System Tuning ............................................................................654
The tune2fs Command......................................................................654
The e2fsck Command........................................................................655
The badblocks Command .................................................................655
Disabling File Access Time.................................................................655
Kernel ..........................................................................................................655
Apache.........................................................................................................656
MySQL.........................................................................................................658
Measuring Key Buffer Usage..............................................................658
Using the Query Cache .....................................................................660
Miscellaneous Tweaks........................................................................661
Query Optimization ..........................................................................661
Reference .....................................................................................................662
30 Command Line Masterclass 663
Why Use the Shell?.....................................................................................664
Basic Commands.........................................................................................665
Printing the Contents of a File with cat ...........................................666
Changing Directories with cd ...........................................................667
Changing File Access Permissions with chmod................................668
Copying Files with cp........................................................................669
Printing Disk Usage with du .............................................................669
Finding Files by Searching with find ................................................670
Searches for a String in Input with grep ...........................................673
Paging Through Output with less .....................................................674
Creating Links Between Files with ln................................................676
Finding Files from an Index with locate...........................................677
Listing Files in the Current Directory with ls ...................................678
Reading Manual Pages with man......................................................679
Making Directories with mkdir .........................................................680
Moving Files with mv........................................................................680
Listing Processes with ps ...................................................................680
Deleting Files and Directories with rm .............................................681
Printing the Last Lines of a File with tail..........................................682
Printing Resource Usage with top .....................................................682
Printing the Location of a Command with which...........................684
Combining Commands ..............................................................................684
Multiple Terminals......................................................................................686
Reference .....................................................................................................687
31 Managing Software 689
Using Add/Remove Applications for Software Management.....................689
Using Synaptic for Software Management .................................................691
Staying Up-to-Date......................................................................................693
Working on the Command Line ................................................................694
Day-to-Day Usage ..............................................................................694
Finding Software................................................................................697
Compiling Software from Source ...............................................................698
Reference .....................................................................................................699
32 Kernel and Module Management 701
The Linux Kernel ........................................................................................702
The Linux Source Tree .......................................................................702
Types of Kernels.................................................................................704
Managing Modules .....................................................................................706
When to Recompile ....................................................................................708
Kernel Versions ...........................................................................................708
Obtaining the Kernel Sources .....................................................................709
Patching the Kernel ....................................................................................710
Compiling the Kernel .................................................................................712
Using xconfig to Configure the Kernel.............................................717
Creating an Initial RAM Disk Image .................................................720
When Something Goes Wrong...................................................................721
Errors During Compile ......................................................................721
Runtime Errors, Boot Loader Problems, and Kernel Oops ...............722
Reference .....................................................................................................723
Part VII Appendixes
A Ubuntu Under the Hood 727
What Is Linux?............................................................................................727
Why Use Linux?..........................................................................................729
What Is Ubuntu?.........................................................................................730
Roots of Ubuntu ................................................................................730
Ubuntu for Business....................................................................................731
Ubuntu in Your Home ................................................................................732
64-Bit Ubuntu .............................................................................................733
Ubuntu on the PPC Platform .....................................................................733
Getting the Most from Ubuntu and Linux Documentation .....................733
Ubuntu Developers and Documentation ...................................................735
Reference .....................................................................................................735
B Installation Resources 737
Planning Your Ubuntu Deployment ..........................................................738
Business Considerations ....................................................................738
System Considerations ......................................................................741
User Considerations...........................................................................742
A Predeployment Planning Checklist ...............................................742
Planning the Installation...................................................................742
Hardware Requirements..............................................................................743
Meeting the Minimum Ubuntu Hardware Requirements ................743
Using Legacy Hardware .....................................................................744
Planning for Hard Drive Storage for Your Ubuntu Installation .......744
Checking Hardware Compatibility ...................................................745
Preparing for Potential Hardware Problems......................................746
Preparing and Using a Hardware Inventory .....................................749
Preparing for the Install Process .................................................................750
Preparing to Install from a CD-ROM ................................................753
Partitioning Before and During Installation ..............................................754
Choosing a Partitioning Scheme.......................................................756
Hosting Parts of the Linux File System on Separate Partitions ........756
Reference .....................................................................................................757
C Ubuntu and Linux Internet Resources 759
Websites and Search Engines......................................................................760
Web Search Tips.................................................................................760
Google Is Your Friend ........................................................................761
Ubuntu Package Listings ...................................................................761
Certification.......................................................................................761
Commercial Support..........................................................................762
Documentation..................................................................................762
Linux Guides......................................................................................763
Ubuntu...............................................................................................763
Mini-CD Linux Distributions ............................................................763
Various Intel-Based Linux Distributions ...........................................764
PowerPC-Based Linux Distributions..................................................764
Linux on Laptops and PDAs..............................................................765
The X Window System ......................................................................765
Usenet Newsgroups.....................................................................................765
Mailing Lists................................................................................................767
Ubuntu Project Mailing Lists.............................................................767
Internet Relay Chat.....................................................................................767
Index 769