12.07.2015 Views

3 - fileserver

3 - fileserver

3 - fileserver

SHOW MORE
SHOW LESS
  • No tags were found...

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

IntroductionWelcome to Linux! You hold in your hands everything you need to install and use one ofthe most powerful computer operating systems in the world. This book is designed tohelp guide you through the process of learning about Linux. To make the task even easier,this book uses one of the best Linux distributions on the market today—OpenLinuxfrom Caldera Systems, Inc.Although the title of this book is Teach Yourself Linux in 24 Hours, you won’t be alonewhile you learn. As you’re taken from installation through system administration to playinggames, you’ll find advice, tips, and hints to help you along the way. Before you knowit, you’ll be familiar with the terms, topics, and technical concepts dealing with thehottest and newest operating system in the world—Linux!Teach Yourself Linux in 24 Hours is designed to help you learn quickly. You’ll find it anindispensable guide to installing Linux and getting right to work. This helps you overcometechnical obstacles, explains complex subjects in simple language, and shows yousome neat tricks to make your computing experience easier.Each section of this book gives you an hour’s worth of knowledge and examples you canrun as you learn. By the way, this book was created, developed, and edited using the softwareincluded on the book’s CD-ROM. I hope you enjoy teaching yourself Linux!What is Linux?Linux (pronounced lih-nuks) is a UNIX-like operating system that runs on many differentcomputers. Although many people might refer to Linux as the operating system andincluded software, strictly speaking, Linux is the operating system kernel, which comeswith a distribution of software. The Linux distribution included with this book is CalderaSystems, Inc. OpenLinux and features special software not included with other distributions(see the section “What’s Included on the CD-ROM?” later in the “Introduction”).Linux was first released in 1991 by its author, Linus Torvalds, at the University ofHelsinki. Since then, it has grown tremendously in popularity as programmers around theworld embraced his project of building a free operating system, adding features, and fixingproblems.Linux is popular with today’s generation of computer users for the same reasons earlyversions of the UNIX operating system enticed fans more than 20 years ago. Linux isportable, which means you’ll find versions running on name-brand or clone PCs, AppleMacintoshes, Sun workstations, or Alpha-based computers. Linux also comes with


2 Sams Teach Yourself Linux in 24 Hourssource code, so you can change or customize the software to adapt to your needs.Finally, Linux is a great operating system that is rich in features adopted from otherversions of UNIX. Soon you’ll become a fan, too!Why Teach Yourself Linux?You should teach yourself Linux for a number of good reasons. You’ll expand yourknowledge of your computer’s hardware, which can be handy in troubleshooting problems.You’ll also learn the basics of using a UNIX-like operating system loaded withstate-of-the-art features. When you combine this knowledge of hardware and software,you’ll be well on your way to becoming a “power” computer user.Use this book as a starting point in learning Linux basics. You’ll learn all the skills youneed to build and run a powerful and productive Linux workstation. Although you won’tlearn how to program in Java, administer a wide-area network, or manage a Web server,you will learn these things:●●●●Using Linux is a great way to connect to the Internet for emailing, file downloading,or World Wide Web browsing.You can get to work right away, as this book’s Linux distribution (on CD-ROM)comes with a rich assortment of popular productivity tools, such as word processors,calendars, emailers, or graphics programs. More than 2,000 programs areincluded!You can have fun with some wacky arcade games.In no time at all, you’ll be on your way to joining the worldwide community ofLinux users.Who is This Book For?This book is for someone who wants to quickly master the basics of how to install, run,and maintain Linux on an Intel-based personal computer. All the tools you need areincluded.Your computer should have a monitor (display), keyboard, mouse, hard drive, floppydrive, and CD-ROM drive. Although you can jump right in and install Linux on yourhard drive, you should have some technical information about your computer and itshardware on hand before you start.


4 Sams Teach Yourself Linux in 24 HoursA Tip informs you of a trick or element that is easily missed by most newLinux users. Feel free to skip these hints and additions; however, if you skipreading them, you might miss a shorter or more efficient way to accomplisha task described in the main text.A Caution deserves at least as much attention as the body of the lesson,because these point out a problematic element of the operating system or a“gotcha” you want to avoid while using the operating system. Ignoring theinformation contained in a Caution could have adverse effects on the stabilityof your computer. Be careful to read every Caution you run across.A Note is designed to clarify the concept being discussed. Notes also containadditional information that might be slightly off-topic but interestingnonetheless. Notes elaborate on the subject, and if you’re comfortable withyour understanding of the subject, you can read these to add to your knowledgeor bypass them with no danger.Each lesson concludes with a Summary of what you have just learned, a Q&A sectionthat answers the questions users new to Linux most frequently ask about that particularlesson’s subject, and a Workshop containing exercises that will advance the reader in afurther, hands-on study of that lesson’s topic.


PART IInstallation andConfigurationHour1 Preparing to Install Linux2 Installing Linux3 Post-Installation Issues


HOUR 1Preparing to Install LinuxWelcome to the wonderful world of Linux! This hour is the best place tostart reading before attempting to install OpenLinux. There are several goodreasons, especially for new Linux users, to sit down, take a deep breath,relax, and collect some thoughts before jumping into an installation.Intrepid or experienced Linux users, such as those migrating from other distributionsand installations such as Red Hat, Debian, or S.U.S.E. might feeltempted to rip the CD-ROM out of the back of this book and launch theinstallation. Hey, go for it! The CD-ROM boots, and you can easily use yourexisting Linux partitions. I think you’ll be quite pleased with the treasuretrove of software and the carefully crafted Caldera configuration of Linux.For those of you coming into the light from the Dark Side—welcome!Consider some of the topics covered in this hour:●●●What is Linux? (Or what isn’t it?)What is OpenLinux? (And how is it different from other Linuxdistributions?)What equipment is required? (Do I have everything?)


8 Hour 1●●●●●●What equipment is supported? (Will my stuff work?)What equipment doesn’t work? (Uh oh! What am I going to miss?)What equipment do I have? (Do I know about my computer?)How do I plan for the installation? (What do I need to know?)How is Linux installed? (Count me the ways!)How do I plan to boot OpenLinux? (How can I boot Linux?)After these introductory sections, you then get directions on how to prepare your harddrive for OpenLinux. So, if you’re an experienced user, skip this hour. Heck, you canskip the next two hours! But if you want to know a little more about Linux and howOpenLinux is different, read on! First-time Linux installers and users definitely need toread what follows.What is Linux?Linux is the kernel of an operating system that runs on many different types ofcomputers. This is the core piece of software that provides an interface betweenthe command line or program and your computer’s hardware. The Linux kernel managessuch things as memory, how and when files are opened or closed, and what process, orprogram, has the full attention of your computer’s Central Processing Unit (CPU).NEW TERMLinux, a clone of the UNIX operating system, was first released on October 5, 1991 byits author, Linus Torvalds, at the University of Helsinki. Linux supports all the featuresof a modern operating system, including (but not limited to) the following:●●●●●●●●●●●●All major networking protocolsDisk quota supportFull source codeInternationalization for fonts and keyboardsJob controlMath co-processor emulationMemory protectionMultiple platformsMultiple processorsMultiple usersMultitaskingShared libraries


Preparing to Install Linux 11Video cards, or video chipsets for laptop users, are listed under the/usr/X11R6/lib/X11/doc directory after you install OpenLinux and the X WindowSystem. To read an online list of supported cards for X11 (and which X11 server to use),browse to this site:1http://www.xfree86.org/cardlist.htmlLaptop users definitely need to browse the Linux Laptop Pages. There are specific directionson how to install and configure Linux and X11 for your laptop. Look for your laptopmodel listed at this site:http://www.cs.utexas.edu/users/kharker/linux-laptop/What Equipment Doesn’t Work?With the explosion of the personal computer market in the last few years, more and morehomes and businesses are either buying computers for the first time or upgrading oldercomputers. Believe it or not, you’ll probably have fewer problems installing Linux withone- to three-year-old hardware than if you’re on the latest and greatest PC. This isbecause although Linux is supported by the efforts of programmers around the world, notmany PC manufacturers support Linux (yet!) by releasing the specifications of theirhardware. Without these techincal details, programmers can have a difficult time writingsoftware. If your computer’s hardware is not supported by Linux, complain to its manufacturer!Fortunately, the list of unsupported hardware, or hardware with problems, is muchsmaller than supported hardware. For example, you might have trouble with older 486-based AMD CPUs, older Cyrix CPUs, and Microchannel-based PCs. There is little supportfor parallel-port tape drives and some Xircom ethernet cards with the current Linuxsoftware.WinprintersWinprinters, or printers that depend on operating system-specific drivers, such as theHewlett-Packard 710, 720, 820, and 1000-series printers, are not supported by softwareincluded on this book’s CD-ROM. However, you can find support for some of theseprinters through the use of special software, located at this site:http://www.rpi.edu/~normat/technical/ppaOther problems crop up with printing support for Epson Stylus color printers. You canfind some answers from Caldera at the following site:http://www.calderasystems.com/support/techguide/styluscolor.html


12 Hour 1WinmodemsWinmodems (part of a disgusting recent trend by PC and laptop manufacturers trying tosave a few pennies per unit) are operating system-specific and will probably never besupported by Linux. These modems, which use less hardware than “real” modems,work through the use of software drivers (it’s cheaper to offload all the work on yourcomputer’s CPU; besides, if you use Windows 9x, you’re only doing one thing at a timeanyway, right?). If you buy a PC or laptop with one of these modems, you’re at themercy of the manufacturer whether the modem is supported in the future or whether itworks with another operating system.Beware! Many manufacturers tout these modems as “56K ITU V.90modems,” but fail to mention they are winmodems. Ask if the modem canbe used with DR-DOS, PCDOS, or MSDOS. If not, it’s a winmodem. To besafe, buy an external modem that can be used with any computer operatingsystem.Infrared PortsAlthough software to support your computer’s infrared port isn’t included on this book’sCD-ROM, the good news is that there is full infrared support for OpenLinux. This meansthat if you have a laptop or desktop with an IR port, you can now network, print to an IRprinter (such as an HP 340Cbi or Canon BJC80), and even transfer or back up your3Com Palm PDA without cables! Browse to this site:http://www.cs.uit.no/~dagb/irda/irda.htmlThere are directions on how to download, install, and configure IR support for Linux.For complete directions in a HOWTO document format, browse to this site:http://www.userpage.fu-berlin.de/~r2d2c3po/ir_howto.cgiIf you own a 3Com Palm Pilot Professional or Palm III, there are nearly twodozen Pilot support utilities included with OpenLinux. Kenneth Albanowski’spilot-xfer command makes backing up a Palm III as easy as this:pilot-xfer /dev/pilot –b pilotbackupdirectoryIf you use KDE, use the Kpilot client, installed from the /col/install/RPMSdirectory on your OpenLinux CD-ROM. This is a graphical interface to administeringyour Palm computer.


Preparing to Install Linux 13What Equipment Do I Have?You need to know a little about your computer before installing OpenLinux. Get out yourpaper and pencil, and then fill out as much information as you can in this section’s followingchecklist. If your PC or laptop manufacturer didn’t document all the technicaldetails of your computer, you might have to browse the manufacturer’s Web site or callfor the information.1●●●●●●●●●●●●●●●●●●●Type of CPU (386, and so on)Amount of system RAM (in megabytes)Total size of hard drive (in megabytes)Hard drive space needed for the Linux swap partition (twice the size of systemmemory, or your computer’s RAM; see Hour 2, “Installing Linux”)Size of hard drive you want for OpenLinux (in megabytes, depending on the typeof installation; see Hour 2)Type of hard drive controller (for example, IDE/SCSI)Type of CD-ROM controller (for example, ATAPI)Number of serial ports (note: there is no Universal Serial Bus, or USB, support forLinux at the time of this writing)Type of keyboard (PS/2, most likely)Number of keys (101, 102, 104, and so on)Type of mouse (PS/2, serial, and so on)Infrared port (COM1–COM4, IRQs used, shared, and so on)Serial port assignments (COM1–COM4, IRQs used)Type of modem (Fax class support, such as Class 1, 2.0, voice, and so on)Parallel port assignment (0x378, IRQ 5, and so on)Model and type of printer (Epson, HP, PostScript, HPCL, and so on)PC cards used (modem, network, flash memory, and so on)Type of PCMCIA controller (TI, for example)Type of sound card (SoundBlaster, ESS, and so on)● I/O address of sound card (such as 0x220)●DMA values (0, 1, and so on)● Sound card IRQ (such as 5 or 7)●Miscellaneous addresses (such as for MPU)


14 Hour 1●●●●●●Type of graphics card (chipset used, such as TGUI9680, Cirrus Logic, ATI Rage II,and so on)Amount of video memory (1MB, 2MB, 4MB, and so on)Color depth capability (256, 16-bit, 24-bit, and so on)Monitor Horizontal Refresh (such as 31.5–60, 31.4, and so on)Monitor Vertical Refresh (70–100, for example)Monitor Maximum Resolution (800×600, 1024×768, 1280×1024, and so on)You might not need all this information to install OpenLinux, but sooner or later thesedetails come in handy when you install PC cards, set up sound, or configure X11.How Do I Plan for the Installation?Many new OpenLinux users easily install Linux by themselves. If you experience a problem,don’t be disappointed, and don’t give up! Here are the four basic hurdles to a successfulOpenLinux installation:1. Partitioning the hard drive—This is one of the reasons many people think Linux ishard to install. How many computer users today have partitioned a hard drive oreven installed an operating system? Don’t be intimidated by this step, whichmerely makes room for OpenLinux on your hard drive. Just make sure to back upimportant documents or files before you begin. See Table 1.1 for the size requirementsof different installations, and then write down your requirements. Manyexperienced OpenLinux users don’t bother with this step at all and simply installLinux as the sole operating system. Installing Linux is a breeze if you don’t haveto deal with creating or resizing hard drive partitions.TABLE 1.1CALDERA OPENLINUX INSTALLATION REQUIREMENTSSize in MegabytesInstallation Description300 Small system (with X11 and KDE) with programs suitableto use your computer as a server500 Standard system (the default); includes developmenttools and other programs suitable for a server andworkstation1024 Full installation (everything)


Preparing to Install Linux 152. Configuring the X Window System—X11 is the default graphical interface forOpenLinux—but it is not Linux. X runs on many different types of computers andoperating systems, which is why there is such a wealth of graphical programs forLinux. You have a better chance of configuring X11 to work with your graphicshardware if you have a graphics card that’s been on the market for at least twoyears. You’ll configure X11 during your OpenLinux installation. Details about configuringX can be found under the /usr/X11R6/lib/X11/doc directory afterOpenLinux is installed.3. Configuring sound—OpenLinux comes with loadable code modules you can use toget sound working, or you can recompile the Linux kernel to work with your soundcard (some details can be found athttp://www.calderasystems.com/support/techguide.html). If you don’t wantto hassle with kernel modules or rebuilds, browse to http://www.4fronttech.com/oss.html,and download an evaluation copy of the Open Sound Systemdrivers. This inexpensive set of sound drivers supports hundreds of different soundsystems. Using OSS is one of the easiest ways to configure sound cards for Linux.See Hour 20, “Relaxation and Playing Linux Games,” for tips on configuringOpenLinux for sound.4. Getting connected—Connecting to the Internet using OpenLinux is an importantstep. To make the job of connecting to the Internet easier, use the Red Hat netcfgtool, the kppp client, or the xisp client to set up your account. Make sure to readthe PPP HOWTO and ISP Hookup HOWTO under the /usr/doc/HOWTO directoryif you have trouble. Hour 9, “Using Communications Programs,” has the detailsabout using a modem with OpenLinux. See Hour 10, “Connecting to the Internet,”for information about how to establish a PPP connection.1You next have to decide how to install OpenLinux. I don’t cover installing Linux using anetwork or a Parallel Line (PLIP) interface (for details about these methods, seehttp://www.calderasystems.com/support/techguide.html).Booting the Install from CD-ROMThe easiest way to install OpenLinux is to insert the OpenLinux CD-ROM in your computer,reboot, and follow the prompts. Booting from a CD-ROM drive might require youto reset your computer’s BIOS to change the order of boot disk recognition (usually doneby pressing a particular F key (or key sequence) after starting your computer—see yourcomputer’s manual for details).


16 Hour 1Booting the Install from FloppiesYou can create a boot floppy diskette, then insert your OpenLinux CD-ROM, and bootfrom your floppy to start an installation. The easiest way to create a boot floppy is toinstall the OpenLinux utilities under Windows (see this chapter’s later section “PreparingYour Hard Drive from Windows”). You can then click on the Create Install Diskette iconin the OpenLinux program folder on your Start menu.You can also use the RAWRITE3.COM program under DOS to create the floppy if you cannotboot the OpenLinux CD-ROM. First, note the drive letter (such as D or E) for yourCD-ROM. To create a boot floppy, do the following:1. Insert the OpenLinux CD-ROM, and then reboot to DOS. At the DOS commandline, type the drive letter of your CD-ROM, change the directory to the\col\launch\floppy directory, and start the RAWRITE3 command like this:D:CD \COL\LAUNCH\FLOPPYRAWRITE32. After the RAWRITE3 program starts, it asks you to enter the source file name. TypeINSTALL.144, and press Enter.3. RAWRITE3 then asks you to enter the destination drive (A or B); type the drive letterof your floppy, such as A, and press Enter.4. RAWRITE3 then asks you to install the target diskette in the disk drive. Insert a blankdiskette into your drive, and press Enter.5. RAWRITE3 copies the file INSTALL.144 to your floppy.6. When you finish, remove and label the diskette.If you have a PCMCIA CD-ROM drive or need other specialized support,repeat the preceding steps with a separate floppy, but use MODULES.144instead of INSTALL.144. This creates a second disk with software you needto help OpenLinux recognize your external CD-ROM or PC cards during thefirst installation steps.Label and keep your boot floppies in a safe place. You’ll need them (if you don’t bootfrom CD-ROM) in Hour 2.


Preparing to Install Linux 17Other WaysA number of hardware vendors also offer Linux preinstalled on a new hard drive, laptop,or computer. If you want a computer completely configured out of the box, this is theway to go. Browse to http://metalab.unc.edu/LDP/HOWTO/VAR-HOWTO.html.1You can always ask a friend with Linux experience to come over and installOpenLinux for you! This is a great way to share information, and havingsomeone on hand to help can make the installation process easier.Alternatively, go to a Linux User Group (LUG) InstallFest! Browse tohttp://www.linux.org/users/index.html to find a LUG near you. LUGs regularlyhold installation meetings, and you can have OpenLinux installed andconfigured in no time at all!Planning Your Boot ProcessThere are many different ways to start Linux. You have to decide whether you want tostart Linux from a boot prompt, a command line in DOS, from floppy diskette, or a commercialsoftware program.1. LILO—The Linux loader (LILO) is a small program used to jumpstart Linux orother operating systems. You can install LILO in the Master Boot Record of a DOSpartition or in the root partition of a Linux partition on your hard drive directlyafter the install process.Install OpenLinux and LILO after you have installed Windows. With typicaldisregard, other operating system installs wipe out LILO (although it can berestored by booting with a Linux boot diskette and rerunning the lilo commandfound under the /sbin directory.2. LOADLIN.EXE—Use the LOADLIN program from DOS to boot Linux. You do nothave to install LILO if you use this program. You need to copy the Linux kernelonto a DOS partition or floppy. Booting from DOS has the advantage of enablingcertain hardware (such as an Mwave adapter) to work with OpenLinux.3. Boot diskette—A boot diskette can also be used to start Linux. You can save LILOon a diskette and then boot Linux, DOS, or other operating systems.


18 Hour 14. Floppy—Want to try Linux from a floppy before installing OpenLinux? Browse tohttp://metalab.unc.edu/LDP/devel.html and search for Linux distributions thatfit on a floppy. You can boot to Linux with a single floppy (but you don’t get the XWindow System).5. System Commander—This is a commercial program you can use to boot multipleoperating systems. Browse to http://www.systemcommander.com for details.6. BootMagic—Included with PowerQuest Corp.’s PartitionMagic, BootMagic can beused to boot multiple operating systems, such as Windows NT and IBM’s OS2.The commercial version of PartitionMagic also includes a DOS utility namedPQBoot, which lists active, bootable partitions and can be used to boot other operatingsystems, such as Linux. Browse to http://www.powerquest.com for details.Preparing Your Hard DriveThe first step in the installation process (after making boot floppies, if needed) isto partition, or create room on your hard drive. If you only want to useOpenLinux on your computer, skip the rest of this hour and proceed directly to Hour 2.But if you want to use a dual-boot computer, or boot at least two different operating systems,you need to create a partition on your hard drive with enough room for yourOpenLinux software.NEW TERMPartitions are nothing more than a special way to look at a hard drive and how itis divided up. There are two types of partitions: primary and extended. Your harddrive can contain four primary partitions. If you need to further divide or map your harddrive, you can designate one of these primary partitions as an extended partition (whichcan then be divided up even more).NEW TERMThese partitions generally contain a filesystem. A filesystem is how files ordirectories are written to the hard drive. DOS and older versions of Windows usea filesystem called FAT16. Newer versions of Windows use FAT32. Linux uses two typesof filesystems: ext2 (for storing files) and swap (for temporarily storing memory).NEW TERMFortunately, Caldera’s OpenLinux CD-ROM contains everything you need to partitionyour hard drive for OpenLinux! This CD-ROM contains limited editions ofPowerQuest’s PartitionMagic and Boot Magic. You’ll be able to set up your Linux partitionsdirectly from Windows after you install these utilities (read on to learn how).


Preparing to Install Linux 19During the installation process, some laptop and desktop users might find asmall partition used by the computer’s BIOS for “Save to Disk” operations(such as putting the computer to sleep). This partition is generally the samesize as the amount of system memory, or RAM, installed in your computer.Generally speaking, leave this partition alone. Also note that if you increaseyour computer’s RAM, the partition might need to be resized to match thenew size of internal memory (which could cause some interesting jugglingor resizing of other partitions).1Preparing Your Hard Drive from WindowsThe first step to preparing your hard drive to support booting Windows and OpenLinux isto install Caldera’s and Power Quest’s utilities. Start your computer. When the Windowsdesktop appears, insert your OpenLinux CD-ROM. The OpenLinux Welcome screenshould appear, as shown in Figure 1.1.FIGURE 1.1The OpenLinuxWelcome dialog box isthe starting point foryour OpenLinuxadventure!If the install process doesn’t begin automatically, double-click your computer’sCD-ROM icon under the My Computer folder.Follow the prompts, and this setup procedure will create an OpenLinux program folderin your Start menu. This folder will contain Shortcuts to creating installation (boot) floppies,installing Boot Magic (to support booting Windows and Linux), and partitioningyour hard drive and installing Linux. After the setup finishes, double-click the Partitionand Install Linux icon (as shown in Figure 1.2).


20 Hour 1FIGURE 1.2Double-click thePartition and InstallLinux program tobegin your installation.This will start the PartitionMagic Caldera Edition setup program, as shown in Figure 1.3.Follow the prompts, and the setup will create a PowerQuest program folder on your harddrive. A PartitionMagic program folder for your Start menu will also be created.FIGURE 1.3To start your installation,you must firstinstall thePartitionMagicCaldera Editionprogram.After the installation, the setup program will then ask you to click a Finish button. Thiswill shut down Windows and run PartitionMagic. You’ll be asked, as shown in Figure1.4, to remove your OpenLinux CD-ROM before continuing. This is because you mustfirst create your Linux partitions before you install Linux. (Your computer could rebootdirectly to installing OpenLinux if the CD-ROM is still inserted.)


Preparing to Install Linux 21FIGURE 1.4Don’t forget to removeyour CD-ROM beforecontinuing your installation!1If you already have a Linux installation and use LILO, your computer willreboot to LILO at this point. To continue the installation, boot to Windowsfrom LILO. However, the installation procedure will not recognize your existingLinux partitions. After you install OpenLinux, you’ll find a Delete Linuxicon in the PartitionMagic program folder you can use to delete Linux partitions.The best way to install OpenLinux on an existing Linux setup is toreboot and install OpenLinux using the installation floppies or directly fromCD-ROM. See Hour 2, “Installing Linux,” for details.PartitionMagic Caldera Edition will only recognize your first hard drive and will onlycreate three different sized partitions: 300 megabytes, 500 megabytes, and one gigabyte.When its dialog box appears, click the desired Linux partition size, and click the OK button.You then see PartitionMagic’s dialog box, which shows the partitioning progress.After the partitioning is complete, insert your OpenLinux boot floppy diskette and/oryour OpenLinux CD-ROM, and reboot your computer to start the installation.If you want to use more hard drive space than the maximum one gigabyteafforded by the limited edition of PartitionMagic, boot directly to theOpenLinux installation with a boot floppy and/or the OpenLinux CD-ROM.During the initial installation, choose the Custom partitioning scheme. Note,however, that you must have an available existing or empty partition; thispartition will be formatted for Linux.SummaryThis hour introduced you to some basic concepts about Linux, OpenLinux, and how toprepare for a Linux installation.


22 Hour 1Q&AQ I’m confused! What’s the best way to install OpenLinux?A Although it all depends on your computer’s hardware and how you plan to useOpenLinux, the simplest, most direct way to install OpenLinux is to boot with theOpenLinux CD-ROM from the back of this book. You can overwrite any existingdata and install OpenLinux as the primary operating system.Q I want to use NT and OpenLinux! What do I do?A Install NT first. But when installing OpenLinux, install LILO in the Linux rootpartition (see Hour 2).Q I have the commercial version PartitionMagic. Can I use this program insteadof the Caldera Edition?A Yes. You’ll have a bit more flexibility, as PartitionMagic can create any size partitionfrom your existing hard drive space. Caldera included a special edition ofPartitionMagic to make the job of making room on your hard drive a bit easier, butthe commercial version of PartitionMagic offers many, many additional features.Q I have 32 megabytes of RAM. How large of a swap space should I plan for?What’s the largest swap space I can use?A If you have 32 megabytes of RAM, plan on creating a 64-megabyte swap partition.In general, create a swap partition at least twice the amount of your computer’sRAM (or larger if you plan to run memory-intensive programs, such as graphicseditors).Exercises1. Create your OpenLinux installation boot floppies. Make sure to label them correctly.2. Install OpenLinux and PowerQuest’s Caldera Systems Edition PartitionMagic.Note which program folders are used for OpenLinux and PartitionMagic in yourStart menu.3. Sit down and calculate the amount of hard drive space you want to use withOpenLinux. Don’t forget to include the swap space required!


HOUR 2Installing LinuxThis hour shows you how to install OpenLinux. At this point, you shouldknow how much hard drive space you want to devote to OpenLinux. Youshould also have filled out the checklist presented in Hour 1, “Preparing toInstall Linux,” and have this information on hand during and after the installationprocess. You also need the OpenLinux boot disks if your computercannot boot from a CD-ROM drive. Take your time during the installation,and don’t proceed until you’re sure of the information presented in theinstallation dialog boxes.If you’ve installed OpenLinux or other Linux distributions, be prepared for apleasant surprise! The latest version of Caldera OpenLinux offers the fastestand easiest Linux installation ever! The folks at Caldera have made thechore of installing Linux a pleasant task with features such as the following:●●●A complete graphical interface to the install processPoint-and-click hard drive partitioning for expertsBackground installation of packages from CD-ROM while continuingthe system configuration process


24 Hour 2●●Automatic detection of graphics cards for configuring the X Window SystemA pleasant diversion while the installation continuesYou have backed up any important documents or files, right? Don’t proceedto install OpenLinux unless you’re absolutely sure you won’t lose any importantdata. If you’re installing OpenLinux on a brand new desktop or notebookcomputer, make sure you have a restore CD-ROM or have followed themanufacturer’s recommendations on backing up critical device drivers.Granted, you might be able to get most of the important files from themanufacturer’s Web site, but unfortunately, many computer manufacturersdon’t provide a restore CD-ROM and still require end users to back upincluded software to diskette. You have been warned!Beginning the InstallationExperienced installers might have skipped the installation instructions in Hour 1. If so,the first step is to set your computer to boot from its CD-ROM drive. This might requireyou to restart your computer and then press and hold down a function key during therestart to enter your computer’s BIOS manager. Set your computer’s BIOS to change theorder of the recognized boot device so the CD-ROM drive is recognized first. You probablyhave to then save these changes and restart your computer. Then, do the following:1. Insert the OpenLinux CD-ROM in your computer, and reboot.2. If you followed the directions in Hour One and inserted your CD-ROM, when yourcomputer restarts, you see Caldera’s splash screen.3. OpenLinux starts booting. You see various lines of technical information flash byon the screen as OpenLinux determines the various components installed on yourcomputer (such as the hard drive, floppy, serial ports, keyboard, or CD-ROM) andattempts to load various software components.4. At the dialog box Shown in Figure 2.1, click to select the type of mouse installedon your system. Test your mouse buttons by moving your cursor to the labeled testarea and then clicking the left, right, or middle mouse buttons. When you finish,click the Next button.


Installing Linux 25FIGURE 2.1OpenLinux shouldautomatically detectyour mouse, but youcan use the Set UpMouse dialog to testyour mouse buttons.25. You’re asked to select where Linux should be installed. If you partitioned yourhard drive with Partition Magic, OpenLinux automatically highlights the PreparedPartitions button—click Next to continue. (Partition Magic will have automaticallycreated a large, single Linux partition and a smaller Linux swap partition for theinstallation process.)The Caldera Edition of Partition Magic implements a simple partitioningscheme using a single Linux native and a single swap partition. This is theeasiest and fastest way to install OpenLinux, but it might not suit the needsof more advanced users. For a quick digression on partitioning, read Eric S.Raymond’s Installation HOWTO (under the /usr/doc/HOWTO directory), especiallySection 6.4, “Creating partitions for Linux.”If you’d rather use the entire hard drive, click Entire Hard disk to format and installLinux.If you select Entire Hard disk, OpenLinux formats your entire drive. Makesure this is what you want to do! Always back up important informationbefore installing Linux (or any other operating system)!


26 Hour 2If you want to create several Linux partitions from an existing spare partition, clickCustom (Expert only!), and click the Next button. You see a dialog box you canuse to split up an existing partition to create different partitions for different partsof your OpenLinux installation (many experienced Linux users create separate partitionsfor programs, users, or temporary storage). Use the Custom (Expert only!)dialog box to create Linux partitions from existing Linux, Windows, or DOS harddrive partitions. By using the Edit button in the Expert mode, you can change thesize of a partition and designate mounting points for Linux partitions. When youfinish with the Expert mode, click the Write button to save your changes, and thenclick the Next button to continue.6. OpenLinux now displays the Linux partition information, as shown in Figure 2.2.You should see at least one Root Partition (with a “/” Mount Point) and a VirtualMemory (or swap) partition. If you’re satisfied, click the Format Chosen Partitionsbutton to continue.FIGURE 2.2Format your Linuxpartitions prior toinstalling OpenLinux7. OpenLinux now formats your new Linux partitions. When the formatting is finished,the Next button becomes active. Click Next to continue.8. You’re now asked to select an installation. There are four choices: a minimum set(about 300 megabytes for a server installation with the X Window System); all recommendedpackages (about 500 megabytes for a server and workstation installationwith the X Window System and development packages); all recommendedplus commercial packages; and all packages (about one gigabyte for a completeinstallation of all the software included on your CD-ROM). Click the desired packageto install, and then click the Next button to continue.


Installing Linux 27OpenLinux doesn’t enable you to try to choose an installation larger thanthe available space on your Linux partition. You have to choose a smallerinstallation. If you have the hard drive space, you can back through theinstallation dialog boxes by pressing the Back button to create a larger Linuxpartition or create additional Linux partitions later.9. OpenLinux now shows a dialog box and asks you to select a keyboard model andlayout. Scroll through the list of keyboards, and click your model. Next, select akeyboard layout (such as U.S. English). To test the selected keyboard, click in theTest here field and type some text. When you finish, click the Next button to continue.Also, note that the package installation continues copying files to your Linuxpartition while you continue the configuration process!10. OpenLinux now asks you to select your video card, as shown in Figure 2.3. This isa critical step in the installation process and ensures that you’ll be able to run the XWindow System at the best possible resolution with your computer’s video cardand monitor. Look at the Card Type field to see if your computer’s video card iscorrectly listed. Next, click the amount of video RAM installed on your video card(such as 2MB). Even if your video card is correctly listed, click the Probe button toget more accurate information. This runs the XF86_SVGA X11 server to probe yourgraphics card for setup information.2FIGURE 2.3OpenLinux shouldautomatically detectyour video card, butyou can click theProbe button to get amore specific setting.


28 Hour 211. After you click the Probe button, a dialog box appears, asking you to confirm theprobe. Click the Probe button to continue or the Abort button to cancel the probe.12. Your screen blanks and a dialog box with an OK button appears if the probe is successful.Click OK to close the dialog box, and then click Next to continue configuringthe X Window System.13. You now see a Select Monitor dialog box with a list of monitors and horizontal andvertical sync ranges, as shown in Figure 2.4. Scroll through the list of monitors,and click the model used with your system. If you do not see your monitor listed,enter your monitor’s name and sync ranges below the scrolling list. Click theMonitor name field, and then type a name. Enter the low and high horizontal syncranges by clicking on the up and down arrows, and then do the same for the lowand high vertical sync ranges. When you finish, click the Next button.FIGURE 2.4Scroll through the listof monitors and eitherpick a specific monitor,or type in detailsabout your computer’smonitor.Make sure to enter correct sync values for your monitor! You can possiblydamage your display with incorrect settings! You have been warned!14. The next dialog box asks for your preferred video mode, as shown in Figure 2.5.Click a desired resolution, such as 800×600, which represents the number of pixelsavailable across and down your display. Don’t choose a resolution outside of yourmonitor’s capabilities! Next, click a desired display depth from the list in theupper-right corner of your screen. When finished, click the Test This Mode buttonto test your settings.


Installing Linux 29FIGURE 2.5The Select Video Modedialog is used to pickthe best resolution andcolor depth for yourmonitor and graphicscard.215. A confirm dialog box appears. Click OK to continue. The screen clears, and a representativeX11 display appears for about 10 seconds, as shown in Figure 2.6.When the installation dialog box reappears, click the Next button to continue.FIGURE 2.6During your X11 configuration,OpenLinuxlets you test yourgraphics card andmonitor to make sureyour settings arecorrect.16. OpenLinux now asks you to set the root password. This is the password for thesystem administrator—you! Type in a password, then press Enter, and type it inagain. Don’t forget this password! You need this password to perform importantconfiguration tasks during your OpenLinux sessions. When you finish, click theNext button.


30 Hour 2Good passwords have a minimum of eight characters and contain a mix ofletters and numbers.17. The next dialog box asks you to add at least one new user to your OpenLinux system,as shown in Figure 2.7. Start by clicking the Real Name field, and enter yourname. Press Enter, and then type in a Login name. Press Enter, and then type in apassword. Press Enter, and then again enter the password. Next, click bash, tcsh,or zsh to select a Login Shell. When you finish, click the Add User button. Tocontinue, click the Next button.FIGURE 2.7The Set Login Name(s)dialog is used to createnew users duringyour OpenLinuxinstallation. (Otherusers may be addedor deleted afterinstallation.Login names are generally the first letter of a person’s name, followed bythe last name. For example, Julie Lewis would have a login name of jlewis,and Jeff Goldfarb would have a login name of jgoldfarb.18. You can now set up networking in the dialog shown in Figure 2.8. If your computeris attached to a network and you have a network card installed, enter the IPAddress (such as 192.168.1.2), Hostname (such as wishbone.erols.com),Netmask, and Gateway of your network. If your network has a Domain Nameserver, enter its IP address. If you don’t have a network card, click the Next buttonto continue.


Installing Linux 31FIGURE 2.8If you have a networkcard installed, use theSet Up Networkingdialog to enter networkinginformation,such as the InternetProtocol, or IP,address number ofyour computer.2If you skip this, you can always add and configure a networking card later.See Hour 3, “Post-Installation Issues,” for details.19. To make sure OpenLinux keeps accurate track of time, you’re now asked to selectyour time zone. Scroll through the list of zones, and then click your time zone. Ifyour computer’s hardware clock is set to local time, click the Hardware ClockRuns in Local Time item, and then click Next to continue.20. Now relax! It’s time to play a familiar game of falling blocks while OpenLinuxcontinues to copy files to your hard drive. Click New Game to start the action. Useyour cursor keys to rotate, shift, or drop the blocks into place. While you play, theprogress bar along the bottom of the screen helps you monitor the installation.When the install finishes, click the Finish button.Finishing Your Linux InstallationCongratulations! Hang in there because you’re almost finished installing OpenLinux!After you click Finish, OpenLinux reboots your computer to the K DesktopEnvironment’s K display manager login screen (as shown in Figure 2.9).


32 Hour 2FIGURE 2.9Your first peek atOpenLinux is at the Kdisplay manager,where you must log into Linux.Although you can log in now if you want to, there’s still an important step left in theinstallation! If you want to boot to Linux, you must first shut down, restart, and theninstall BootMagic from Windows.Experienced Linux users might want to use LILO, but should know that atthis point, unlike previous OpenLinux installs, LILO has been installed, andthe default /etc/lilo.conf configuration file is configured to start LILOfrom the root Linux partition. This might not be what you want, but it is theproper configuration to support commercial boot loaders such as SystemCommander or the included version of Boot Magic. Although experiencedLILO users might either use a boot floppy or install LILO in the Master BootRecord of the DOS partition, the MBR is needed by Boot Magic. At this pointyou have to decide if you want to use BootMagic or LILO. If you decide touse LILO, log in to OpenLinux as root, then edit /etc/lilo.conf to point tothe MBR, and insert an entry to support booting DOS. (One is not includedby default, and you might have noticed that the installation process doesnot offer you the opportunity to configure LILO.) If you decide to not useLILO by itself, BootMagic then uses LILO (installed on your Linux partition)to boot OpenLinux. For more information, see the file README under the/usr/doc/lilo directory.Click the Shutdown button, then select Shutdown, and restart to reboot to Windows.When the Windows desktop appears, click the Post Install Boot Magic menu item fromthe OpenLinux folder on the Start menu. Make sure your OpenLinux CD-ROM isinserted in your computer. The BootMagic setup window appears, as shown inFigure 2.10.


Installing Linux 33FIGURE 2.10To enable bootingDOS, Windows, orLinux, you must installa boot loader, such asBootMagic.2Follow the prompts to install BootMagic, entering your name and acknowledging thelicensing agreements. When prompted to create a BootMagic boot diskette, insert a blankfloppy in your computer, and follow the prompts. This is an important safety step thatenables you to recover and boot your computer in case your drive’s MBR becomescorrupted.You can also make a BootMagic boot diskette later by clicking the CreateBootMagic diskette icon in the BootMagic program folder on your Startmenu.BootMagic then installs on your computer, placing a boot loader in the MBR of yourhard drive. After the installation finishes, you see the BootMagic Configuration windowon your desktop, as shown in the Figure 2.11.FIGURE 2.11The BootMagicConfiguration windowis used to set thedefault operating system,reorder yourbooting list, or setstartup delays.


34 Hour 2BootMagic recognizes that you have created and installed a Linux partition on your harddrive. Click the Linux menu name, and then click the Reorder button to move Linux upin the list (where it rightfully belongs). Next, click the Set as Default button to makeLinux the default operating system to boot.BootMagic’s Startup Delay buttons and Timed delay field enable you to boot immediately,wait for a mouse click on an operating system name, or set a delay from 1 to 99seconds before booting. Make sure the BootMagic Enabled checkbox is checked. Whenyou finish configuring BootMagic, click the Save/Exit button to save your changes.To boot to Linux and log in, restart your computer. BootMagic then loads and displaysits boot menu, listing Linux and then Windows. Booting starts according to the delay youset in its configuration window. You then see Caldera’s customized LILO message screen(from the file message under the /boot directory), as shown in Figure 2.12.FIGURE 2.12BootMagic uses LILOto boot Linux.Type linux at the boot prompt to start your OpenLinux session. If you do nothing,OpenLinux boots after 50 seconds.The boot delay can be changed by editing the file /etc/lilo.conf andrerunning the lilo command.


Installing Linux 35Logging in to LinuxAfter OpenLinux boots, you again see the kdm client’s login screen. At the loginprompt, type root, and then press Enter. Then, enter the password you used during theinstall process.The screen clears, and you start your first OpenLinux session using the X WindowSystem with the K Desktop Manager (discussed in Hour 8, “Exploring the K DesktopEnvironment”), as shown in Figure 2.13.2FIGURE 2.13The first view of anOpenLinux X11 KDEsession.The main window on the desktop is the KDE configuration manager, which offers a onetimetime configuration of KDE themes, or how you want KDE’s windows, buttons, andcolors to appear. Click the Next button to continue to the themes setup, and you see aselection of themes, as shown in Figure 2.14.Click a theme icon (such as KDE, MacOS, Windows, or BeOS), and KDE automaticallysets the theme for your KDE sessions. Then, click on the Next button to proceed to thenext screen, as shown in Figure 2.15.


36 Hour 2FIGURE 2.14Select a window themefrom KDE’s configurationmenu by clickingon a theme icon.FIGURE 2.15KDE’s setup automaticallycreates convenientfloppy andCD-ROM icons onyour desktop.Click on each desired icon, and KDE puts each on your root desktop. These icons providean easy way to view the contents of a floppy disk or can be used as drag-and-dropicons for copying. For example, if you have a floppy inserted in your computer, you canlater drop a file onto the floppy icon to copy the file to diskette.


Installing Linux 37When you finish, click the Next button. The next screen asks if you want a printer icon.When you finish, click the Next button again to configure convenient hypertext links foryour desktop (as shown in Figure 2.16).FIGURE 2.16KDE creates Internetand hypertext links onyour desktop duringsetup.2After you finish, click the OK button. Your screen appears as shown in Figure 2.17(depending on the theme you chose during setup).FIGURE 2.17A KDE-themed KDEdesktop after configuration.


38 Hour 2Rebooting and Shutting DownAt this point, you can exit your first KDE session by clicking the small icon above thepadlock on the KDE panel (as shown in Figure 2.17) or by clicking the ApplicationStarter button (the large “K”) and clicking the logout menu item. KDE asks you to confirmthe logout. Click the logout button; the screen clears, and you again see the kdmlogin screen. To shut down and restart your computer, click the Shutdown button, selectShutdown or Shutdown and Restart, and then click OK. Your computer shuts down orreboots to BootMagic.Linux also offers a way to shut down or reboot from the command line of aterminal. After typing su and pressing enter to switch to superviser mode,use the shutdown command, along with its -r (reboot) option, followed bythe word now, like this:# shutdown -r nowAlternatively, you can use the number 0, like this:# shutdown -r 0This reboots your computer. Use the shutdown command along with its -h(halt) option, followed by the word now, like this:# shutdown -h nowAlternatively, you can use the number 0, like this:# shutdown -h 0This shuts down OpenLinux. When you see the message “System is halted.”you can turn off your computer.SummaryThis hour detailed a step-by-step simple OpenLinux installation session. InstallingOpenLinux is a major hurdle in using Linux but is usually an easy accomplishment.Although some computer users might be disconcerted by having to partition a hard driveto install a dual-boot computer, most find the process relatively painless. Welcome toLinux!


Installing Linux 39Q&AQ I screwed up my LILO installation! My system won’t boot to OpenLinux!A This is probably an error in the /etc/lilo.conf file. Use the OpenLinux bootdiskette to reboot your computer. At the command line, type linuxroot=/dev/your_hard_drive (such as /dev/hda1). See the BootPrompt-HOWTOunder the /usr/doc/HOWTO directory.Q What are some good documents to read about installing OpenLinux?A Although you can find many different documents installed under the/usr/doc/HOWTO or /usr/doc/HOWTO/mini directories, such as Linux+Win95,Loadlin+Win95, or the Linux Installation Guide, you should first read the technicaldocuments, FAQs, and errata at http://support.calderasystems.com/calderaor http://www.calderasystems.com/support/techguide.html.2Exercises1. Try rebooting your computer. Press the Tab key at the LILO boot prompt. Whathappens?2. At the LILO boot prompt, type vga=ask, and press Enter. What happens?3. After pressing Enter in the previous exercise and starting the boot process toOpenLinux, what happens next?


HOUR 3Post-Installation IssuesThis hour shows you how to configure OpenLinux to work with varioushardware and software components. You’ll learn how to disable or bypassX11 and the kdm graphical login, change the default color depth of yourX11 server, configure OpenLinux to use your sound card, set and configurean Ethernet network interface, enable PCMCIA card service, and use a Zipdrive.If you’ve partitioned your hard drive, installed OpenLinux, and have successfullylogged in and out of Linux, congratulations! Most of the hard workis done. This hour might help you finish your installation by showing youhow to configure different computer hardware to work with OpenLinux.


42 Hour 3All the configuration tasks described in this hour require you to be loggedin as the root operator. Make sure you proceed slowly, and always make abackup copy of important files before editing the original!The X Window SystemThe X Window System is the default graphical interface for Linux—but it is notOpenLinux. Originally developed by a consortium of computer companies and theMassachusetts Institute of Technology (MIT) , The X Window System, known as X11or X, is a network windowing system that runs along with Linux to provide graphicsservices . The main task in configuring X11 is to choose the correct X11 server (includedon your OpenLinux CD-ROM) and then to properly configure this server to work withyour computer’s graphics card.Configuring X11 is one of the major hurdles new OpenLinux users face when installingOpenLinux. X11 runs on many different types of computers and works with many differenttypes of graphics cards. You have a much better chance of configuring X11 to workwith your graphics hardware if you have a graphics card that’s been around in the marketfor at least two years. Having the latest and greatest graphics card lessens yourchances of being able to use X—although you can still use Linux.The version of X11 included on your OpenLinux CD-ROM comes from The Xfree86Project, Inc. , a group of programmers from around the world who have worked veryhard to provide a free graphical interface for Linux (and other operating systems , suchas BSD ). These folks deserve a big vote of thanks. To read more about The XFree86Project, browse to http://www.xfree86.org.How the X Window System is ConfiguredThis section introduces you to X11’s configuration file for OpenLinux: the XF86Configfile, found under the /etc directory. During your OpenLinux installation, X11 used agraphical interface by starting an X11 server named XF86_VGA16 . Hopefully, yourOpenLinux desktop now takes the best advantage of your computer’s monitor and graphicscard with a properly selected X server and configuration file. However, if you need toreconfigure X11 because you install a new graphics card or if X11 isn’t working to yoursatisfaction, you can reconfigure X11.


Post-Installation Issues 43The xf86config command configures X11 through a text-based interface . Before youbegin, take some time to read documentation under the /usr/X11R6/lib/X11/doc directory.This directory, summarized in Table 3.1, contains numerous documents with informationabout accelerated video graphics , different video monitors , various graphicschipsets , different video modes , and several helpful text files filled with tips on configuringX11.TABLE 3.1FileXFREE86 DOCUMENTATIONAccelCardsBUILDCOPYRIGHTDevicesMonitorsQuickStart.docREADMEREADME.ConfigREADME.DECtgaREADME.DGAREADME.LinkKitREADME.LinuxREADME.MGAREADME.Mach32README.Mach64DescriptionList of tested accelerated graphics cardsHow to compile the XFree86 X distribution from sourceCopyright statementOld file of contributed XF86Config Device sectionsOld file of contributed XF86Config Monitor sectionsQuick-start guide to setting up XFree86General information about the current XFree86 releaseDetailed, step-by-step guide to configuring XFree86Information for DEC 21030 usersHow to program for the XFree86 DGA interfaceSpecific information on how to build XFree86 from scratchGood information for Linux users about installing and usingXFree86Information about the Matrox Millennium & Mystique videocardsInformation about the Mach32 XFree86 X serverRelease notes about the Mach64 XFree86 X serverREADME.NVIDIA Notes for NVidia NV1, SGS-Thomson STG2000, and RIVA 128video cardsREADME.OakNotes for Oak Technologies Inc. chipset usersREADME.P9000Release notes for the P9000 XFree86 X serverREADME.S3Notes for S3 chipset usersREADME.S3VNotes for S3 ViRGE, ViRGE/DX, ViRGE/GX, ViRGE/MX, andViRGE/VX usersREADME.SiSNotes for Sis chipset usersREADME.Video7Readme file about Video7 drivers3continues


44 Hour 3TABLE 3.1 CONTINUEDFileREADME.W32README.WstDigREADME.agxREADME.apmREADME.arkREADME.atiREADME.chipsREADME.cirrusREADME.clkprogREADME.cyrixREADME.epsonREADME.mouseREADME.neoREADME.renditionREADME.tridentREADME.tsengRELNOTESServersOnlyVGADriver.DocVideoModes.docxinputDescriptionNotes for W32 and ET6000 chipset usersNotes for Western Digital chipset usersInformation about the AGX XFree86 X serverNotes about the Alliance Promotion chipsetNotes for ARK Logic chipset usersInformation about XFree86’s ATI Adapters video driversNotes about Chips and Technologies chipsetsInformation about XFree86 support for Cirrus Logic chipsetProgramming info about external video clock setting programsInformation about Cyrix chipsetsInformation about EPSON SPC8110 (laptop) chipsetsDetails about XFree86’s X11 mouse supportInformation about NeoMagic (laptop) chipsetsInformation about the Rendition chipsetNotes for Trident chipset usersNotes for Tseng chipset usersDefinitive release notes for XFree86How your directories should look when building XFree86 XserversHOWTO on adding an SVGA or VGA drive to XFree86Eric S. Raymond’s comprehensive treatise on buildingXF86Config modelinesGeneral info on input device (such as joystick) support inXFree86Before you use the xf86config command to reconfigure X11, log in as the root operator,and make a backup copy first, like so:# cp /etc/XF86Config /etc/XF86Config.orgYou can then start the command by typing it on the command line of a terminal windowlike this:# xf86config


Post-Installation Issues 45After you press Enter, follow the prompts to configure your graphics card and monitorfor X11. The xf86config command generates a new XF86Config file in the /etcdirectory.The XF86Config FileThe XF86Config file is used to properly feed font, keyboard, mouse, video chipset, monitorcapabilities, and color depth setting information to your selected X11 display server.XF86Config is a single text file that consists of several sections that are summarized inTable 3.2.You can page through your system’s XF86Config file by using the less command (discussedin Hour 4, “Reading and Navigation Commands”). At the command line of a terminal,use less, followed by the path to XF86Config, like this:# less /etc/XF86Config3You can then use the cursor keys to browse through the file. Press the Q key when youfinish reading.TABLE 3.2SectionMAJOR SECTIONS OF THE XF86Config FILEPurposeFilesTells the X server where colors, fonts, or specific software modules arelocatedModuleTells the X server what special modules should be loadedServerFlagsContains on/off flags to enable or deny special actions, such as coredumps , keyboard server shutdown , video-mode switching , video tuning, and mouse and keyboard configurationKeyboardTells the X server what keyboard to expect and what settings to usePointerTells the X server what pointer to use and how buttons are handledXinputSpecial section for devices, such as graphics pads , styli, and so onMonitorSpecifies details and settings for your monitor , such as name, horizontalsync ranges , vertical sync ranges , and modelines (one for each videoresolution , such as 640×480, 800×600, 1024×768, and so on)Device Provides details about your video chipset , such as RAM , clockchips ,and so onScreenSpecifies what X server to use, the color depth (such as 8-, 16-, 24-, or32-bits per pixel), screen size (such as 640×480, 800×600, 1024×768,and so on), and the size of the virtual screen


46 Hour 3Do not use an XF86Config from someone who does not have the samegraphics card and monitor as you! Incorrect settings can damage your monitor.Do not use monitor settings outside you monitor’s specifications . Youhave been warned! The only exception to this rule might be for PC notebookusers with exactly the same components.Before you try to start an X11 session using your new XF86Config settings , as the rootoperator , open the file in your favorite text editor , disable line wrapping , and check thesettings. It is essential, especially for laptop users , to do this to check the created settings,enable or disable some X server options , enter the correct amount of video memory, and fine-tune monitor settings.The XF86Config Files SectionThe Files section tells the X server the location of the color name database and systemfonts .The XF86Config ServerFlags SectionSeveral parts of this section can be used to configure special actions enabled by yourXFree86 X server . Enable a particular action by removing the pound sign (#) in front ofthe specific flag. Most users do not disable the DontZap feature because it provides aquick way to exit an X session . The DontZoom feature can be disabled if you use X inonly one video resolution , such as 800×600 pixels.The XF86Config Keyboard SectionThe Keyboard section tells the X server what type of keyboard to expect and settings touse, such as language type , key character layout , and manufacturer.The XF86Config Pointer SectionThe Pointer section tells the X server what pointer, or mouse, to use and how the buttonsare handled. Some Protocol settings are Auto for a serial mouse and BusMouse for abus mouse. The Device entry, /dev/mouse, is a symbolic link to the actual device (suchas /dev/ttys0 for a serial mouse).Two-button mouse users definitely want to enable the three-button emulator, in which simultaneously depressing both buttons simulates pressing themiddle button, or button 2. One common use of button 2 is to paste text orgraphics. For more information about configuring a mouse, see the fileREADME.mouse under the /usr/X11R6/lib/X11/doc directory.


Post-Installation Issues 47The XF86Config Monitor SectionAlthough the first several parts of the XF86Config file are easy to understand , if you’rean XFree86 user whose initial XF86Config file does not work, pay specific attention tothe Monitor section, the Device section, and the Screen section. The Monitor sectioncontains specific details and settings for your monitor, such as your monitor’s name, itshorizontal and vertical sync ranges, and critical modelines (one for each video resolution,such as 640×480, 800×600, 1024×768, and so on). Understanding the modeline is thekey to fine-tuning your X11 display.For the best details, see the files VideoModes.doc and README.Config underthe /usr/X11R6/lib/X11/doc directory before fine-tuning modeline s in yourXF86Config file. Another good tutorial is the XFree86-Video-Timings-HOWTO under the /usr/doc/HOWTO directory.3The basic parts of a modeline are 10 different values representing the following (fromleft to right):● A label of the screen resolution , such as 800×600●●●●●●●●●A video frequency in MHzThe number of visible dots per line on your displayThe Start Horizontal Retrace value (number of pulses before video sync pulsestarts)The End Horizontal Retrace value (end of sync pulse)The total number of visible and invisible dots on your displayThe Vertical Display End value , or number of visible lines of dots on your displayThe Start Vertical Retrace value (number of lines before the sync pulse starts)The End Vertical Retrace value (number of lines at the end of the sync pulse)The Vertical Total value , or total number of visible and invisible lines on your displayThe XF86Config Device SectionThe Device section contains details about your video chipset , such as RAM ,clockchips , and so on. Note that even though you tell xf86config or XF86Setup that youhave two megabytes of video RAM , these values are commented out with a pound sign(#). To properly configure for X, you need to remove the pound sign in front of theVideoRam setting in this part of the XF86Config file.


48 Hour 3This section of your XF86Config file is critical. The device definition is used totell the X server exactly what type of video chipset and options to support.For a list of device identifiers and options , see the README file under the/usr/X11R6/lib/X11/doc directory corresponding with your chipset.The XF86Config Screen SectionThe Screen section tells what X server to use , the color depth (such as 8-, 16-, 24- or32-bits per pixel), screen size (such as 640×480, 800×600, or 1024×768, and so on), andthe size of the virtual screen .This section contains directions for your chosen X server (the XF86_SVGA or other colorserver , the 4-bit, or 16-color XF86_VGA16 server , or the monochrome server ,XF86_Mono ) on what resolutions and virtual screen size to support.For example, if you’re using the 8-bit, or 256-color, mode of the XF86_SVGA server ,you might have the choice of a 640×480 display (with an 800×600 virtual screen ) or an800×600 display. Resolutions can be toggled during your X session by holding down theCtrl+Alt keys and depressing the plus (+) or minus (-) keys on your keypad. Laptopusers need to use the NumLock key before switching resolutions.Bypassing or Disabling the kdm Login DisplayThe default OpenLinux configuration uses X11 and the kdm client to provide a log-inscreen. However, you can bypass this screen and go directly to a log-in prompt for a textonlyconsole (without X11) by pressing Ctrl+Alt+F2. You then see a log-in prompt. Toreturn to the kdm login, press Alt+F1.Alt+F1 or Alt+F2 are known as virtual consoles. This means that with Linux, you canhave up to six different logins from the keyboard of the same computer at the same time.See Hour 7, “Using the X Window System,” for details about using virtual consoles andX11.If you don’t want Linux to start X11 or use the kdm graphical login display, you canconfigure OpenLinux not to use kdm after booting. First, log in as the root operator, andmake a copy of the file inittab under the /etc directory with the cp command like this:# cp /etc/inittab /etc/inittab.orgNext, use a favorite text editor (discussed in Hour 14, “Text Processing”), open the file,and look for the following line:id:5:initdefault


Post-Installation Issues 49Change the number 5 (which is the X11 runlevel) in the line to a 3 (which is the multiuserrunlevel without X), like this:id:3:initdefaultSave the file, then reboot your computer. After Linux reboots, wait until OpenLinux hasreported the booting progress, and then press Alt+F2. You see a log-in prompt.However, a much safer way to not use X11 is to tell OpenLinux to boot directly to multiusermode at the LILO boot prompt, like this:linux 3After you press Enter, OpenLinux boots without using X11 or kdm.Starting an X11 SessionIf you’ve configured OpenLinux not to use X11, you can start an X11 session by typingstartx at the command line after you log in. To start an X session using the K DesktopEnvironment , type kde at the command line. To start an X session using more than 256colors, use startx or kde , as in the following two examples (you can also try substituting24 or 32):3# startx -- -bpp 16# kde -- -bpp 16You can also change the default color depth used when you boot OpenLinux and startX11. Open your system’s XF86Config file, and look in the Screen section for the followingline:DefaultColorDepth 16This entry tells the default X server to use thousands of colors for the display. If youknow your computer can use millions of colors (from testing during your OpenLinuxinstall), change the setting to the following:DefaultColorDepth 32Save the file, and restart X11 from the command line or through the kdm Shutdown button.Your graphics card and monitor must be capable of supporting more than256 colors to use greater color depths, such as 16, 24, or 32. Incorrect settingswill result in the X server repeatedly trying to use bad settings and willmake logging into Linux nearly impossible. Test your graphics card and monitorwhen you install OpenLinux; you’ll then know what default settings youcan use.


50 Hour 3Configuring Sound for OpenLinuxConfiguring OpenLinux to use your computer’s sound system can be considered one ofthe last major hurdles in a successful Linux installation. Of course, if playing music,watching Internet TV, or participating in recreational death matches with Quake is importantto you, sound configuration is an important task.The good news is that over the last several years, Linux has evolved to make the job ofconfiguring sound a lot easier. In the past, configuring Linux to use sound involved apotentially frustrating cycle of configuring kernel source code, compiling, and testing.Today, however, the kernel uses loadable code modules to provide sound support foryour computer.Even better news is that most computers today follow common protocols when playingsound. You can easily configure OpenLinux to play sound through your computer’ssound card.Loading Sound ModulesOpenLinux comes with nearly 30 loadable code sound modules, found under the/lib/modules/2.2.3/sound directory, where 2.2.3 is the version of your OpenLinuxkernel (or the output of the uname command with the -r option). See the following example:# uname -r2.2.3# ls /lib/modules/2.2.3/soundaci.o gus.o opl3sa2.o soundlow.oad1816.o mad16.o pas2.o sscape.oad1848.o maui.o pss.o trix.oadlib_card.o mpu401.o sb.o uart401.oaedsp16.o msnd.o sgalaxy.o uart6850.oawe_wave.o msnd_classic.o softoss2.o v_midi.ocs4232.o msnd_pinnacle.o sonicvibes.o wavefront.oes1370.o opl3.o sound.oes1371.o opl3sa.o soundcore.oThese code modules support sound cards configured for a stock OpenLinux 2.2 kernel.You can read about the specific configuration of your kernel by looking at the WHATSIN-2.2.3-modular document (where 2.2.3 is the version of your Linux kernel) under the/boot directory. Table 3.3 lists just some of the cards (and compatibles) and modulessupported by OpenLinux.


Post-Installation Issues 51TABLE 3.3NameOPENLINUX 2.2 KERNEL MODULE SOUND SUPPORTCrystal CS4232 (PnP)Ensoniq ES1370Ensoniq ES1371Ensoniq SoundScapeGeneric OPL2/OPL3 FM synthesizerGravis UltrasoundMediaTrix AudioTrix ProMPU-401OPTi MAD16, MozartProAudioSpectrum 16PSS, ECHO-ADI2111Rockwell Wave Artist (Netwinder)SoftOSS software wave tableSound Blaster compatibles,Aztec Sound Galaxy,SB16/32/64/AWE, ESS, Jazz16Sound card supportTurtle Beach Wave Front, Maui, TropezYamaha OPL3-SA1Module(s)cs4232.o, ad1848.oes1370.oES1371.Osscape.oopl3.ogus.otrix.ompu401.omad16.opas2.opss.owaveartist.osoftoss2.osb.osound.o, sbcard.owavefront.o, maui.oopl3.o3Before you can begin, find and write down the I/O port addresses, IRQ, and DMA channelnumber for your computer’s sound system. You have this information if you followedthe recommendations in Hour 1, “Preparing to Install Linux.”If you performed a full installation of OpenLinux from the CD-ROM (whichincludes the source code for Linux), you can find an excellent tutorial, alongwith details about configuring OpenLinux to work with sound cards. Look atthe directory /usr/src/linux/Documentation/sound, and definitely read thefile README.modules. The /usr/src/linux/drivers/sound directory containsthe source code to the sound modules. Also read the Sound-HOWTO underthe /usr/doc/HOWTO directory.


52 Hour 3Log in as the root operator. At the command line of your console or an X11 terminalwindow, use the insmod command to load the sound kernel modules. This procedureshould work for most computers with SoundBlaster or equivalent cards. Type the following,and replace the io, irq, and dma values with those for your computer:# insmod sound# insmod uart401# insmod sb io=0x220 irq=5 dma=1You can then see if the sound modules were loaded with the lsmod command, like this:# lsmodModuleSize Used bysb 32660 1uart401 5936 1 [sb]sound 58584 0 (autoclean) [sb uart401]soundcore 2404 5 (autoclean) [sb sound]soundlow 300 0 (autoclean) [sound]...You can also try looking at the output of the /dev/sndstat device, like this (your outputmight look different):# cat /dev/sndstatOSS/Free:3.8s2++-971130Load type: Driver loaded as a moduleKernel: Linux noname.nodomain.nowhere 2.2.3 #1 Tue Mar 9 23:27:39 MST 1999i586Config options: 0Installed drivers:Card config:Audio devices:0: ESS ES1688 AudioDrive (rev 11) (3.1)Synth devices:Midi devices:Timers:0: System clockMixers:0: Sound Blaster


Post-Installation Issues 53Testing Your Sound ConfigurationTry to play a sound included in the KDE distribution. Use the play command to testyour sound card by playing ktalkd.wav (the sound of a phone ringing), like this:# play /opt/kde/share/sounds/ktalkd.wavIf your sound configuration does not work the first time, or if you enter an incorrect setting,use the rmmod command, followed by the name of the driver, to unload each soundmodule from system memory and try again. If the sound works, great!You can find numerous sound utilities for OpenLinux installed from this book’s CD-ROM. Some handy utilities include kmix for KDE and xmixer to control the balance andsource of your system’s sound.Configuring Sound with COASOpenLinux comes with a new utility, the Caldera Open Administration System, orCOAS, that you can use to administer and configure Linux. COAS can be used to controlmany different features of your OpenLinux system, including the following:3●●●●●●●●●●●●Ethernet interfaces, such as the Internet Protocol (IP) address of your computerFilesystems, such as mounting options for local or remote storage devicesHostname resolution, such as where your computer looks up the names andaddresses of other computersKernel module boot-time control to load or unload kernel modules, such as thosefor sound, from memory (more than 350 kernel modules are included withOpenLinux)Mail, such as setting how your email messages are sent or receivedNetwork services, such as the Network Information ServicePeripheral controls for configuring your keyboard, mouse, or printerSoftware management to control the types of software, such as scientific or textprocessing packages, installed on your computerSystem resource information to provide information about your computer’s CentralProcessing Unit (CPU)System services, such as what services to start when booting (for example, printing)Time, such as setting your system’s clock and timezone (useful when traveling)User management, such as adding, deleting, or renaming users and passwords


54 Hour 3COAS is a “work in progress.” This means that not all functions might beenabled with the version included on your CD-ROM. Checkhttp://www.calderasystems.com and browse through the news and supportareas for information about your version of OpenLinux.When you have sound working, start COAS by clicking the Application Starter button onyour K Desktop Environment’s panel; select COAS, and then click the Kernel menuitem, as shown in Figure 3.1.FIGURE 3.1The COAS client canbe used to configureOpenLinux kernelmodules.You see a short welcome dialog box. Click the OK button or press Enter to continue. Youthen see a dialog box, shown in Figure 3.2, with a list of currently loaded kernel moduleson the right, and available modules on the left.


Post-Installation Issues 55FIGURE 3.2Configure your system’skernel modulesby clicking the module’sname in the left(unloaded) or right(loaded) dialog boxlist.Using this previous example, scroll through the list of modules on the left, then select thesound module, and click the Load button. A dialog box appears, as shown in figure 3.3.FIGURE 3.3Configure how orwhen a kernel moduleis loaded with COAS.3Because no options are needed (for this example), make sure the Load at boot time buttonis enabled. Click the OK button. Next, scroll through the list of modules on the left,select the uart401 module, and click the Load button. Again, ensure loading at boottime, and click OK. To finish configuring for sound, scroll through the list of modules,and select the sb module. Click the Load button, and you see a dialog box similar to theone in Figure 3.4.


56 Hour 3FIGURE 3.4ConfigureSoundBlastercompatiblecard kernelmodules easily forLinux with COAS!Click in the I/O address, IRQ, and DMA fields, and enter your sound card’s addresses.Make sure boot-time loading is enabled, and click the OK button. The module loads(you might hear a slight “click”), and your card is configured! To exit COAS, click theOK button.A Quick Recording ScriptHere’s a short recording script you can use to record sound with a built-in or attachedmicrophone. The script works by using the dd command to save and convert a specifiedamount of data (in seconds) to your hard drive. Type the script in Listing 3.1 in a fileusing your favorite text editor:LISTING 3.1THE RECORDER SCRIPT#! /bin/sh# recorder – record sound to disk file# usage: recorder [n] soundfilenameecho -ne “recording “echo -ne $1echo -ne “ seconds of sound to “echo $2.au/bin/dd bs=8k count=$1 $2.auSave the file with a name, such as recorder, and then use the chmod command to makethe script executable, like this:# chmod +x recorder


Post-Installation Issues 57First, use kmix or xmixer to set your microphone’s input level. To record a sound, typerecorder, followed by a number in seconds, like this:# recorder 5 myfirstsoundThe script responds with the following:recording 5 seconds of sound to myfirstsound.au5+0 records in5+0 records outPlay the sound by sending it to your audio device, like this:# cat myfirstsound.au >/dev/audioConfiguring Sound the Easy WayOf course, there’s an even easier way to configure OpenLinux for sound. Browse tohttp://www.opensound.com/linux.html, and download a copy of the Open SoundSystem, or OSS. You can find links to detailed technical procedures for manual soundconfiguration, or you can use the commercial version of OSS, which supports more than200 sound cards (and which saves you a lot of time and effort).3OSS installs using a shell script. When you buy OSS online, you receive a license messageby email. You can also use a 30-day demonstration version to try out the software.If you’re having a hard time configuring sound on your system, give OSS a try!Enabling PCMCIA CardsIf you installed OpenLinux on your laptop, one of the first tasks you should perform isenabling your PC card slots. Nearly all laptops come with a Type III or Type II PC cardslot, which is typically used for a modem or Ethernet network card. However, there aremany different types of PC cards used for functions, such as the following:●●●●●●●●●●ATA/IDE card drives (Flash cards, interfaces)ATA/IDE CD-ROM interfacesEthernet interfaceEthernet/modem combination cardsFast Ethernet interfaceModemsSCSI interfacesSerial interfacesToken-ring interfaceWireless network interfaces


58 Hour 3You can find a list of more than 275 cards supported by David Hind’s PCMCIA CardServices package, which is a collection of kernel modules that automatically load andrecognize inserted PC cards during the boot process. Read the file SUPPORTED.CARDSunder the /usr/doc/pcmcia directory.Even if your card is not listed, it might work, especially if it is a modem card.Winmodem PC cards, such as several models in the MegaHertz line or fromother manufacturers, do not work under Linux. Do not purchase a winmodemmodem or PC card for Linux.Although the Card Services package is distributed only in source form through links athttp://hyper.stanford.edu/HyperNews/get/pcmcia/home.html or Linux downloadsites, such as ftp://metalab.unc.edu/pub/Linux/kernel/pcmcia, you can findinstalled binaries of the modules on your OpenLinux system under the /lib/modules/2.2.3/pcmcia directory. However, Caldera OpenLinux (and indeed, no otherdistribution) does not have a laptop option for enabling Card Services. You must manuallyconfigure OpenLinux for your laptop’s PC card controller.Make sure that Card Services is installed on your computer. If you do not seea /usr/doc/pcmcia-cs-3.0.9 directory on your system, chances are that CardServices is not installed. To install card services, insert your OpenLinux CD-ROM in your computer, and then mount the CD-ROM like this:# mount /mnt/cdromNext, use the rpm command to install the software like this:# rpm –i /mnt/cdrom/col/install/RPMS/pcmcia*.rpmThis installs the necessary software and documentation.To enable the Card Services package for PCMCIA support, use your favorite text editor,and open the file pcmcia under the /etc/sysconfig directory. It looks like this:PCMCIA=yesPCIC=PCIC_OPTS=CARDMGR_OPTS=”-f “


Post-Installation Issues 59If you want to disable Card Services, type the word no in the PCMCIA= line. However, inorder to use Card Services, you must enter the type of PCMCIA controller used for yourlaptop in the PCIC= entry. For many users the value i82365 or tcic works. Your entrymight look like this:PCMCIA=yesPCIC=i82365PCIC_OPTS=CARDMGR_OPTS=”-f “Save the file and exit your text editor. You can then reboot OpenLinux or start CardServices like this:# /etc/rc.d/init.d/pcmcia startStarting PCMCIA services: modules cardmgrCard Services starts and reports that cardmgr, the PCMCIA device manager, has beenactivated. This device manager monitors your PC card slots for card inserts or removals.If you have a modem card inserted, you should then be able to use the modem. Othercards, such as Ethernet interfaces, will be recognized but cannot be used until you properlyconfigure OpenLinux for networking.After starting Card Services, you can check its status in at least three ways. First, youcan use the dmesg command, like this:# dmesg…Linux PCMCIA Card Services 3.0.9kernel build: 2.2.3 #1 Tue Mar 9 05:22:33 MET 1999options: [pci] [cardbus]Intel PCIC probe:TI 1131 PCI-to-CardBus at bus 0 slot 10, mem 0x68000000,2 socketshost opts [0]: [ring] [pci + serial irq] [no pci irq][lat 168/176] [bus 32/34]host opts [1]: [ring] [pci + serial irq] [no pci irq][lat 168/176] [bus 35/37]ISA irqs (scanned) = 3,4,7,9 status change on irq 9cs: IO port probe 0x1000-0x17ff: clean.cs: IO port probe 0x0100-0x04ff: excluding 0x330-0x3370x378-0x37f 0x388-0x38f 0x408-0x40f 0x480-0x48f 0x4d0-0x4d7cs: IO port probe 0x0a00-0x0aff: clean.cs: memory probe 0xa0000000-0xa0ffffff: clean.eth0: NE2000 Compatible: port 0x300, irq 3, hw_addr 00:E0:98:04:AA:D5…3Not all the dmesg output is shown here, but you can see that the service has been loadedand that an Ethernet PC card was found by Card Services.


60 Hour 3Another way to check is to look at your OpenLinux system log, a file named messagesfound under the /var/log directory. Use the less pager, followed by the pathname tothe file, like this:# less /var/log/messages…Mar 23 22:20:32 noname kernel: Linux PCMCIA Card Services 3.0.9Mar 23 22:20:32 noname kernel: kernel build: 2.2.3 #1 Tue Mar 905:22:33 MET 1999Mar 23 22:20:32 noname kernel: options: [pci] [cardbus]Mar 23 22:20:32 noname kernel: Intel PCIC probe:Mar 23 22:20:32 noname kernel: TI 1131 PCI-to-CardBus at bus 0slot 10, mem 0x68000000, 2 socketsMar 23 22:20:32 noname kernel: host opts [0]: [ring] [pci +serial irq] [no pci irq] [lat 168/176] [bus 32/34]Mar 23 22:20:32 noname kernel: host opts [1]: [ring] [pci +serial irq] [no pci irq] [lat 168/176] [bus 35/37]Mar 23 22:20:32 noname kernel: ISA irqs (scanned) = 3,4,7,9 statuschange on irq 9Mar 23 22:20:32 noname cardmgr[991]: starting, version is 3.0.9Mar 23 22:20:32 noname cardmgr[991]: watching 2 socketsMar 23 22:20:32 noname kernel: cs: IO port probe 0x1000-0x17ff: clean.Mar 23 22:20:32 noname kernel: cs: IO port probe 0x0100-0x04ff: excluding0x330-0x337 0x378-0x37f 0x388-0x38f 0x408-0x40f 0x480-0x48f 0x4d0-0x4d7Mar 23 22:20:32 noname kernel: cs: IO port probe 0x0a00-0x0aff: clean.Mar 23 22:20:33 noname cardmgr[991]: initializing socket 0Mar 23 22:20:33 noname kernel: cs: memory probe 0xa0000000-0xa0ffffff:clean.Mar 23 22:20:33 noname cardmgr[991]: socket 0: Linksys EtherFast 10/100FastEthernetMar 23 22:20:33 noname cardmgr[991]: executing: ‘insmod/lib/modules/2.2.3/net/8390.o’Mar 23 22:20:33 noname cardmgr[991]: executing: ‘modprobe net/8390’Mar 23 22:20:33 noname cardmgr[991]: executing: ‘insmod/lib/modules/2.2.3/pcmcia/pcnet_cs.o’Mar 23 22:20:33 noname kernel: eth0: NE2000 Compatible: port 0x300, irq 3,hw_addr 00:E0:98:04:AA:D5Mar 23 22:20:33 noname cardmgr[991]: executing: ‘./network start eth0’Mar 23 22:20:33 noname cardmgr[991]: + eth0: configuration file not found.Mar 23 22:20:33 noname cardmgr[991]: start cmd exited with status 1Mar 23 22:20:33 noname cardmgr[991]: exiting…Not all the output is shown here, but you can see that additional information, such as themodel of your recognized card (in this case a Linksys EtherFast 10/100 card), is shown.Looking at your system’s log is also a good way to diagnose other problems.


Post-Installation Issues 61A third way to diagnose, check, or reset your PC cards, if you’re using X11, is withDavid Hind’s cardinfo client. Start cardinfo from the command line of a terminal windowlike this:# cardinfoAfter you press Enter, you see a window somewhat like that in Figure 3.5.FIGURE 3.5The cardinfo X11client can be used tomonitor, reset, suspend,eject, or insertPC cards withOpenLinux.3A small log window in the lower left of the cardinfo dialog box lists PC card events,such as insertion or removal. To control a card, press and hold down a card’s Socket button.You’ll see a small menu enabling you to reset, eject, or insert a card.Configuring Network Information with COASAlthough you were asked for network information during your OpenLinux installation,this is not your only opportunity to configure an interface. If you didn’t enter networkinformation during the installation, you don’t have to perform a re-install just to configurenetworking! Use the COAS utility to configure your interface’s address.Configuring Your Ethernet InterfaceTo configure your interface, click the Application Starter button in your KDE desktop,select COAS and then Network, and click on Ethernet Interfaces, as shown in Figure 3.6.


62 Hour 3FIGURE 3.6Use COAS to configureyour Ethernetadapter under the KDesktop Environment.You then see a welcome dialog box. Click the OK button (or press Enter) to continue.The Ethernet Interface Configuration dialog box appears, as shown in Figure 3.7.FIGURE 3.7The Ethernet InterfaceConfiguration dialogbox is used to set networkdevices, interfaceaddresses, and otherinformation.To configure your interface, click in the Interface address field, and enter your computer’sIP address (such as 192.168.1.20). When you finish, click the OK button. Thedialog box disappears. You can then check the status of your interface with the ifconfigcommand, like this:# ifconfiglo Link encap:Local Loopbackinet addr:127.0.0.1 Mask:255.0.0.0UP LOOPBACK RUNNING MTU:3924 Metric:1RX packets:56 errors:0 dropped:0 overruns:0 frame:0TX packets:56 errors:0 dropped:0 overruns:0 carrier:0collisions:0 txqueuelen:0


Post-Installation Issues 63eth0Link encap:Ethernet HWaddr 00:E0:98:04:AA:D5inet addr:192.1.2.34 Bcast:192.1.2.0 Mask:255.255.255.0UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1RX packets:5 errors:0 dropped:0 overruns:0 frame:0TX packets:5 errors:0 dropped:0 overruns:0 carrier:0collisions:0 txqueuelen:100Interrupt:3 Base address:0x300If you do not see an active local loopback (lo) interface, use the ifconfigcommand with the lo and up options like this:# ifconfig lo upAs you can see, you now have an active Ethernet interface (eth0) and address (in thiscase, 192.1.2.34). If you’re connected to a local network, use the ping command to tryto test your connection. Type ping on the command line of a terminal window, followedby the IP address of another computer, like this:3# ping 192.1.2.36PING 192.1.2.36 (192.1.2.36): 56 data bytes64 bytes from 192.1.2.36: icmp_seq=0 ttl=64 time=0.6 ms64 bytes from 192.1.2.36: icmp_seq=1 ttl=64 time=0.5 ms64 bytes from 192.1.2.36: icmp_seq=2 ttl=64 time=0.5 ms64 bytes from 192.1.2.36: icmp_seq=3 ttl=64 time=0.5 ms64 bytes from 192.1.2.36: icmp_seq=4 ttl=64 time=0.5 ms--- 192.1.2.36 ping statistics ---5 packets transmitted, 5 packets received, 0% packet lossround-trip min/avg/max = 0.5/0.5/0.6 msPress Ctrl+C to stop the ping command, which sends and records the time it takes (inthousandths of a second) for a “packet” of 64 characters to be sent and echoed back froma remote computer. The remote computer can be on a local network or halfway acrossthe world.


64 Hour 3SETTING THE HOSTNAMEIf you didn’t set the hostname for your computer during the OpenLinuxinstallation, you can add it later by using the Hostname menu item underthe COAS System menu, or editing the file network under the /etc/sysconfig directory. To manually change your hostname, use your favoritetext editor and open the sysconfig file (which should look like this):NETWORKING=”yes”HOSTNAME=noname.nodomain.nowhereChange the HOSTNAME entry to the hostname of your computer, save the file,and exit your editor. You can then verify your new hostname with the hostnamecommand.Using an Iomega Zip Drive with OpenLinuxThere are now at least three different Iomega parallel-port Zip drives available for Linux(not including internal IDE, USB, or SCSI drives): the original Zip drive, the Zip Plusdrive, and the new Zip 250.For the very latest development information about Linux and parallel-portdevices, such as the Zip drive, browse to http://www.torque.net/linux-pp.html.The following steps (tested with an original Zip drive) will enable you to mount and usea Zip disk:1. Turn on and connect your Zip drive to your computer’s parallel port.2. Insert a Zip disk into your Zip drive.3. Create the directory (such as /mnt/zip) where you’d like to access the contents ofyour Zip disk, like this:# mkdir /mnt/zip4. Use the insmod command to load kernel module support for the Zip drive, like this:# insmod scsi_mod# insmod sd_mod# insmod parport# insmod parport_pc# insmod ppa


Post-Installation Issues 65This loads SCSI support (the Zip drive uses a low-level SCSI protocol), support forsharing the parallel port, and support for the Zip drive. After you load the ppa module,you should hear your Zip drive activate. You can then use the mount command,along with a filesystem type, device name (/dev/sda), and mount point, like this:# mount –t vfat /dev/sda4 /mnt/zip5. To unmount the Zip disk, use the umount command, followed by the mount point,like this:# umount /mnt/zipUsers of the Iomega Zip Plus or Zip 250 drive will need to use the imm.omodule and will not be able to share the parallel port with a printer whenusing the Zip drive. If you use an original Zip parallel-port drive, you can usethe Zip disk and print at the same time.3After you’ve verified that your Zip drive works, you can then use the Kernel utility underCOAS to load your Zip drive’s modules when booting.SummaryThis hour provided a step-by-step approach to configuring X11 for your computer’svideo card and monitor. Use this hour as the starting point for fine-tuning your X11 configuration.Q&AQ Help! My XFree86 only gives me a resolution of 320 by 200!A It’s possible that you picked the wrong resolution during your OpenLinux installation.Make sure to test various X11 modes during the OpenLinux install to get thebest resolution possible with the most colors. You can also try reconfiguring X11with the xf86config command and start X11 again. Pay close attention to the valuesyou enter for your monitor’s horizontal and vertical frequencies, and don’t forgetto edit your XF86Config file’s Device section to set the correct amount of videoRAM. If you have one of the latest and greatest video cards, the card might not besupported by XFree86 just yet. Chances are also good that the next release ofXFree86’s X11 distribution will contain fixes for your graphics cards.


66 Hour 3Exercises1. Start the xvidtune client , and then use its controls to fine-tune your X11 settings .See if you can get a better image on your display.2. Try starting an X11 session at different color depths. Does your display look anydifferent?3. Try mounting, reading from, and writing to a Zip drive. Navigate tohttp://www.torque.net/.4. Scroll through your XF86Config file while reading the XF86Config man page.


PART IILearning Linux BasicsHour4 Reading and Navigation Commands5 Manipulation and Searching Commands6 Using the Shell7 Using the X Window System8 Exploring the K Desktop Environment


HOUR 4Reading and NavigationCommandsThis hour introduces you to the basic Linux commands used for navigating,searching, and reading files and directories of the file system, your Linuxpartition’s collection of directories. After working through the material,you’ll know how to get help on commands, find out where you are in Linux,and find files on your hard drive. The hour starts with navigating and searchingyour directory, and then moves on to show you how to read directoriesand files. But first, you’ll learn how to help yourself with the man command.Getting Help with the man CommandOne of the first things to know about Linux is that help is never far away.Like most implementations of UNIX, your Linux distribution comes withmanual pages for most programs, utilities, commands, and programmingsystem calls. You can get information about nearly any command, includingman. For example, read the manual page for the man command by typing thefollowing:# man man


70 Hour 4Manual pages started as one-page UNIX command summaries. The file for each manualpage is named with a single-digit extension and placed in a subdirectory under /usr/man.Manual pages for many OpenLinux commands are copied to your computer’s hard driveduring the initial installation process or when you later install an individual program. Forexample, the manual page for man is named and found as follows:/usr/man/man1/man.1.gzThe name of the manual page for the man command is man.1, but the extension.gz indicates that the man.1 file has been compressed with the gzipcommand. The man command automatically decompresses the file before displayingthe manual page. For more information about compressed files, seethe section “Compressing and Uncompressing Files” in Hour 5,“Manipulation and Searching Commands.”There are more than 1,000 manual page files under the /usr/man/man1 directory. But if,for example, you want to understand the format and placement of manual pages, youdon’t find this information in man.1 but in man.7 under /usr/man/man7. Look at Table4.1 to see the location and contents of each manual section.TABLE 4.1Directory/usr/man/man1/usr/man/man2/usr/man/man3/usr/man/man4/usr/man/man5/usr/man/man6/usr/man/man7/usr/man/man8/usr/man/man9THE LINUX MANUAL SECTIONSContentsCommands—Commands you run from within a shellSystem calls—Documentation for kernel functionsLibrary calls—Manual pages for libc functionsSpecial files—Information about files in the /dev directoryFile formats—Details of formats for /etc/passwd and other filesGamesMacro packages—Descriptions of the Linux file system, manualpages, and othersSystem management—Manual pages for root operator utilitiesKernel routines—Documentation on Linux kernel source routinesor kernel module specificationsEach manual page traditionally has a number of sections; the documentation for the commandalso breaks down into sections. Look at Table 4.2 for the organization of a manualpage.


Reading and Navigation Commands 71TABLE 4.2 ORGANIZATION OF A MANUAL PAGESectionDescriptionNameThe name of the command and a brief descriptionSynopsisHow to use the command and command-line optionsDescriptionAn explanation of the program and its optionsFilesA list of files used by the command and their locationSee alsoA list of related man pagesDiagnosticsA description of unusual outputBugsKnown problemsAuthorThe program’s main author and other contributorsOnline manual pages contain special typesetting codes for the nroff text formatting program,using special macros(as documented in man.7) that control how the manual page isdisplayed or printed. For more information on the nroff text formatting program, seeHour 15, “Preparing Documents.” The nroff format also is critically important for otherprograms, such as makewhatis, whatis, and apropos, which you’ll learn about later inthis chapter. These programs expect manual pages to have a consistent format so thatinformation can be properly displayed during search operations or properly stored whenbuilding an information database about your OpenLinux system’s programs.4You can also find more detailed documentation for Linux commands and other subjectsunder the /usr/doc directory, which contains files called Frequently Asked Questions, orFAQs, and How-To documents, or HOWTOs. Additionally, the Free SoftwareFoundation, which releases the GNU software packages, puts much of its documentationin a special hypertext info format. Many of the commands discussed in this book areGNU programs.Much of the software for Linux comes from the Free Software Foundation,founded by Richard Stallman, author of the emacs editor (see Hour 14, “TextProcessing”). The FSF distributes its software under the GNU General PublicLicense, or GPL. Part of the success and popularity of Linux and GNU softwareis because of the terms of the GPL. If you want more informationabout the GNU software programs for Linux, the FSF, or the GNU GPL, youcan try the info command, which is a reader for the GNU hypertext documentationfound under the /usr/info directory. You can also use the mancommand like so:man GPL


72 Hour 4The man command normally searches for manual pages according to instructions detailedin the man.conf file under the /etc directory. These instructions define the default directoriesin which to look for manual pages. The default places to look for these pages areas follows:MANPATH /usr/manMANPATH /usr/TeX/manMANPATH /usr/local/manMANPATH /usr/X11R6/manMANPATH /usr/openwin/manA graphic version of the man command, called xman, is available for the XWindow System. You can use xman not only to read manual pages, but alsoto see directories of manual page entries. If you use the K DesktopEnvironment with X11 (introduced in Hour 8, “Exploring the K DesktopEnvironment”), you find that KDE manual pages are in Hypertext MarkupLanguage, or HTML format.Navigating and Searching the File SystemThis section introduces you to the basic navigational commands and shows you how tomove around your Linux file system, find files, and build file information databases,such as those for use with the whatis command. You’ll learn about alternativeapproaches and programs and how to speed up searches to find files quickly.Moving to Different Directories with the cd CommandThe cd (change directory) command is the basic navigation tool for moving todifferent parts of the Linux file system. After you log in to OpenLinux, you arein your home directory. This directory has a name, or pathname, beginning with /home/followed by your username.NEW TERMYou can move directly to a different directory by typing the command followed by apathname. For example, the following command moves you to the /usr/bin directory:# cd /usr/binWhen you’re in that directory, you can move up to the /usr directory with the followingcommand:# cd ..


Reading and Navigation Commands 73You can also move to the root directory, or /, while in the /usr/bin directory by usingthe following command:# cd ../..Finally, you can always go back to your home directory (where your files are) by usingthe command# cdor# cd ~If you try to use the man command to read the cd man page, you won’t findone. Why? Because cd is built into the shell, which interprets your commandline after you press Enter. See bash in Hour 6, “Using the Shell,” for moredetails.Knowing Where You Are with the pwd CommandThe pwd (print working directory) command tells you where you are and prints the working(current) directory. For example, if you execute4# cd /usr/binand then type# pwdyou see/usr/binAlthough there’s a man page for the pwd command, chances are that when you use pwd,you’re using a pwd built into your shell. How do you tell? If you try calling pwd with thefollowing command, you see only the current working directory printed:# pwd --helpInstead, try using the pwd command in the /bin directory as follows:# /bin/pwd --help


74 Hour 4This runs the pwd command in the /bin directory and not the pwd built into your shell.You see a short help file for the pwd command and not the current directory. If you’reever in doubt about where you are, use the pwd command under the /bin directory.Searching Directories for Matching Files with the findCommandThe find command is a powerful searching utility you can use to find files on your harddrive. You can search your hard drive for files easily with a simple find command line.For example, to search for the spell command under the /usr directory, you use thefollowing:# find /usr -name spell -printYou can use the find command to find files by date, and you can also specify a range oftimes. For example, to find programs in the /usr/bin directory that you have not used inthe last 100 days, you can try the following:# find /usr/bin -type f -atime +100 -printThe -atime option is followed by a number representing days. To find any files, eithernew or modified, that are one or fewer days old in the /usr/bin directory, you can usethe following option:# find /usr/bin -type f -mtime -1 -printThe -mtime option, followed by a number in days (in this case one or less), looks formodified files. The find command also accepts wildcards (such as * or ?) in searchstrings, which you’ll learn about in Hour 5. As a simple example, you can use find toshow you all the PostScript files in your /usr directory with the following:# find /usr -name ‘*.ps’ -printThe section “Understanding Graphics Formats” in Hour 16, “Graphics Tools,” coversPostScript files.-xdev is one of the find command’s handy options. The examples so far show searcheslimited to the /usr directory. But what if you want to search starting at the root (/)directory? -xdev limits searches to the current file system, which in this case is Linux.Without it, find merrily continues its search through any mounted CD-ROMs or yourDOS or Windows partition, possibly finding files you’re not interested in, slowing downthe search, and cluttering up the search printout.


Reading and Navigation Commands 75For example, you can use the -xdev option to limit your find command search to aWindows partition. To find all files ending in .sys on a mounted Windows partitionunder the /mnt/dos directory, use the -xdev option like this:# find /mnt/dos -name *.sys -print -xdevThe find command has many different options and uses.You can also send the find command on search-and-destroy missions todelete selected files from your computer. See “Saving Disk Space” inHour 21, “Basic System Administration,” for details.Although find rapidly searches your hard drive and file systems, there are other ways ofquickly finding files, especially programs. Read on to find out more!Finding Files with the whereis CommandThe whereis command can quickly find files, and it shows you where the file’s binary,source, and manual pages reside. For example, the following command shows that thefind command is in the /usr/bin directory, and its man page is in the /usr/man/man1directory:4# whereis findfind: /usr/bin/find /usr/man/man1/find.1.gzYou can also use whereis to find only the binary version of the program with the following:# whereis -b findfind: /usr/bin/findThis is handy if you only want to see where a program is located and not its documentation.If whereis cannot find your request, you get an empty return string, for example:# whereis foofoo:Part of the problem could also be that the file is not in any of the directories the whereiscommand searches. The directories whereis looks in are hard-coded into the program.Although this might seem like a drawback, limiting searches to known directories suchas /usr/man, /usr/bin, or /usr/sbin can speed up the task of finding files.Although whereis is faster than using find to locate programs or manual pages, there’san even faster search utility you can use, called locate, discussed in the next section.


76 Hour 4Locating Files with the locate CommandOne way to speed up searches for files is not to search your file directories! You can dothis by using a program like locate. locate uses a single database of filenames andlocations and saves time by looking in a single file instead of traversing your hard drive.Finding a file using locate is much faster than the find command because locate goesdirectly to the database file, finds any matching filenames, and displays its results.Locate is easy to use. For example, to find all the PostScript files on your system, youcan enter the following:# locate *.psAlmost instantly, the files appear on your screen. You might even find the locate commandline a little easier to use than the find command. However, there is a catch: findworks “right out of the box,” whereas locate requires a database of all the files on yoursystem. But don’t worry—the procedure is almost automatic.After you install OpenLinux, the locate database is updated every day at 5:50 a.m.To create an updated version of the locate database right away, you need to use theupdatedb command. Make sure that you’re logged in as the root operator, or use thesu command (see Hour 21). At the prompt, enter the following:# updatedbIt might take a minute or so for the updatedb command to finish its work, but when it’sdone, the database for locate, locatedb, resides in the /var/state directory. locatedbis about 700,000 characters in size for 900MB worth of files. The only downside to usingthe locate command is that over time, its database can become outdated as you add ordelete files to your system. Fortunately, OpenLinux automatically updates the locatedatabase; to find out how, see Hour 24, “Scheduling,” for details.Getting Command Summaries with whatisand aproposAs you first explore your OpenLinux system, you might come across programs whosefunction is not clear. Many Linux programs are designed to give at least a little help witha ?, -help or --help option on the command line, but you generally shouldn’t run a programwithout knowing what it does.


Reading and Navigation Commands 77The whatis command might be able to help you quickly find out what a program is witha summary line derived from the program’s manual page. For example, to find out whatis who, you can enter the following:# whatis whoYour screen clears, and the whatis command displays a summary like so:who (1)- show who is logged onPress Q to quit the whatis command. However, unlike the locate command, you mustfirst build a database of the command summaries with the makewhatis command, whichis found under the /usr/sbin directory. To do this, make sure you’re logged in as root,and enter the following:# makewhatisThe makewhatis command, like the updatedb command, takes a few minutes to build thewhatis database, which is called whatis and is found under the /usr/man/man1 directory.The makewhatis command has several options but does not have a manual page. Tosee a quick summary, use the following:# makewhatis -?You need to periodically update the whatis database to keep track of any newly installedprograms. See Hour 24 for tips on how to make OpenLinux do this automatically.Now you see how whereis and whatis can help you find programs or figure out whatthey do. But what if you want to do something but can’t remember which program doeswhat? In this case, you can turn to the apropos command.For example, if you can’t remember which command searches for files, you can enter thefollowing:# apropos searchapropos (1)- search the whatis database for stringsbadblocks (8) - search a device for bad blocksbsearch (3)- binary search of a sorted array.conflict (8)- search for alias/password conflictsfind (1)- search for files in a directory hierarchyhcreate, hdestroy, hsearch (3) - hash table managementlfind, lsearch (3) - linear search of an array.lkbib (1)- search bibliographic databaseslookbib (1)- search bibliographic databaseslsearch (n)- See if a list contains a particular elementmanpath (1)- determine user’s search path for man pagesstrpbrk (3)- search a string for any of a set of charactersstrspn, strcspn (3) - search a string for a set of characterstsearch, tfind, tdelete, twalk (3) - manage a binary tree4


78 Hour 4whatis (1)- search the whatis database for complete words.zgrep (1)- search possibly compressed files for➥ a regular expressionzipgrep (1)- search possibly zip files for➥ a regular expressionYou see a list of programs from the whatis database on your screen. Press the Q keywhen you finish reading the list. The apropos command uses this database to search forthe keyword you entered. If you keep your whatis database up-to-date, you’re able touse apropos to help you find the program you need.You can also use the man command’s -K option to do the same thing asapropos, but the search is slow and presents each manual page in the searchresult. For example, to search for any programs dealing with PostScript, youcan try the following:# man -K PostScriptThis can result in the following output, before you quit with Q:/usr/man/man7/unicode.7? [ynq] n/usr/man/man7/suffixes.7? [ynq] n/usr/man/man7/groff_char.7? [ynq] n/usr/man/man1/convert.1x? [ynq] n/usr/man/man1/xv.1? [ynq] n/usr/man/man1/xdvi.1? [ynq] n/usr/man/man1/dvips.1? [ynq] n/usr/man/man1/afm2tfm.1? [ynq] n/usr/man/man1/ps2pk.1? [ynq] n/usr/man/man1/ps2frag.1? [ynq] qReading Directories and FilesNow that you know about directory navigation, searching for files, and how to find moreinformation about programs, I’ll introduce you to other basic Linux commands you canuse. This section shows you how to list the contents of directories, make a catalog ofyour hard drive, and read the contents of files. You’ll learn the basic forms of thesecommands to help get you started.Listing Directories with the ls CommandThe ls (list directory) command is one of the most often used programs. In its simplestform, ls lists nearly all the files in the current directory. But this command, which hassuch a short name, probably has more command-line options (more than 75 at last count)than any other program!


Reading and Navigation Commands 79Why are there so many Linux commands, and why do they have such shortnames? If you’re not familiar with Linux, you’ll soon find hundreds of programswith short, initially cryptic names like cd, pwd, df, du, ps, ls, as, ar, at,w, and so on. Don’t be intimidated! Instead, be thankful that Linux hasinherited this rich assortment of traditional UNIX tools. The UNIX philosophyis that a good program is small and does one thing very well; the power ofthe operating system comes from combining the output of several programsin concert. Many of the command names were chosen to save typing. Whyenter a long program name when one or two letters suffice? Also, manyearly UNIX users communicated with remote UNIX computers over very slow(110-baud) terminal lines, and short, precise commands were transmitted alot faster. To better appreciate the short command names, read Hour 6.In the simple form, ls lists the files in the current directory as in the following example:[home/bball]$ lsNews axhome nsmail searchauthor.msg documents reading vultures.msgauto mail researchThe example lists files in my home directory.You can also list the files as a single line, with comma separations, using the -m option:# ls -mNews, author.msg, auto, axhome, documents, mail, nsmail, reading,➥ research, search, vultures.msg4If you don’t like this type of with the ls Commandlisting, you can have your files sortedhorizontally, instead of vertically (the default) with the -x option, as follows:# ls -xNews author.msg auto axhome documentsmail nsmail reading research searchvultures.msgAre all these just files, or are there several directories? One way to find out is to use the-F option:# ls -FNews/ axhome/ nsmail/ search*author.msg documents/ reading/ vultures.msgauto/ mail/ research/As you can see, the -F option causes the ls command to show the directories, each witha / character appended to the filename. The asterisk (*) shows that the file search is anexecutable program. But are these all the files in this directory? If you want to see everything,you can use the -a option with -F, as follows:


80 Hour 4# ls -aF./ .dt/ .neditdb auto/../ .dtprofile* .netscape/ axhome/.Xauthority .festival_history .newsrc documents/.Xdefaults .forward .oldnewsrc mail/.addressbook .fvwm2rc95* .pinerc nsmail/.addressbook.lu .index/ .procmail/ reading/.bash_history .mailcap .procmailrc research/.bash_logout .mailrc .tin/ search*.bash_profile .mime.types .xinitrc* vultures.msg.bashrc .ncftp/ News/.desksetdefaults .nedit author.msgAs you can see, files or directories whose names begin with a period (.) are not displayedby ls unless you explicitly request all files. Using the -F option is one way to seethe files and directories in your listings, but if you have a color monitor or use X11 incolor, you can tell ls to show files, directories, or executable files in different colors. Todo this, use the --color option like this:# ls --colorIn X11, using the xterm terminal, directories are blue, programs are green, and regularfiles are black. You can also customize which colors are used for different types of files.For example, to have all graphics files, such as PCX or GIF graphics, appear in red andall text files ending in .txt appear in purple, create a shell environment variable, orsystem- or user-defined value, named LS_COLORS, define the colors, and export the variablelike this:# LS_COLORS=”*pcx=31:*gif=31:*txt=35”;export LS_COLORSThe ls man page lists the default colors. You can put your custom definitionin your .bashrc file for use the next time you log in to OpenLinux. As theroot operator, you can also specify systemwide default colors for all users.See Hour 6 to see how to define LS_COLORS and other environment variablesfor use by all users on your OpenLinux system.Long Directory ListingWould you like even more information about your files? You can use the long format listingby using the ls -l option, for example:# ls -ltotal 2086-rw-r--r-- 1 bball users 256302 Dec 30 15:42 162317art.zipdrwx------ 6 bball users 1024 Dec 17 22:35 Desktopdrwxr-xr-x 24 bball users 1024 Dec 2 15:09 Office40


Reading and Navigation Commands 81drwxr-xr-x 22 bball users 1024 Dec 2 11:23 Office50-rw-r--r-- 1 bball users 29360 Dec 30 14:38 Sheet.as-rw-r--r-- 1 bball users 705 Dec 30 15:15 Sheet.wk3-rw-r--r-- 1 bball users 2360 Dec 30 15:15 Sheet.xl4-rw-r--r-- 1 bball users 5632 Dec 30 15:20 Sheet.xl5-rw-r--r-- 1 bball users 2958 Dec 17 20:37 XWpdrwxr-xr-x 5 bball users 1024 Mar 24 1998 aimdrwxr-xr-x 4 bball users 1024 Dec 30 15:15 axhomedrwxr-xr-x 2 bball users 1024 Dec 23 23:15 documentsdrwxr-xr-x 2 bball users 1024 Dec 11 11:06 graphicsdrwxr-xr-x 6 bball users 1024 Dec 1 11:19 lgdrwxrwxrwt 2 bball users 1024 Dec 9 16:34 maildrwx------ 2 bball users 1024 Nov 8 10:56 nsmaildrwxr-xr-x 3 bball users 1024 Nov 10 16:22 rvplayer5.0drwxr-xr-x 5 bball users 1024 Nov 4 10:49 so50drwxr-xr-x 2 bball users 3072 Dec 30 15:43 tyl2-rwxr-xr-x 1 bball users 12004 Dec 30 12:37 worth.as-rw-r--r-- 1 bball users 1533 Dec 30 13:09 worth.csv-rw-r--r-- 1 bball users 227985 Dec 30 13:08 worth.dif-rw-r--r-- 1 bball users 4905 Dec 30 13:12 worth.sc-rw-r--r-- 1 bball users 6110 Dec 30 13:09 worth.slk-rw-r--r-- 1 bball users 1533 Dec 30 13:09 worth.txtAs you can see, there are eight different columns. The first column is the file’s permissionflags, which are covered in Hour 22, “Handling Files and Your File System.” Theseflags generally show the file’s type, and who can read, write (modify or delete), or runthe file.4The next column shows the number of links, which are discussed in Hour 5. Next is theowner name, followed by the group name. Owners and groups are discussed in Hour 22.The file size is listed next, followed by a timestamp stating when the file or directorywas created or last modified. The last column, obviously, is each file’s name.Specifying Other DirectoriesYou can also use the ls command to view the contents of other directories by specifyingthe directory or pathname on the command line. For example, if you want to see allthe files in the /usr/bin directory (you’ll probably see a lot more than these), use thefollowing:# ls /usr/binarch dd gzip netstat sttyash df hostname nisdomainname suawk dmesg kill ping syncbasename dnsdomainname ksh ps tarbash doexec ln pwd tcshbsh domainname login red touchcat echo ls rm truechgrp ed mail rmdir umountchmod egrep mkdir rpm uname


82 Hour 4chown false mknod sed ypdomainnamecp fgrep more setserial zcatcpio gawk mount shcsh grep mt sleepdate gunzip mv sortRegular expressions are a language of special string specification patterns. Thels command supports using wildcards and regular expressions, which means youcan use options similar to and much more complex than the examples you saw with thefind and locate commands. For example, if you only want to search for text files in thecurrent directory, you can use the following:NEW TERM# ls *.txtFinally, if you want to see all the files on your system, you can use the ls -R option,which recursively descends directories to show you their contents. Although you can usethis approach to search for files and build a catalog of the files on your system, bewarned that it might take several minutes to list your files. The listing might also includefiles you don’t want listed or files on other operating system file systems, such as DOSor Windows, especially if you use the following:# ls -R /A better approach might be to use the -d option with -R to list only a certain number ofdirectory levels. For example, the following command searches three directory levelsalong the root (/) directory:# ls -Rd /*/*/*However, there’s a much better utility for getting a picture of the directory structure ofyour system—tree—which is discussed in the following section.Do you like how ls -aF shows your directories? Do you prefer ls to use colorsall the time? If you want the ls command to always show this sort ofdetail, see Hour 6.Listing Directories with the dir and vdir CommandsIf you just can’t get the hang of using ls to list your directories, you can use the dir orvdir commands. These commands have only about 45 command-line options comparedto ls, but they’re just as capable. They work like ls but with certain defaults.


Reading and Navigation Commands 83The dir command works like the default ls command, listing the files in sorted columnsas in the following example:# dir01_hyph.dat 49_thes.dat bin help store01_spell.dat Desktop config install.ini template01_thes.dat LICENSE database instdb.ins wordbook44_hyph.dat README download kino xp344_spell.dat addin explorer l_soffice.xpm44_thes.dat autotext filter lib49_hyph.dat backup fonts s_soffice.xpm49_spell.dat basic gallery sofficercThe vdir command works like the ls -l option and presents a long format listing bydefault as follows:# vdirtotal 3659-rw-rw-rw- 1 bball users 65605 Oct 27 10:00 01_hyph.dat-rw-rw-rw- 1 bball users 313015 Oct 27 10:00 01_spell.dat-rw-rw-rw- 1 bball users 375808 Oct 27 10:00 01_thes.dat-rw-r--r-- 1 bball users 65605 Oct 27 10:00 44_hyph.dat-rw-r--r-- 1 bball users 313015 Oct 27 10:00 44_spell.dat-rw-r--r-- 1 bball users 380928 Oct 27 10:00 44_thes.dat-rw-rw-rw- 1 bball users 51765 Oct 27 10:00 49_hyph.dat-rw-rw-rw- 1 bball users 602497 Oct 27 10:00 49_spell.dat-rw-rw-rw- 1 bball users 1191936 Oct 27 10:00 49_thes.datdrwxr-xr-x 2 bball users 1024 Dec 2 11:21 Desktop-rw-r--r-- 1 bball users 11631 Oct 27 10:00 LICENSE-rw-r--r-- 1 bball users 8435 Oct 27 10:00 READMEdrwxr-xr-x 3 bball users 1024 Dec 2 11:21 addindrwxr-xr-x 2 bball users 1024 Dec 2 11:21 autotextdrwxr-xr-x 2 bball users 1024 Dec 30 15:41 backupdrwxr-xr-x 2 bball users 1024 Dec 17 11:43 basicdrwxr-xr-x 2 bball users 2048 Dec 2 11:22 bindrwxr-xr-x 11 bball users 3072 Jan 4 09:52 configdrwxr-xr-x 2 bball users 1024 Dec 2 11:30 databasedrwxr-xr-x 2 bball users 1024 Dec 2 11:20 downloaddrwxr-xr-x 5 bball users 1024 Dec 2 11:28 explorerdrwxr-xr-x 2 bball users 1024 Dec 2 11:22 filterdrwxr-xr-x 4 bball users 1024 Dec 2 11:20 fontsdrwxr-xr-x 14 bball users 2048 Dec 2 11:22 gallerydrwxr-xr-x 4 bball users 1024 Dec 2 11:21 help-rwxr-xr-x 1 bball users 15569 Dec 2 11:22 install.ini-rw-r--r-- 1 bball users 274209 Dec 17 11:20 instdb.insdrwxr-xr-x 2 bball users 1024 Dec 2 11:21 kino-rw-r--r-- 1 bball users 5199 Oct 27 10:00 l_soffice.xpmdrwxr-xr-x 2 bball users 3072 Dec 2 11:21 lib-rw-r--r-- 1 bball users 812 Oct 27 10:00 s_soffice.xpm-rwxr-xr-x 1 bball users 8406 Jan 4 09:52 sofficercdrwxr-xr-x 3 bball users 1024 Dec 2 11:38 store4


84 Hour 4drwxr-xr-x 13 bball users 1024 Dec 17 11:43 templatedrwxr-xr-x 2 bball users 1024 Dec 2 12:08 wordbookdrwxr-xr-x 5 bball users 1024 Dec 2 11:20 xp3Although you don’t find separate manual pages for dir or vdir (they’re mentioned in thels man page), you can get help with each command by using the --help option.Listing and Combining Files with the cat CommandThe cat (concatenate file) command is used to send the contents of files to yourscreen. You can also use this command to send files’ contents into other files,too, using a process called output redirection. This section shows you some basic usesfor this command. See Hour 6 for more about standard input, standard output, and redirection.Although cat can be useful for reading short files, it is usually used either tocombine, create, overwrite, or append files. To use cat to look at a short file, you canenter the following:NEW TERM# cat test.txtThis text file was created by the cat command.Cat could be the world’s simplest text editor.If you read this book, you’ll learn how to use cat.This is the last line of text in this file.The cat command also has a number of options. If you’d like to see your file with linenumbers, perhaps to note a specific phrase, you can use the -n option:# cat -n test.txt1 This text file was created by the cat command.2 Cat could be the world’s simplest text editor.3 If you read this book, you’ll learn how to use cat.4 This is the last line of text in this file.You can also use cat to look at several files at once because cat accepts wildcards:# cat -n test*1 This text file was created by the cat command.2 Cat could be the world’s simplest text editor.3 If you read this book, you’ll learn how to use cat.4 This is the last line of text in this file.5 This is the first line of test2.txt.6 This file was also created by cat.7 This is the last line of test2.txt.As you can see, cat also includes a second file in its output and numbers each line of theoutput, not each file. Note that you can also see both files with the following:# cat test.txt test2.txtThe output is exactly the same as if you used a wildcard.


Reading and Navigation Commands 85But looking at several files is only one way to use cat. You can also use the cat commandwith the redirection operator (>) to combine files. For example, if you want tocombine test.txt and test2.txt into a third file called test3.txt, you can use thefollowing:# cat test* > test3.txtYou can check the result as follows:# ls -l test*-rw-r--r-- 1 bball users 190 Jan 4 16:06 test.txt-rw-r--r-- 1 bball users 108 Jan 4 16:07 test2.txt-rw-r--r-- 1 bball users 298 Jan 4 16:07 test3.txtBut what if you want to combine test.txt and test2.txt without creating a larger,third file? In this case, you first decide whether you want the contents of test.txt to gointo test2.txt or the contents of test2.txt to go into test.txt. Then, using cat withthe >> redirection operator, you type the following:# cat test.txt >> test2.txtThis appends the contents of test.txt to the end of the test2.txt. To check theresults, use cat again:# cat test2.txtThis is the first line of test2.txt.This file was also created by cat.This is the last line of test2.txt.This text file was created by the cat command.Cat could be the world’s simplest text editor.If you read this book, you’ll learn how to use cat.This is the last line of text in this file.4Note that you can instead enter the command as follows:# cat -n test.txt >> test2.txtNow the test2.txt file looks like this:# cat test2.txtThis is the first line of test2.txt.This file was also created by cat.This is the last line of test2.txt.1 This text file was created by the cat command.2 Cat could be the world’s simplest text editor.3 If you read this book, you’ll learn how to use cat.4 This is the last line of text in this file.


86 Hour 4Finally, here’s a trick you can use if you want to create a short text file without running aword processor or text editor. Because the cat command can read the standard input, youcan make the cat command create a file and fill it with your keystrokes. To do so, firsttype the following, using myfile.txt as the example file:# cat > myfile.txtNow enter some text, such as the following:This is the cat word processor.This is the end of the file.Now press Ctrl+D to close the file. To see if this works, try the following:# ls -l myfile.txt-rw-r--r-- 1 bball users 61 Jan 4 16:11 myfile.txt# cat myfile.txtThis is the cat word processor.This is the end of the file.The cat command prints out the contents of any file, not just text files. Although cat canbe useful to look at one or several short files, what do you do when you want to readlonger text files? Read on and learn about pager commands, which make life easier whenreading longer files.Reading Files with the more CommandThe more command is one of a family of Linux commands called pagers. Pagercommands let you browse through files, reading a screen or line at a time. Thiscan be extremely helpful, especially if you read a lot of manual pages, because the mancommand uses a pager to display each page.NEW TERMThe more command is a traditional pager in the sense that it provides the basic featuresof early pagers. You can use more on the command line as follows:# more longfile.txtIf you need help, you can press the H key to see a help screen. You can also run othercommands from inside more by using the exclamation character (!). Reading through atext file is easy because you can advance one screen by pressing the Spacebar and gobackward one screen by pressing the B key.The more command also has a number of command-line options. You can customize thescreen prompt (more displays the current percentage of the file you’re reading), set thescreen size (the number of lines shown when going forward or backward through yourfile), use multiple filenames or wildcards, and turn scrolling on or off, in addition toother options.


Reading and Navigation Commands 87Although you might find the more command to be more than adequate in reading files,you might really like the less pager.Browsing Files with the less Commandless is more or less like more, but less is also much more than more. Confused? Don’tbe, because less, like more, is also a pager command. Its author, Mark Nudelman,improved on a number of features in the more command and added many others.The less command offers a number of advantages over more:●●●●●●●You can scroll backwards and forwards through text files using your cursor keys.You can navigate through files with bookmarks by line numbers or by percentagesof file.You have sophisticated searches, pattern options, and highlighting through multiplefiles.Keystrokes are compatible with word processing programs, such as emacs.The less command doesn’t quit on you when you reach the end of a file or the endof the standard input.The information prompt at the bottom of the screen is more customizable andoffers more information.There are loads of options, including a separate key setup program, lesskey, soyou can customize which keys control less.4When you install Linux, the less pager is the default pager used by a number of programs,such as the man command. If you need to read compressed files (those with a .gzextension, and about which you’ll learn in Hour 5), you can use the zless commandfound under the /usr/bin directory.As an example, I first create a text file containing a list of all the OpenLinux commandsin the /usr/bin directory with the ls command, as follows:# ls /usr/bin >programs.txtThis command line creates a text file called programs.txt. To read this file, use the lesscommand as in the following:# less programs.txt


88 Hour 4The less command loads the file and displays lines starting at the beginning of the file.To advance a single screen, press the Spacebar. To go back a single screen, press theB key. You can also use the cursor keys to move forward, backward, and even left andright! Normally, the less command prompt is a colon (:) at the bottom left of yourscreen. However, you can use the -M command-line option to view more informationabout your file, as follows:# less -M programs.txtNow when you browse through your file, the less command prints the file’s name, thecurrent and total line numbers, and a percentage number representing the current positionin the file. The prompt looks something like the following:programs.txt line 91/1221 8%This shows that you’re reading the file programs.txt, with the 91 st line of 1221 linesdisplayed at the top of the screen. If you want to run another program, such as the wc, orword count program, type an exclamation mark, followed by your command line, andpress Enter, as follows:! wc programs.txtThe wc command echoes the number of lines, words, and characters for the fileprograms.txt back to your screen. After the command finishes, the less commandprints the word done and asks you to press Enter.You can also quickly search through a text file using a less search command. Press theforward slash (/) and then type part of a word or phrase. The less command searchesthrough your file and highlights the first found instance of the search string. To searchfor the same phrase, just press / followed by the Enter key. To quit reading the file, pressthe Q key, and you return to your shell’s command line.Reading the Beginning or End of Files withthe head and tail CommandsAlthough the head and tail commands are not pagers per se, they can make life a loteasier when all you want to do is read the beginning or end of a file. Although these programs,like most Linux commands, are designed to do only one or two things, they dothese tasks well.The head command has a number of options besides the traditional -n x, which printsthe first x lines of a file. The head command in your Linux distribution, which is part ofthe GNU text utilities, also prints any number of 512-character, 1-kilobyte (1024 bytes),or megabyte-sized blocks from the beginning of a file. Like the cat command, head can


Reading and Navigation Commands 89handle binary files.If you use head in the traditional way, you strip off lines from thebeginning of one or several files. For example, if you want to see the first two linesof each HTML file for the Linux Installation Guide, use head with the option -n 2,followed by the path to the files, as follows:# head -n 2 /usr/doc/LDP/install-guide/install-guide-3.2.html/*.html==> /usr/doc/LDP/install-guide/install-guide-3.2.html/➥footnode.html Note that I only include the output for the first two files and that the default output fromthe head command is to include the filename (enclosed by ==> and The tail command is especially useful when you face the task of reading through largefiles where the most useful information is at the end of the file. One example task is tolook at the system messages for errors. One message file, located in /var/log, containsdetails of system operations, but the log is updated at the end of the message file. Inother words, text is appended, so the most recent messages are at the end of the file. Tolook at the last 12 lines in the message file using tail, make sure you’re logged in asroot, and type the following:# tail -n 12 /var/log/messagesNov 12 21:02:02 localhost cardmgr[152]: initializing socket 0Nov 12 21:02:02 localhost cardmgr[152]: socket 0: ATA/IDE➥Fixed Disk CardNov 12 21:02:02 localhost cardmgr[152]: executing: ‘insmod /➥lib/modules/2.0.30/pcmcia/fixed_cs.o’Nov 12 21:02:03 localhost kernel: hdc: SunDisk SDCFB-4,➥ 3MB w/1kB Cache, LBA, CHS=123/2/32Nov 12 21:02:03 localhost kernel: ide1 at 0x100-0x107,0x10e on irq 3


90 Hour 4Nov 12 21:02:03 localhost kernel: hdc: hdc1Nov 12 21:02:03 localhost cardmgr[152]: executing:➥’./fixed start hdc’Nov 12 21:02:03 localhost cardmgr[152]: initializing socket 1Nov 12 21:02:03 localhost cardmgr[152]: socket 1: Serial or➥Modem CardNov 12 21:02:03 localhost kernel: tty01 at 0x02f8 (irq = 5)➥is a 16550ANov 12 21:02:03 localhost cardmgr[152]: executing:➥’insmod /lib/modules/2.0.30/pcmcia/serial_cs.o’Nov 12 21:30:17 localhost PAM_pwdb[556]: (su) session opened➥for user root by bball(uid=0)If you try this example, OpenLinux might report the following:tail: /var/log/messages: Permission deniedThis means that you’re not logged in as the root operator! For security reasons,OpenLinux prevents casual users from reading your system logs.Instead, try using the su command as follows:su -c “tail -n 12 /var/log/messagesAfter you press Enter, su asks for the root password. Type in the root operator’spassword and press Enter again to see the information. This is a handyway to run commands as root.Being able to read large files in this way is convenient, considering that the systemmessages can grow to more than a million characters.SummaryThis hour introduces more than a dozen basic commands you use during yourOpenLinux sessions. Knowing how to get help, read files, list directories, and navigatethrough your file system are important skills. You use many of these commands repeatedlyas you learn how to use OpenLinux.


Reading and Navigation Commands 91Q&AQ I’ve found files with names like README under different directories under the/usr/doc directory. How do I read a README file?A Use the less pager from the command line, followed by the complete pathname tothe desired file. For example, to read the README file for the pdksh shell, type acommand line with less as follows and press Enter:less /usr/doc/pdksh-5.2.13/READMEQ Some pathnames are really long! Is there an easier way to read or list a file?A Using the previous example, you can use an asterisk (*) in the pathname as follows:less /usr/doc/pdksh*/README.Q I typed the previous example but used an asterisk as follows:less /usr/doc/p*/READMEThe less command says that it is reading file 1 of 25! What happened, andhow do I read the other files?A There are at least 37 different directories under the /usr/doc directory with namesthat begin with the letter p. Obviously, 25 of these directories contain a file calledREADME. In the less pager, to jump to the next file, type a colon (:) and press the Nkey.Q How do I list just directory names? For example, I want to see the names ofall directories under the /usr/doc directory that begin with the letter z.A Use the -d, or directory command-line option with the ls command. To see all thedirectories with names beginning with the letter z, type the command as follows:4ls -d /usr/doc/z*Exercises1. Use the cd command to go to the /usr/bin directory. Then type cd and pressEnter. Where are you?2. Again, use the cd command, but this time go to the / directory. Type cd ~ andpress Enter. Next, type cd - and press Enter. Where are you?3. The cat command’s -n option numbers lines displayed to your screen. How canyou number lines in files you read with the less command?


HOUR 5Manipulation andSearching CommandsIn this hour, you’ll learn about creating, copying, deleting, and moving filesand directories. You’ll also learn about searching files and how to compressand decompress files. This information builds on information you learned inthe preceding hour, and the commands you learn here are used later in thisbook.Manipulating Files or DirectoriesUsing Linux isn’t different from using any other computer operating system.You create, delete, and move files on your hard drive in order to organizeyour information. This section shows you how to do these tasks quickly andeasily.


94 Hour 5Although the graphical interface for Linux, the X Window System, might offer drag-anddropcapabilities or multiple selections in order to copy or delete files, many of the commandsyou learn here form the base of these operations. It is worth knowing how theseprograms work, even if you don’t use Linux in the console mode.Creating Files with the touch CommandThe touch command is easy to use, and generally, there are two reasons to use it. Thefirst reason is to create a file, and the second is to update a file’s modification date. Thetouch command is part of the GNU file utilities package and has several options.To create a file with touch, use the following:# touch newfile# ls -l newfile-rw-r--r-- 1 bball users 0 Jan 5 12:40 newfileAs you can see, touch creates a file with a length, or size, of zero. You can also use thefollowing:# > newfile2# ls -l new*-rw-r--r-- 1 bball users 0 Jan 5 12:40 newfile-rw-r--r-- 1 bball users 0 Jan 5 12:41 newfile2Like touch, this creates a file with a length of zero. So why use touch if you can do thisat the command line? Because touch can update a file’s date or time. You can even usetouch to change a file’s date or time to the past or the future, for example:# touch newfile2# ls -l newfile2-rw-r--r-- 1 bball users 0 Jan 5 12:44 newfile2As you can see, the file newfile2 now has a timestamp 3 minutes younger (12:44 insteadof 12:41). You can also set the time and date of a file to an arbitrary time and date byusing the touch command’s -t option, followed by a string of numbers representing themonth, day, time, and year, for example:# touch -t 1225130000 newfile2# ls -l --full-time new*-rw-r--r-- 1 bball users 0 Tue Jan 05 12:40:14 1999 newfile-rw-r--r-- 1 bball users 0 Mon Dec 25 13:00:00 2000 newfile2The --full-time option and long format listing of the ls command show that the filenewfile2 now has a timestamp of 1 p.m., Christmas Day, 2000 (which appears to be,and is indeed, a Monday).


Manipulation and Searching Commands 95One use for touch is during backup operations. Either before or after backing up a seriesof files or directories, you can use touch to update the timestamps of your files so thatthe backup program has a reference time for the next backup session. Another use fortouch is to either delete or retain log files on your system during automated file cleanupby scheduled programs managed by cron (see the section “Using the cron Daemon” inHour 24, “Using Scheduling to Automate System Management”). If you make a log fileold enough, it is deleted. If you update it, the file is retained.Deleting Files with the rm CommandThe rm command deletes files. This command has several simple options but should beused cautiously. Why? Because when rm deletes a file, it is gone. (You might be able torecover portions of text files, though; see the mc command later this hour for pointers.)Always running Linux while logged in as the root operator and using the rmcommand has caused many untold tales of woe and grief. Why? Becausewith one simple command, you can wipe out not only your Linux system,but also any mounted file systems including DOS partitions, flash RAM cards,or removable hard drives, as follows:# rm -fr /*This command removes all files and directories recursively with the -roption, starting at the root (/) directory. If you must run Linux as root, makesure to back up your system, and read Hour 23, “Backing Up and RestoringYour System.”The rm command deletes one or several files from the command line. You can use any ofthe following:5# rm file# rm file1 file2 file3# rm file*The first command line deletes a single file named file, the second command linedeletes three files, and the third command line deletes any file in the current directorywith a filename beginning with the letters file. One of the safer ways to use rm isthrough the -i, or interactive, option where you’re asked if you want to delete the file,for example:# rm -i new*rm: remove `newfile’? yrm: remove `newfile2’? y


96 Hour 5You can also force file deletion by using the -f option, as in the following:# rm -f new*If you use the -f option and no files match the new* pattern, the rm command fails withoutdisplaying an error message. However, if rm finds a directory, even if it is empty, itdoes not delete the directory, and it complains, even if you use -f, as in the following:# rm -f temp*rm: temp: is a directoryrm: temp2: is a directoryWhen you combine the -f and -r options, you can delete directories and all files ordirectories found within, provided you own them or have permission; see Hour 22,“Handling Files and Your File System.” -f and -r can be combined as in the followingexample:# rm -fr temp*The -fr option also makes rm act like the rmdir command (discussed laterthis hour). Be extremely careful when you use this option! Generally, whenyou delete a file in OpenLinux, the file is gone forever!Some X window environments, such as KDE, or productivity suites, likeStarOffice, offer “trash can” approaches to deleting files—files are not reallydeleted, just moved to a temporary directory. This is a safe, but not fail-safe,approach to deleting or recovering files. If you really need help with recoveringa file, you might be able to use the mc, or Midnight Commander, commanddiscussed later this hour.Creating Directories with the mkdir CommandUse the mkdir command to create one or several directories. You might be surprised toknow that mkdir can also create a whole hierarchy of directories, including parents andchildren, with a single command line.This command is one of the basic tools, along with cp and mv, you can use to organizeyour information. Take a look at some examples. The following simple command linecreates a single directory:# mkdir temp


Manipulation and Searching Commands 97But you can also create multiple directories, as follows:# mkdir temp2 temp3 temp4You can also type the following to make a directory named child under temp:# mkdir temp/childThis works because the temp directory exists (you just created it). But, suppose you typethe following:# mkdir temp5/childmkdir: cannot make directory `temp5/child’: No such file or directoryAs you can see, mkdir complains because the temp5 directory does not exist. To build ahierarchy of directories with mkdir, you must use the -p, or parent, option, as in thefollowing example:# mkdir -p temp5/parent/child# tree temp5temp5`-- parent`-- child2 directories, 0 filesAs you can see, not only does mkdir create the temp5 directory, but also a subdirectorycalled parent, and a subdirectory under parent called child.Now that you know how to create directories, take a look at how to remove them.Removing Directories with the rmdir CommandThe rmdir command removes directories. To remove a directory, all you have to do istype the following:5# rmdir tempdirectoryBut there’s a catch: the directory must be empty first! If you try to delete a directory containingany files, you get an error message like this:# rmdir temp5rmdir: temp5: Directory not emptyIn this example, temp5 contains other directories. The rmdir command also complains ifa directory contains only files and not directories. You can use the rm command toremove the files first (remember to be careful if you use the -fr option), move the filessomewhere else, or rename the directory with the mv command, which is discussed next.


98 Hour 5The rmdir command, like mkdir, has a -p option. You can use this option to removedirectory hierarchies, as follows:# rmdir -p temp5rmdir: temp5: Directory not emptyHmm… That doesn’t work! How about the following:# rmdir -p temp5/parentrmdir: temp5/parent: Directory not emptyHey! That doesn’t work either. Now try this:# rmdir -p temp5/*rmdir: temp5/parent: Directory not emptyThis is getting frustrating! Try it one more time:# rmdir -p temp5/parent/childFinally! As you can see, you must specify the complete directory tree to delete it. If youuse the same command line without the -p option, only the child directory is deleted. Butwhat if there are two or more subdirectories, as in the following example:# mkdir -p temp5/parent/child# mkdir temp5/parent/child2# tree temp5temp5`-- parent|-- child`-- child23 directories, 0 filesIn order to delete the entire directory system of temp5, you need to use the following:# rmdir temp5/parent/*Now you know how to create and remove directories. Next, you learn about the mvcommand, which you can use to move or rename files and directories.Renaming Files with the mv CommandThe mv command, called the rename command, indeed renames files or directories—butit is also known to many as a move command that moves files or directories around yourfile system.Actually, in the technical sense, the files or directories are not really moved. If you insiston knowing all the gory details, read the Linux System Administrator’s Guide, or theSAG, available through the following site:http://metalab.unc.edu/LDP/LDP/sag/index.html


Manipulation and Searching Commands 99Don’t want to read the SAG online? You can probably find a copy installedon your OpenLinux system. Try using the lynx text-only web browser, asfollows:lynx /usr/doc/LDP/system-admin-guide/sag-0.6-html/sag.htmlFor more information about using the lynx browser, see Hour 13, “InternetDownloading and Browsing.”In its simplest form, mv can rename files, for example:# touch file1# mv file1 file2This command renames file1 to file2. Besides renaming files, mv can rename directories,whether they are empty or not. For example, even if you create a directory structurewith the mkdir command, you can use the mv command to rename the new top-leveldirectory, like so:# mkdir -p temp/temp2/temp3# mv temp newtempAlthough mv has nine different options, this section concentrates on the two most commonlyused, -b (backup) and -i (interactive). These options enable you to use mv in afairly safe way—mv not only renames but also overwrites quickly and silently (withoutasking)! The first option, -b, creates a backup of any file or directory you rename to anexisting name, for example:# touch uno deux tres# ls uno deux tresdeux tres uno# mv uno deux# ls uno deux tresls: uno: No such file or directorydeux tres5As you can see, without using -b, mv not only renames the file uno to deux, but deletesthe file deux in the process. Is this dangerous? You bet! Now, try the -b option:# touch uno# ls uno deux tresdeux tres uno# mv -b uno deux# ls deux* tresdeux deux~ tres


100 Hour 5This example shows that although the file uno is renamed replacing the file deux, abackup of deux with a default extension of the tilde (~) is created.The mv command can work silently, or as with rm, you can use the -i option, forexample:# touch file2 file3# mv file2 file3# touch file2# mv -i file2 file3mv: replace `file3’? yHere, I create two files, and then rename the file file2 to file3, which deletes the originalfile3. However, I then use the -i option, and the mv command asks if I want to overwritethe file. The mv command does not ask for permission if no overwriting takes place,even if you use -i. You can also combine the -b and -i options as follows:# mv -bi file2 file3Now that you know how to delete, rename, or move your files, how do you copy files?Copying with the cp CommandThe cp, or copy, command copies files or directories. This command has nearly 40command-line options. They aren’t all covered here, but you learn about some of themost commonly used options, which save you time and trouble.You’ll most likely first use cp in its simplest form, for example:# cp file1 file2This copies file1 to create file2 and, unlike mv, leaves file1 in place. But you must becareful when using cp because you can copy a file onto a second file, effectively replacingit! In this regard, cp can act like mv. To show you how this can happen, try creatingthree files, each with a line of text, using the cat command:# cat > file1this is file1# cat > file2this is file 2# cat > file3this is the third file# ls -l file*-rw-r--r-- 1 bball users 14 Jan 5 13:29 file1-rw-r--r-- 1 bball users 15 Jan 5 13:29 file2-rw-r--r-- 1 bball users 23 Jan 5 13:29 file3


Manipulation and Searching Commands 101Now, copy a file onto another file, and then check the file sizes and the contents of thenew file, as follows:# cp file1 file2# ls -l file*-rw-r--r-- 1 bball users 14 Jan 5 13:29 file1-rw-r--r-- 1 bball users 14 Jan 5 13:31 file2-rw-r--r-- 1 bball users 23 Jan 5 13:29 file3# cat file2this is file1It should be obvious that file1 replaces file2. To avoid this problem (unless you reallywant to overwrite the file), you can use the -b or -i options, which work like mv. Here’san example:# cp -i file1 file2cp: overwrite `file2’? n# cp -bi file1 file2cp: overwrite `file2’? y# ls file*file1 file2 file2~ file3Note that file2, which is overwritten, is backed up.The cp command can also copy a number of files at one time. The following exampleshows how to copy all the files in directory tempdir1 to directory tempdir2:# cp tempdir1/* tempdir2# tree tempdir2tempdir2|-- temp1file1|-- temp1file2`-- temp1file350 directories, 3 filesLike the rm command, cp also has an -r, or recursive, option. You can use this option tocopy one directory into another. For example, to copy the tempdir1 directory and its filesinto tempdir2, use this syntax:# cp -r tempdir1 tempdir2# tree tempdir2tempdir2|-- temp1file1|-- temp1file2|-- temp1file3`-- tempdir1|-- temp1file1|-- temp1file2`-- temp1file31 directory, 6 files


102 Hour 5Finally, the cp command has the -p option, which is similar to mkdir’s -p option.Normally, when you copy a file inside several directories into another directory, only thefile is copied. The following example only copies temp1file1 into tempdir3:# tree tempdir2tempdir2|-- temp1file1|-- temp1file2|-- temp1file3`-- tempdir1|-- temp1file1|-- temp1file2`-- temp1file31 directory, 6 files# cp tempdir2/tempdir1/temp1file1 tempdir3However, what if you want to copy a file along with its directory structure? To do this,you can use the -P option:# cp -P tempdir2/tempdir1/temp1file1 tempdir3# tree tempdir3tempdir3`-- tempdir2`-- tempdir1`-- temp1file12 directories, 1 fileNot only does cp copy the single file, but it has also creates the subdirectory structure.Creating Hard and Symbolic Links with the lnCommandLinux supports both hard and symbolic links. Although it is not important that youunderstand how links in Linux work, you need to understand the difference betweenthese two types of links, and how to use links while you use Linux. To create hard orsymbolic links, use the ln, or link, command.The ln command creates both types of links and links files with other files(including directories, which under OpenLinux are simply files, too). The importantdifference is that hard links directly link two files on only the same file system. Onthe other hand, you can use a symbolic link between directories or files that span differentfile systems. Hard links also have other advantages. If you use the ln command tocreate a hard link, you specify a second file on the command line you can use to referencethe original file, as in the following example:NEW TERM


Manipulation and Searching Commands 103# cat > file1This is file1# ln file1 file2# ls -l file*-rw-r--r-- 2 bball users 14 Jan 5 13:32 file1-rw-r--r-- 2 bball users 14 Jan 5 13:32 file2# cat file2This is file1You can see that file2 is exactly the same as file1. If you delete file1, file2 remains.If you make changes to file1, such as adding text, these changes appear in file2, and ifyou make changes to file2, file1 is also updated. Although you can see two files, each14 characters in size, only 14 characters of hard drive space are used for the original file(okay, technically more than that, but it depends on the block size of the partition or typeof hard drive).On the other hand, although symbolic links are useful, they have a drawback. The nextexamples show you why. First, to create a symbolic link, use the ln command’s -soption:# cat >file1This is file1# ln -s file1 file2# ls -l file*-rw-r--r-- 1 bball users 14 Jan 5 13:48 file1lrwxrwxrwx 1 bball users 5 Jan 5 13:48 file2 -> file1Note the arrow pointing from file2 to file1. This tells you that file2 is a symboliclink to file1. Also note that file2 is smaller in length than file1. Symbolic links aredifferent from hard links in that a symbolic link is merely an alias for the original file.Nothing happens to the original file if you delete the symbolic link. However, if youdelete the original file, your symbolic link can’t help you at all:5# rm -f file1# cat file2cat: file2: No such file or directoryBecause the original file, file1, no longer exists, you can’t access its contents throughthe symbolic link, file2. However, symbolic links do have an advantage over hard links.You can use a symbolic link to point to a directory on your OpenLinux file system oreven another file system. In the following example, if you try to create a hard link to the/usr/local/games directory, the ln command complains and quits:# ln /usr/local/games playln: /usr/local/games: hard link not allowed for directory


104 Hour 5But you can use a symbolic link, as follows:# ln -s /usr/local/games play# ls -l playlrwxrwxrwx 1 bball users 16 Jan 5 14:12 play -> /usr/local/gamesNow, instead of typing a long command like# cd /usr/local/gamesyou can use# cd playSymbolic links to other directories on other file systems, such as a DOS orWindows partition, can be handy. For example, having a directory called dosin your home directory that is linked to /mnt/dos/windows/desktop makescopying or moving files to and from Linux and Windows a lot easier. Forexample, if you want to have a linked directory named dos in your homedirectory and your DOS file system is mounted under the /mnt/dos directory,first make sure that the DOS file system is mounted, and then use the lncommand to create a symbolic link, like so:# ln -s /mnt/dos/windows/desktop dosSee Hour 22 for details about mounting other file systems.So far, you’ve learned about using the command line. If you’re familiar with more graphicalinterfaces for manipulating files, you’ll like the next program, mc.Handling Files with the Midnight CommanderProgramThe mc program, called Midnight Commander, is a graphical interface for handling files(see Figure 5.1). It is a visual shell (you’ll learn more about shells in the next hour,“Using the Shell”). To start mc, type the following at the command line:# mcThis section does not cover all the details of the mc program. Here are the highlights ofits features:●●●Provides a visual interface to two directories at a timeEnables directory browsing with mouse clicksEnables menu-driven file operations with dialog boxes, mouse, keyboard and functionkey support


Manipulation and Searching Commands 105●●●●●●Has an open command line to your shellRuns commands through mouse clicksHas extensive, built-in hypertext help screensEmulates and supports the ls, cp, ln, mv, mkdir, rmdir, rm, cd, pwd, find, chown,chgrp, and tree commandsCompares directory contentsUses customized menus so you can build your own commands● Can use network links for telnet or FTP operations (see Hour 13)●●Offers mouse-click decompression of files (see the section “Compressing Fileswith the gzip Command” later this hour)Can undelete files if your Linux file system is configured to support this capabilityMidnight Commander is a handy and convenient tool to use for file handling and directorynavigation. You have to invest some time learning how to use this program, but ifyou’ve used similar file-management interfaces, you’ll feel right at home.FIGURE 5.1The MidnightCommander visualshell displays a graphicalinterface to Linuxfile commands.5Searching FilesThis section introduces you to the use of sophisticated wildcards, or regular expressions,along with short examples of file searches using the grep family of programs. If youunderstand and use these expressions, you can create refined search techniques you canuse again and again. You’ll save time and effort during your work, and your learninginvestment will pay big dividends throughout your Linux experience.


106 Hour 5What Are Regular Expressions?Regular expressions are patterns that use special syntax to match strings (usuallyin text in files, unless your search is for filenames). There are also extended regularexpressions that can use additional operators in the search patterns. The difference,important for syntax, should not deter you from learning how to construct patterns thataccurately match your desired search targets. This is important if you’re looking for textin files and critical if you’re performing potentially dangerous tasks, such as multiple filedeletions across your system.NEW TERMYou can build an infinite number of regular expressions using only a small subset of patterncharacters. Table 5.1 contains a short list of some of these characters. You should befamiliar with at least one (the asterisk) from the previous examples.TABLE 5.1 COMMON REGULAR EXPRESSIONSExpressionMatching* Any character? or . A single character{x}Preceding character x times{x,y}Preceding character at least x times but no more than y{x,}Preceding character at least x times(xxx)|(XXX)String xxx or XXX[xxx] or [x-x] A character in a range of characters[XYZ]+X, Y, or Z at least once\x A character such as ? or \^patternpattern at the beginning of a line$patternpattern at the end of a lineThis is not a comprehensive list of pattern characters. For more details, you can read theed manual page (the ed command is discussed in Hour 14, “Text Processing”). For now,try several simple examples using different patterns.The asterisk is useful for finding matches to all characters. For example, if you wantto find all the text files in your directory with an extension of .txt, you can use thefollowing:# ls *.txt14days.txt 96hours.txt datalog.txt datebook.txt day67.txt


Manipulation and Searching Commands 107But suppose you want a list of all the ?files in your directory with numbers in the filename?You can try to string multiple searches on the ls command line, like this:# ls *0* *1* *2* *3* *4* *5* *6* *7* *8* *9*08100097.db 14days.txt backup001.file phonelog.11159708100097.db 32days.msg day67.txt phonelog.11159708100097.db 32days.msg day67.txt phonelog.11159708100097.db 96hours.txt message.7608100097.db 96hours.txt message.7614days.txt backup001.file phonelog.111597Obviously, this is not the result you want because the multiple searches have printedduplicate filenames. To find exactly what you want, use a regular expression that tells lsto list any file that has a number appearing in the file’s name, as follows:# ls *[0123456789]*0001file.0009 32days.msg day67.txt08100097.db 96hours.txt message.7614days.txt backup001.file phonelog.111597This shows all the files containing numbers in the filename because you specify a rangeof characters or, in this case, numbers in your search pattern. You can also use a regularexpression shorthand to build a shorter expression to do the same thing, for example:# ls *[0-9]*0001file.0009 32days.msg day67.txt08100097.db 96hours.txt message.7614days.txt backup001.file phonelog.111597How you specify your pattern characters in your expression is important. If you onlywant a list of files ending in a number, you can use the following:# ls *[0-9]0001file.0009 message.76 phonelog.1115975If you only want a list of files beginning with a number, you can use this:# ls [0-9]*0001file.0009 08100097.db 14days.txt 32days.msg 96hours.txtHere’s a fun exercise: What if you want to list those files with numbers only inside or onboth ends of a filename? Try these:# ls *[-a-z][0-9]*backup001.file day67.txt# ls [0-9]*[a-z]*[0-9]0001file.0009


108 Hour 5Finally, how do you match patterns when the pattern you’re looking for contains apattern-matching character? Easy! Use the backslash to escape the character, forexample:# ls *\?*cathy?.messageAs you can see, using regular ?expressions can take some practice, b-ut your efforts arewell rewarded. Try experimenting with different expressions to see if you can come upwith results similar to the examples shown in this section.Searching Inside Files with the grep CommandsThis section introduces you to the family of grep commands. You’ll learn about grep,egrep, and fgrep. In order to use these commands, you should know how to use some ofthe pattern-matching techniques already discussed. You’ll use these commands to searchthrough files and extract text. Each of these programs works by searching each line in afile. You can search single files or a range of files.Each of the grep commands is basically the same and has nearly 20 different commandlineoptions. The only real difference is that egrep uses a slightly different syntax for itspattern matching, whereas fgrep uses fixed strings. You’ll see examples of each programand use some of the common options. For specific details about the pattern-matchingcapabilities of these programs, see the grep manual page.To show you the difference in each program’s search pattern syntax, I’ll look for differentpatterns in Matt Welsh’s Linux Basic Installation Guide (available athttp://metalab.unc.edu/LDP or on your OpenLinux system in the /usr/doc/LDP directory). For example, if you want to find all the lines in the guide that beginwith a number, use the following syntax:# grep ^[0-9] guide.txt1 Introduction to Linux 12 Obtaining and Installing Linux 403 Linux Tutorial 854 System Administration 137...# egrep ^[0-9] guide.txt1 Introduction to Linux 12 Obtaining and Installing Linux 403 Linux Tutorial 854 System Administration 137...# fgrep ^[0-9] guide.txt


Manipulation and Searching Commands 109You can see that grep and egrep returned a search (I deleted all the output except thefirst four lines). Note, however, that fgrep can not handle regular expressions. You mustuse fixed patterns or strings with the fgrep command, for example:# fgrep friend guide.txtlarge extent by the window manager. This friendly program is incopy Linux from a friend who may already have the software, or share(Unfortunately, the system was being unfriendly.)Now use egrep to try searching for the pattern of the letter (b) in the file:# egrep “\([b]\)” guide.txt(see Section 1.8 for a list of compatible boards), or (b) there is anconnect to the network, or (b) you have a ``dynamic’’ IP address,You see that exactly two lines in the file match (b). See what happens when you searchwith grep:# grep “\([b]\)” guide.txtThis is version 2.2.2 of the book, “Linux Installation and Gettingto PostScript printers. This document was generated by a set of toolsfrom LaTeX source, so there may be a number of formatting problems.This is not the “official” version of the book! Please see...Whoa! Not exactly what you wanted, is it? As you can see, grep does not use the samesyntax as the egrep command. But you can use a simpler approach:# grep “(b)” guide.txt(see Section 1.8 for a list of compatible boards), or (b) there is anconnect to the network, or (b) you have a ``dynamic’’ IP address,This pattern works with grep and fgrep. If you try this pattern with egrep, you get thesame results as if you tried extended regular expressions with grep (each line with a(b)).5Each grep program accepts nearly the same set of command-line options. One popularoption is -n, or line numbering. This is handy because you see which lines in the filecontain matches. This example works for each grep program:# egrep -n “friend” guide.txt1242:large extent by the window manager. This friendly program is1942:copy Linux from a friend who may already have the software, or5161:(Unfortunately, the system was being unfriendly.)You can see that matches were made on lines 1242, 1942, and 5161. Another feature ofthese programs is that you don’t have to retype your patterns each time you want tosearch. As a simple example, if you need to repeatedly search files for different words,you can put these into a file for grep to use. First, create a text file and then use the -foption to specify the file, as follows:


110 Hour 5# cat > mywordswonderfulTypewriterWar# grep -nf mywords guide.txt574:Typewriter Used to represent screen interaction, as in617:software since the original Space War, or, more recently, Emacs1998:Now you must be convinced of how wonderful Linux is, and all2549:inanimate object is a wonderful way to relieve the occasional3790: Warning: Linux cannot currently use 33090 sectors of7780:to wear the magic hat when it is not needed, despite wonderful10091:wonderful programs and configurations are available with a bitBecause you also use the line-numbering option, you should note that it has to comebefore the -f, or file, option, or grep reports an error, complains it can’t find file n, andquits.You can make grep act like fgrep with the -F option or like egrep with the -E option.You can also find a unique version of grep on your system, called zgrep, which you canuse to search compressed files, the topic of the next section.Compressing and Uncompressing FilesThis section introduces you to the basics of archiving and compressing files. However,for details concerning using these programs for the purpose of system management orbacking up your system, see Hour 23. Read on, and you’ll learn how to build your ownarchives and save disk space.Creating Archives with the Tape Archive CommandThe tar (tape archive) program has its roots in the early days of computing beforefloppy drives, hard disks, and CD-ROMs. Software was distributed and backed up onlarge reels of magnetic tape, so one of the first programs to run on computers was a tapereader. Over time, the tar program proved its merit as a convenient way to transportfiles, and many programs for Linux come packaged in tar archives (your OpenLinuxCD-ROM uses the rpm program to package files; see Hour 22).Using tar, you can create an archive file containing multiple directories and files. Theversion of tar installed on your system also supports a -z option to use the gzip programto compress your archive. (gzip is discussed later in this chapter.)The tar command has a bewildering array of options, but it’s not hard to use. You canquickly and easily create an archive of any desired directory.


Manipulation and Searching Commands 111First, create a directory with three files, and then create a subdirectory with another threefiles:# mkdir mydir# cd mydir# touch file1 file2 file3# mkdir mydir2# cd mydir2# touch file21 file22 file23# cd ../..# tree mydirmydir|-- file1|-- file2|-- file3`-- mydir2|-- file21|-- file22`-- file231 directory, 6 filesNow that you have a directory and files, create a tar archive using the c (create) and f(file) options with this command:# tar cf mydir.tar mydir# ls -l *.tar-rw-r--r-- 1 bball users 10240 Jan 5 15:01 mydir.tarNotice that your original directory is left untouched. By default, tar does not delete theoriginal directories or files. You can use the --remove-files option if you want to dothis, but it’s not recommended. If you want to see what’s going on, you can use the voption, like this:5# tar cvf mydir.tar mydirmydir/mydir/file1mydir/file2mydir/file3mydir/mydir2/mydir/mydir2/file21mydir/mydir2/file22mydir/mydir2/file23The tar command shows you what directories and files are being added. Does this meanyou have to add all the files in your directories? No! You can use the w, or interactiveoption, and have tar ask if you want each file added. This can be handy for selectivelybacking up small directories, for example:


112 Hour 5# tar cwf mydir.tar mydiradd mydir?yadd mydir/file1?nadd mydir/file2?yadd mydir/file3?nadd mydir/mydir2?yadd mydir/mydir2/file21?yadd mydir/mydir2/file22?nadd mydir/mydir2/file23?yHere I left out file1, file3, and file22 from this archive. But how can you make sure?One way is to use two tar options, t to list an archive’s contents and f to specify a tararchive to use, for example:# tar tf mydir.tarmydir/mydir/file2mydir/mydir2/mydir/mydir2/file21mydir/mydir2/file23Note that if options are placed in the wrong order (like the grep example), tar complainsand quits. Now that you know how to create and see the contents of an archive, you canlearn how to extract the whole archive or a single file. To extract everything, you can usethe -x, or extract, option with -f. Just so you know what’s going on, include the -voption, too:# tar xvf mydir.tarmydir/mydir/file2mydir/mydir2/mydir/mydir2/file21mydir/mydir2/file23If you want only a few files from your archive, you can again use the w option:# tar xvwf mydir.tarextract mydir/?ymydir/extract mydir/file2?ymydir/file2extract mydir/mydir2/?ymydir/mydir2/extract mydir/mydir2/file21?ymydir/mydir2/file21extract mydir/mydir2/file23?ymydir/mydir2/file23


Manipulation and Searching Commands 113Here, I went through the archive interactively extracting files. If you want a single filefrom an archive, you can specify the file on the command line. For this example, theoriginal mydir is removed, and I’m using an empty directory:# tar xf mydir.tar mydir/mydir2/file23# tree mydirmydir`-- mydir2`-- file231 directory, 1 fileAs you can see, only one file is extracted. Be careful, though! The tar command doesn’toverwrite whole directories, but it does overwrite files with the same name.Try experimenting with tar before you start building archives. Some other features to tryare selectively deleting files from an archive or adding a file to an existing archive, whichis something the next program, cpio, can do, too.You can use other programs, such as BRU-2000 or the taper script to back upyour file system or selected files and directories. OpenLinux can also createfile archives automatically through cron scheduling. See Hour 23 for informationon BRU-2000 and the taper script; see Hour 24 for details on cronscheduling.Creating cpio ArchivesThe cpio command copies files in and out of tar or cpio archives. Because cpio iscompatible with tar, this section doesn’t go into all the details of how it works, but ithas some features that tar does not, such as the following:5●●●Support for both cpio and tar archivesSupport for a number of older tape formatsThe capability to read files’ names from a pipe (which you’ll learn about in thenext hour)Very few, if any, software packages for Linux are distributed in cpio format. Chances areyou won’t run across any cpio archives in your search for new software across theInternet. But if you’re interested in the details about cpio, see its man page. For anexample of how to use cpio to back up specific files, see Hour 23.


114 Hour 5Compressing Files with the gzip CommandThe gzip command compresses files. This program is not only handy for saving diskspace by compressing large, less often used files, but could be, in combination with tar,the most popular compressed file format for Linux. You’ll often find files with the .tgzor .tar.gz format while searching for new Linux software across the Internet.You’ll also find that much of the documentation under your /usr/doc/HOWTO directorywas compressed with gzip. This can save a lot of space. According the Free SoftwareFoundation folks in gzip’s manual page, gzip has a 60–70%compression rate for textfiles.The gzip command is easy to use. To compress a file or tape archive, enter the following:# gzip mydir.tarBy default, gzip compresses your file, appends a .gz extension, and deletes your originalfile. To uncompress your file, you can use the gzip companion program, gunzip, or thegzip -d (decompress) option. You have to make sure the file has a .gz (or .Z, -gz, .z,-z, or _z) extension, or both gzip and gunzip complain. If you want to specify your ownextension, use the -S (suffix) option. For example, to compress a tape archive with theextension .gzipped, use gzip and its -S option, like so:# gzip -S .gzipped mydir.tarThe gzip command also handles zipped, compressed, or pack compressed files. If youwant more information during compression or decompression, you can use -l, or listoption, to see the compressed or decompressed sizes of files. After compressing thedirectory mydir from the previous example, use the gzip to get statistics like this:# gzip -l mydir.tar.gzcompressed uncompr. ratio uncompressed_name239 10240 97.9% mydir.tarFinally, gzip also has a helpful option, -t, to test the integrity of a compressed file. If thefile is okay, gzip reports nothing. If you need to see OK, use -tv when you test a file.Compressing Files with the compress CommandThe compress command does just that: it compresses files. This is one of the earliercompression utilities for the UNIX world.Files created with compress traditionally have a .Z extension. To compress a file, enterthe following:# compress file


Manipulation and Searching Commands 115To uncompress a file, use this:# uncompress file.ZAs with gzip, you must specify a filename with a .Z extension, or compress willcomplain.Interested in other compression utilities for Linux? Look on your system forzip, unzip, zipcloak, zipnote, zipsplit, zless, zcat, znew, zmore, zcmp,pack, compact, shar, unshar, or zforce. You might not find all theseinstalled, but you can find versions at favorite Linux software sites (such ashttp://metalab.unc.edu/pub/Linux) that work with OpenLinux.SummaryThis hour introduced the basic OpenLinux commands needed to create, delete, move,copy, search, save, and compress files and directories. As you learn more aboutOpenLinux during your sessions, you’ll build on your basic knowledge to create morecomplex and custom commands.Q&AQ Are there any other file compression programs for OpenLinux?A Yes. You might be able to get even better compression with the bzip2 command.This program uses a different compression algorithm than gzip and is includedwith OpenLinux under the /bin directory. You can recognize these archives by the.bz2 extension.Q I’ve seen some files with an extension of .uu and wonder if these are compressedfiles?A No. A file with a .uu extension has been converted from a binary format to plaintext by the uuencode command. To convert the file back to its original form, usethe uudecode command like so:uudecode somefile.uuThese commands are used by some users to prepare artwork, programs, or otherbinary format files for transmission by electronic mail or for posting in a Usenetnewsgroup message (see Hour 12, “Configuring Internet News,” for more informationabout Usenet news).5


116 Hour 5Q How can I look at what’s inside a binary file? If I try to use the cat or lesscommands, I see a lot of garbage.A Try using the strings command. To see how to use strings with less, see Hour 6,“Using the Shell.”Q How do I get more information about each file inside a tape archive? I knowthat the t option shows the file and directory names.A Use the v option along with t on the tar command line to view the permissions,owner, group, file size, date, time, and name of each item in a tape archive.Exercises1. The tar program can perform file compression during archiving operations. Createa compressed tape archive of a test directory using tar.2. There are several other compression programs included with OpenLinux. What aretheir names? (Hint: Use whatever command you think is “apropos”priate!)3. How can you find all the compressed files included with your OpenLinux distribution?


HOUR 6Using the ShellIn this hour you’re introduced to the shell. Although the trend in personalcomputing in the last 10 years has been to move away from the commandline to a point-and-click interface, the shell is still very much alive in Linuxand is used by many Linux programs.This hour doesn’t go into a detailed history of Linux or UNIX shells or takesides in a debate over which computing interface is easier or better to use.Nor does this hour delve into shell programming—there’s not enough roomin this hour (or even this book) to do so. This hour does, however, discussthe different shells you can find on your OpenLinux CD-ROM, show youhow to use the shell to make your Linux experience more enjoyable, andhighlight some of the basics of using the shell and the command line.What is a Shell?If you’re not using the X Window System, the shell is one of the mostimportant programs you use. The shell provides the interface to Linux soyou can run programs. In fact, the shell is just another Linux program.


Using the Shell 119These shells, listed in Table 6.1, have many, many features. Read the manual pages foreach in detail. Some of the features to look for and explore include the following:●●●●●●●●What are the shell’s built-in commands?How is job control (or background processes, discussed later this chapter in thesection, “Running Programs in the Background”) handled?Does the shell support command-line editing?Does the shell support command-line history?What are the important startup or configuration files?What environmental variables are important for each shell?What command-line prompts can I use?What programming constructs are supported?There are several other shells that are included with OpenLinux: tclsh, asimple shell and Tcl interpreter; wish, a windowing shell for X11; scotty, aTcl interpreter and shell; and rsh, a remote shell for running commands overa network. For details, see the tclsh, wish, scotty, and rsh manual pages.TABLE 6.1 SHELLS INCLUDED IN THE OPENLINUX DISTRIBUTIONNameDescriptionashCompact sh-compatible shellbashBourne Again Shell (ksh- and sh- compatible)cshkshshtcshzshsymbolic link to tcshpdksh, public domain Korn (ksh- compatible) shellsymbolic link to bashcsh-compatible shellZ-shell; a csh-, ksh-, and sh- compatible shell6Features of ashThe ash shell, by Kenneth Almquist, is one of the smallest shells available for Linux.This shell has 24 different built-in commands and 10 different command-line options.The ash shell supports most of the common shell commands, such as cd, along withmost of the normal command-line operators (discussed later this chapter in the section,“Understanding the Shell Command Line”).


120 Hour 6This is a popular shell that is generally used when you boot OpenLinux in the single-usermode (typing linux single at the LILO boot prompt) or for rescue mode or diskette versionsof Linux. The small executable size, generally one-tenth of the bash shell, makesash an ideal shell for small file systems.Features of the Default Linux Shell—bashThe bash, or Bourne Again Shell, by Brian Fox and Chet Ramey, is one of the most popularshells for OpenLinux. It features 48 built-in commands and a dozen command-lineoptions. The bash shell works just like the sh shell and has a symbolic link under the/bin directory, called sh, that points to the bash shell.Not only does bash work like the sh shell, but it also has features of the csh and kshshells. Because bash is so widely used, it is used for the examples in this hour. Lateryou’re shown how to customize your command-line prompt using the bash shell.The bash shell has many features. You can scroll through your previous commands withthe arrow keys (a history feature), you can edit a command line, and if you forget thename of program, you can even ask the shell for help by using filename completion. Youdo this by typing part of a command and then pressing the Tab key. For example, if youtype l and press the Tab key, you see the following:# llaser less listres locale look lsaclast lesskey lkbib localedef lookbib lsattrlastb let lmorph locate lpq lsclatex lex ln lockfile lpr lsllbxproxy lha lndir logger lprm lynxld lightning loadkeys login lptest lzld86 lisa loadunimap logname lsldd lispmtopgm local logout lsaThe bash shell responds by listing all known commands beginning with the letter l (orany executable file in the current directory). This can be very handy if you can’t remembercomplex command names.The bash shell also has built-in help and lists all the built-in commands, as well as helpon each command. For example:# helpGNU bash, version 1.14.7(1)Shell commands that are defined internally. Type `help’ to see this list.Type `help name’ to find out more about the function `name’.Use `info bash’ to find out more about the shell in general.


Using the Shell 121A star (*) next to a name means that the command is disabled.%[DIGITS | WORD] [&]. filename: [ arg... ]alias [ name[=value] ... ]bg [job_spec]bind [-lvd] [-m keymap] [-f filena break [n]builtin [shell-builtin [arg ...]] case WORD in [PATTERN [| PATTERN].cd [dir] command [-pVv] [command [arg ...]]continue [n] declare [-[frxi]] name[=value] ......while COMMANDS; do COMMANDS; done { COMMANDS }To get help with a particular command, type the command name after the helpcommand. For example, to get help with help, type the following:# help helphelp: help [pattern ...]Display helpful information about builtin commands. If PATTERN isspecified, gives detailed help on all commands matching PATTERN,otherwise a list of the builtins is printed.The bash shell has several important files called resource, run configuration, andshell startup files. These files are used when you first log in to OpenLinux todefine or share predefined values or definitions, such as the type of terminal used, defaulteditor and printer, or location of executable programs. The /etc/profile initializationfile is used systemwide (for all users) to set options, such as environment variables (discussedlater) or to send a message (such as “Welcome to OpenLinux!”) when you firstlog in. You can also use a .bashrc login file in your home directory for personalizinghow your bash shell starts or handles different keystrokes (such as Backspace), and a.profile resource file (also in your home directory), which is used to tell your shellwhich resource file to use after you log in to OpenLinux.NEW TERMFor more information about the bash shell, there are a manual page, info pages you canbrowse with the info command, and documentation under the /usr/doc/bash directory.The Public Domain Korn Shell—pdkshThe pdksh, or public domain Korn shell, originally created by Eric Gisin, features 42built-in commands and 20 command-line options. This shell is found under the /bindirectory, but a symbolic link also exists under the /usr/bin directory.The pdksh shell is named ksh in your Linux system and like the bash shell, reads theshell initialization script /etc/profile if a file called .profile does not exist in yourhome directory. Unfortunately, this shell does not support the same command-lineprompts as the bash shell. However, this shell does support job control (discussed laterthis hour), so you can suspend, background, recall, or kill programs from the commandline.6


122 Hour 6This shell is nearly compatible with commercial versions of the Korn shell included withcommercial UNIX distributions. Documentation for this shell is in the ksh manual pageand in the pdksh directory (under the /usr/doc/pdksh directory).Features of the csh-Compatible Shell—tcshThe tcsh shell, by William Joy (and 47 other contributors), features 53 built-in commandsand 18 command-line options. This shell emulates the csh shell but has manymore features, including a command-line editor with spelling correction.This shell is not only compatible with the bash shell prompts; it offers more promptoptions than bash. tcsh uses the file csh.cshrc under the /etc/directory (much likebash’s /etc/profile) if the .tcshrc or .cshrc resource files do not exist in your homedirectory. Like the bash shell, you can scroll through commands you’ve entered and editthe command line.Get a list of the tcsh commands by using the builtins command (tcsh does not havehelp like the bash shell), as follows:# builtins: @ alias alloc bg bindkey breakbreaksw builtins case cd chdir complete continuedefault dirs echo echotc else end endifendsw eval exec exit fg filetest foreachglob goto hashstat history hup if jobskill limit log login logout ls-F nicenohup notify onintr popd printenv pushd rehashrepeat sched set setenv settc setty shiftsource stop suspend switch telltc time umaskunalias uncomplete unhash unlimit unset unsetenv waitwhere which whileFor more information about this shell, read the tcsh manual page, or look in the tcshdirectory under the /usr/doc/tcsh directory to see a Frequently Asked Questions (FAQ)file and other text files.zshThe zsh shell, originally created by Paul Falstad, is one of the largest shells for Linuxand features 84 built-in commands. The zsh shell has more than 50 different commandlineoptions and also emulates the sh and ksh shell commands.Like the bash and tcsh shells, the zsh shell enables you to scroll through previous commandsand complete, edit, or spell-check the command line. It also enables you to usejob control to manage running programs. This shell features advanced command-lineoptions for searching or matching file patterns.


124 Hour 6The examples used in the rest of this hour use the bash shell. If you want totry some of these command lines, type bash and press Enter at the commandline to use the bash shell. When finished, type exit, press Enter, and you’rereturned to your original shell.As a trivial example, you can use the file containing filenames created to build an archiveusing the cpio command. You do this by using the standard input to feed the file namesinto the cpio command:# cpio -o trash.cpio1 blockThis command line causes the cpio command to read a list of files from the standardinput, the trashfiles.txt file, and then creates an archive by sending its output throughthe standard output to a file called trash.cpio.The cpio command is used, like the tar and dump commands, to archive orback up OpenLinux files. See Hour 23, “Backing Up and Restoring YourSystem,” to learn how to use backup programs.Generally, most programs you run from the shell command line have the capability toread from the standard input and write to the standard output. Along with the standardinput and standard output, there is also a standard error output (which almost alwaysprints to your display). Using the previous example, if the list of files fed into the cpiocommand contains an error, the cpio command complains and sends an error message toyour screen:# rm -fr /tmp/trash/file3# cpio -o < trashfiles.txt >trash.cpiocpio: /tmp/trash/file3: No such file or directory1 blockOne of the existing files has been deleted, but the input file, trashfiles.txt, which stillcontains the list of files, is not changed. When you try to use the list as a valid input tobuild an archive, the cpio command complains and sends an error message to yourscreen (but still builds the archive).


126 Hour 6The end-of-file, or EOF, character is used to close the file and is entered byholding down the Ctrl key and pressing the D key. Add a new feature to this simpleeditor by using the


Using the Shell 127This creates a short address database. Test your database by typing db, followed by aname, city, state, or zip code, like this:# db debDebby, 275 Collins Ave., Vestal NY 13850The database works by using the egrep command to read the file until the end-of-inputstring zzzz. The -i command line option tells the egrep command not to distinguishbetween uppercase and lowercase characters. The $1 string is a shell variable (discussedin the next section) representing the command-line argument to be fed to the egrep command.Input and output redirection with the shell can be used in many different ways. This discussioncontinues and you’re introduced to shell variables and shown some handy tricksfor customizing your shell.Customizing Your ShellWhen you use a shell, you’re running the shell in an environment that containsenvironment variables. Environment variables are predefined values or pathnamesin various resource text files, found under your home directory and the /etcdirectory. For the bash shell, the default, systemwide environment variables are definedin the /etc/profile file, whereas personal settings can be found in the file .bashrc inyour home directory.NEW TERMThere are many different environment variables. Use the printenv or set command tosee a list of the variables currently in use:# printenv...PATH=/usr/local/bin:/bin:/opt/kde/bin:/usr/bin:.:/usr/X11R6/bin:/home/➥bball/binHOME=/home/bballSHELL=/bin/bash...This hour doesn’t list all the environment variables you might find defined for yourOpenLinux shell, but one of the most important is the $PATH variable. This variable tellsthe shell where to find executable programs. Without $PATH, you have to type the completepath, or directory hierarchy of a command, to run a program. For example, if youwant to run the ifconfig command to check the status of your network connections, youmight first try to type its name on the command line:6# ifconfigbash: ifconfig: command not found# whereis ifconfigifconfig: /sbin/ifconfig


Using the Shell 129Although this line might seem somewhat cryptic, this is the prompt string definition forthe $PS1 environment variable and is printed at the command line of your console or terminalwindow when you use a shell. You can change this string to define nearly any typeof prompt string. The preceding definition is in the following form:[username@host base_working_directory]$The bash shell has 15 different prompts (tcsh has 18, and ksh has 35) you can combinewith character strings to customize your prompt. For example, you can have the currentdate and time in your prompt. If you use the bash shell export command, you can testdifferent prompts from the command line:# PS1=’Date: \d Time: \t-> ‘;export PS1Date: Thu Dec 10 Time: 22:19:01->The time is updated each time you enter a command or press the Enter key. If you wantto have the shell’s name, along with the current directory in the command line, try the \sand \w prompt characters:# PS1=’\s:\w> ‘; export PS1bash:/usr/bin>You also can use different escape characters and terminal sequences to control the attributesof your prompt strings. You can use underlining, boldfacing, blinking, or othermodes for your prompt strings:# PS1=’[\033[4m\u\033[0m@\033[4m\h\033[0m]:’;export PS1[bball@localhost]:This example uses the proper escape sequences for the xterm X11 terminal (found withthe printenv command, and by looking at the $TERMCAP variable) to change the promptby underlining the username and hostname in the prompt. You can find these definitionsincluded in the file termcap under the /etc directory, and in the termcap manual page.For more examples and other prompt strings for specific shells, consult your shell’smanual page.Changing the prompt is only one way to customize how you work in your shell.You also can define command shortcuts, or aliases, to tailor how your favoritecommands work. You can find at least one or two aliases defined for your system in thebashrc file under the /etc/directory.NEW TERM6Systemwide alias definitions are entered by the root operator. You can put your own definitionin the .bashrc file in your home directory, but if you’re the root operator, youwant to put in at least these three for all your users:alias rm=’rm –i’alias cp=’cp –i’alias mv=’mv –i’


130 Hour 6These three aliases cause delete, copy, and rename (move) operations to be done interactivelyand provide at least some element of safety when deleting, copying, or moving(renaming) files. Without the -i, or interactive option, users might not think before deletingor overwriting files.You also can define aliases to build new commands or provide variations of familiarcommands to avoid typing long command-line options. For example, the ls commandhas many different options, but you can define several variations to make life easier.Some alias definitions you might want to try include the following:# list the current directory using color filenamesalias lsc=’ls -–color’# long format listingalias lsl=’ls –l’# show all files except . and ..alias lsa=’ls –AF’# show all file except . and .. in coloralias lsac=’ls -AF –-color’After you enter these changes into your .bashrc file in your home directory, you can usethe aliases by again using the bash shell’s source command:# source .bashrcNow you can type lsc, lsl, lsa, or lsac without adding the command-line options. Justmake sure that you don’t redefine an existing command! If you come up with somereally useful aliases, make sure they’re defined for each of the shells active on your system.Just because a shell is available on the system does not mean that a user can use a particularshell to log in. As the root operator, you can maintain a list of acceptable shells foryour system by editing the file shells under the /etc directory. As a default, the followingshells are listed for OpenLinux:/bin/bash/bin/sh (a symbolic link to the bash shell)/bin/ash/bin/tcsh/bin/csh (a symbolic link to the tcsh shell)/bin/ksh/bin/zshIf you don’t want your users to be able to use a particular shell, simply remove it fromthe list! If you try to change your shell with the chsh command to use a particular shellfor the next log in, the shell must be listed in the /etc/shells file. The chsh commandcomplains and quits without making any changes:


Using the Shell 131# chsh -s /bin/zshChanging shell for bball.Password:chsh: “/bin/zsh” is not listed in /etc/shells.chsh: use -l option to see listNote that this doesn’t restrict a user from running a shell after logging in. The only wayto effectively manage who can run a particular shell is to change a shell’s ownership orfile permissions (see Hour 22, “Handling Files and Your File System,” for details).Running Programs in the BackgroundMost shells also offer a way to start and then run programs as a backgroundprocess. Starting a command in the background means that the command continuesto run in memory while control of the shell’s command line is returned to your console.This is a handy way to get work done, especially if you are working on a separateterminal, have limited screen space when working in X11, or have lots of memory.Operations such as sorting large files or searching directories and other file systems aregood candidates for execution in the background.NEW TERMAlthough Linux offers virtual consoles when not working with X (accessed through theAlt and Function keys) and many X11 window managers offer separate desktops, you’llprobably run programs in the background many times while using Linux.Programs are run in the background from the shell command line by using the &, orampersand, operator at the end of a command. For example, to start another terminalprogram under X11, you want the program to run in the background so that your currentterminal is free for further input:# rxvt &This command starts the rxvt terminal, and your command-line prompt returns. The programis assigned a process number you can see using the ps, or process status, commandas in the following example:# ps...291 1 R 0:03 rxvt...6In this example, to keep the list short, not all the running processes are listed. You canstop the program by using the shell’s kill command with the program’s process number:# kill 291[1]+ Terminated rxvt


132 Hour 6Using the kill command is a crude way to control background programs. Thereis a more refined approach that uses other shell commands. Depending on yourcurrent shell, you can put running programs in the background, suspend the program,continue to run the program in the background, kill the program, or bring the programback to the terminal display. This is known as job control.NEW TERMIf you’re running the bash shell, put a running program into the background and suspendits operation by holding down the Ctrl key and pressing the Z key on your keyboard:# pine... program is running... (ctrl-z)...Pine suspended. Give the “fg” command to come back.[1]+ Stopped (signal) pine# fg.... program returnsIn order to be able to suspend the pine mail program, you must enable suspensionusing the pine configuration menu. While running pine, press the Skey to enter the Setup menu and then the C key to enter the Configurationmenu. Then, scroll through the options until you highlight “enable-suspend,”and press the X key to enable this feature. Next, press the E key toexit the configuration screen and then the Y key to save the changes. Youare now able to suspend the pine mailer.Sending a running program into the background and suspending its operation can be followedby the fg command to bring the running program back to your display or by thebg command to continue to enable the program to run. This can be handy if you want tostart a program, such as a newsreader (discussed in Hour 11, “Configuring InternetEmail,” and Hour 12, “Configuring Internet News”), and then suspend and continue torun the program during lengthy operations (such as updating an internal list of newsgroups)while you run other programs in the foreground.Using the bash shell, you can start, suspend, and run a number of programs and thenselectively bring a background program back to your display by the program’s job number:# pine... program is running (ctrl-z)...Pine suspended. Give the “fg” command to come back.


Using the Shell 133[1]+ Stopped (signal) pine# sc.... program is running (ctrl-z)...[2]+ Stopped sc# fg %1... pine program returns...In this example, the pine mail reader is started and then suspended in the background tostart the sc spreadsheet. Because pine is the first job suspended, the bash shell assigns ajob number of 1 to the mail program. The sc spreadsheet is then suspended, assigned jobnumber 2, and returned to the mail program by specifying its job number with the fg %1command.If you run and suspend many jobs in the background, you might not remember a programby its job number or remember which programs are suspended. You can get a listof the suspended programs by using the bash shell’s jobs command:# jobs[1] Stopped (signal) pine[2]- Stopped sc[3]+ Stopped emacs-nox# fg %sc... sc program is running ...This shows that there are three jobs, the pine mailer, the sc spreadsheet, and the emacseditor, currently suspended in the shell. Note that instead of restarting the sc spreadsheetjob by referring to its job number, the program is brought back to the foreground byusing the fg % command with the name of the suspended job.You also can stop programs using this same approach. Instead of using the ps commandto find a program’s process number and then issuing a kill command, you can use killwith the % operator:# kill %1[1]- Stopped (signal) pine# kill %emacs-nox6[3]+ Stopped emacs-noxHere you see how to use the kill command to stop a program by its number or name.This is much easier than using the ps command, especially if there are a large number ofprograms or other processes running in the background.


134 Hour 6Although not part of any shell, OpenLinux also includes the killall command,which you can use to kill processes by name. To use the previousexample, in which the kill command was used to stop the rxvt terminalemulator, instead of typing kill, followed by a process number, you canuse:# killall rxvtAfter you press Enter, the terminal emulator process is stopped, and thewindow disappears. The killall command also has an -i, or interactive,option you can use to selectively stop programs, or you can specify a processnumber to kill.Using your shell’s job control facilities is a powerful way to work efficiently with multipleprograms, especially if you use a single display or console. All the shells included onyour OpenLinux CD-ROM include job control in one form or another. In the next section,you’re shown another powerful way to use your shell to run multiple programs on asingle command line.How to Use PipesYou’ve already seen how to redirect the output of a program into a file and howto then redirect the contents of that file into another program. But you can do thisall at once without the use of a temporary file by using the |, or vertical bar, character,which is called a pipe. Using pipes to string commands together on the command line,called pipelining, is a quick and powerful way to enhance the power of individual commandsand represents a unique strength of Linux and other versions of UNIX.NEW TERMYou definitely use piped commands as you begin to learn how to use Linux. Not only dopipes save you time, but you can use different combinations of piped commands to tacklecomputing tasks particular to the way you work and the programs you run. At first, yourpipe commands might be simple, but as you gain confidence and understanding, you canconstruct fairly complex pipelines.Pipes work well under Linux because many commands are also filters, whichaccept some sort of input, optionally process or modify it in some way, and emitthe result as output to standard output or another command. Pipes can be used in nearlyany computing task and can be used to quickly find information, generate reports, transformdata, or view results. First, look at four simple examples:NEW TERM# ls | lpr# printenv | fgrep EDITOR# nroff -man mymanpage.1 | less# cat document.txt | wc | mail -s “Document.txt Report” bball


Using the Shell 135The first command line pipes a listing of the current directory through the line printercommand to print a report. The second example searches through a listing of your currentshell environment and prints the value of the default text editor. The third exampleprints the formatted output of a manual page to your display so you can browse the documentto check for errors. The last example pipes a text document through the word countcommand, wc, and then electronically mails a report on the number of characters, words,and lines in the document to the user bball.You can use pipes to confront and solve everyday problems not usually solved by individualprograms. This is one of the secrets and power of using the shell with OpenLinux!For example, if you have a lot of documents on your system but can’t remember whichdocument contains a certain phrase, you can find this information quickly. Instead of runningyour word processor and opening each file, you could try typing the following:# find /home -name *.doc | xargs fgrep administration | lessThis command line uses the find command to search the /home directory for all filesending in .doc and then pipes each file’s name into the xargs command. The xargscommand then runs the fgrep command to search for the word “administration” in eachfile and pipes the results through the less pager. You also can use pipes to not only findinformation, but to process data and create new files.# find *.doc | xargs cat | tr ‘ ‘ ‘\n’ | sort | uniq | tee dict | lessThe preceding command line builds a file called dict that contains a sorted list of uniquewords contained in all your word processing files. What do you call this type of file? Adictionary! To be honest, not all the dictionary words might be spelled correctly.This command works by piping each found file through the tr command, which translateseach character space into a carriage return to break the stream into one word perline. The stream of lines is sorted, and the uniq command removes all occurrences ofsimilar lines except for one. Notice that the tee command is also used to save the outputof the stream to a file.6The zsh shell contains some improvements on input and output redirection,so you might not need the tee command if you’re using pipes on the zshshell command line. See the zsh shell documentation for details.


136 Hour 6The tee command is used to save the results of a pipe at a particular juncture. This ishandy when you want to test your results when building pipes or save results in a complexpipe. Look at the following example:# xwd -out wd.xwd# xwdtopnm < wd.xwd | ppmtogif | tee wd.gif | giftopnm | tee wd.pnm |➥ pnmtotiff >wd.tifIn this example, a window dump graphic is created using the X11 xwd command, whichcaptures and saves the contents of an X window or desktop. Then, the xwdtopnm commandis used to convert this graphic into a portable bitmap graphic. The output of thexwdtopnm command is then fed into the ppmtogif command. The tee command is usedto save the output, in GIF format, to a file called wd.gif. At the same time, the GIF outputis converted back into the portable bitmap format by the giftopnm command, and thetee command is again used to save the portable bitmap as the file wd.pnm. Finally, thepnmtotiff command saves the portable bitmap file as a TIFF graphic. That’s one commandline and four graphic conversions!Using pipes with Linux is an easy way to get work done. As you continue to work withLinux, you can soon develop your own set of favorite command lines. When you developyour favorites, you can then build your own shell commands, which you’ll read about inthe next section.Building Shell ScriptsYou don’t have to be a programmer to write commands for Linux. After youbecome familiar with different programs and find yourself typing the same commandlines over and over, save these command lines into text files, and turn them intoshell scripts. In the simplest form, a shell script is simply one or several command linesyou frequently use. Look at the following example:NEW TERM# rxvt -geometry 80x11+803+375 -bg white -fg black -e pico &# rxvt -geometry 80x24+806+2 -bg white -fg black -e pine &These two command lines start the pico editor and the pine mail program in two X11rxvt terminal windows on the second desktop in an 800×600 pixel display. These certainlyaren’t command lines you want to type each time you want to run these programs.Although you can manually start the terminal windows after moving to the other desktop,it might take some time to correctly size the windows and then start the programs.Turn these command lines into an executable file by saving them into a file with yourtext editor, and then use the chmod command to make the file executable:# chmod +x d2


Using the Shell 137Now when you want to run these programs, all you have to type is the following, whichis certainly a heck of a lot easier:# d2You can make this new command even more flexible by using the shell variables $1 and$2, which represent the first and second command-line arguments to a shell command.Edit the file you created, and change the program names to these variables:rxvt -geometry 80x11+803+375 -bg white -fg black -e $2 &rxvt -geometry 80x24+806+2 -bg white -fg black -e $1 &Note that the order of the variables isn’t important. Now when you run your command,you can supply the program names on the command line as in this example:# d2 pine picoThis has the same result, but from now on you’re able to run nearly any program youwant in the terminal windows.This discussion of using the shell concludes with a simple shell script you can use tosafely delete files. There’s nothing special about the rmv script in Listing 6.1, but itdemonstrates some of the power of shell scripts.LISTING 6.1THE rmv SAFE DELETE SHELL SCRIPT#!/bin/bash# rmv - a safe delete program# uses a trash directory under your home directory## when run, always create a directory called .trashmkdir $HOME/.trash 2>/dev/nullcmdlnopts=falsedelete=falseempty=falselist=false# get any command-line optionswhile getopts “dehl” cmdlnopts; docase “$cmdlnopts” ind ) /bin/echo “deleting: \c” $2 $3 $4 $5 ; delete=true ;;e ) /bin/echo “emptying the trash...” ; empty=true ;;h ) /bin/echo “safe file delete v1.0”/bin/echo “rmv -d[elete] -e[mpty] -h[elp] -l[ist] file1-4” ;;l ) /bin/echo “your .trash directory contains:” ; list=true ;;esacdone6continues


138 Hour 6LISTING 6.1CONTINUED# d - delete any files found on the command lineif [ $delete = true ]thenmv $2 $3 $4 $5 $HOME/.trash/bin/echo “ rmv finished.”fi# e - empty the trash?if [ $empty = true ]then/bin/echo “empty the trash? \c”read answercase “$answer” iny) rm -fr $HOME/.trash/* ;;n) /bin/echo “trashcan delete aborted.” ;;esacfi# l - show any files in the .trash directoryif [ $list = true ]thenls -l $HOME/.trashfiThe first line of the script invokes the bash shell to run the script. After you type thisscript using your favorite text editor, make the script executable by using the chmod command:# chmod +x rmvThis script moves unwanted files to a directory called .trash in your home directory.When you’re sure you want to delete the files, you can then verify the files and emptythe trash. Because this script is supposed to act like a regular command, a short, built-inhelp command is included.If you want to try the rmv script, make sure you type it correctly or changethe line containing rm -fr $HOME/.trash/* ;; to rm -i $HOME/.trash/*;;, which is much safer than an unconditional delete. If you don’t type thisline correctly, you might delete your entire home directory!


Using the Shell 139The script works by first creating a .trash directory in your home directory (found withthe $HOME environment variable). If the directory exists, any error messages generated bythe mkdir command are discarded by sending the standard error output to the /dev/nulldevice. The /dev/null device is a handy place to send all complaints, as all input is discarded!This device (known as the ‘ol bit bucket) is also used when you don’t care aboutthe output of a program and want to hide the output from the display.. Four internalscript variables are then defined: cmdlnopts, delete, empty, and list.The script uses the bash shell getopts command to look at your command line for anyoptions. If a matching letter is found by the case statement, the script commands up untilthe two semicolons are executed. For example, if you want a reminder of how to use thescript, you can use the -h, or help, option:# rmv -hsafe file delete v1.0rmv -d[elete] -e[mpty] -h[elp] -l[ist] file1-4This prints a short help message because the script found the letter h on the commandline, and then printed the message using the echo command. To delete files, you mustuse the -d, or delete, command-line option:# rmv –d berries.jpg bowtie.jpg face.gifdeleting: berries.jpg bowtie.gif face.gif rmv finished.This deletes the three files by moving them to the .trash directory in your home directory.The -d option is detected on the command line, and the script then prints a message,echoes the file names back to your display, and sets the delete variable to true.Because the delete variable is changed to true, the mv command found in the if ...then statement is executed.You can verify that the files have been moved by using the -l, or list, option to see thecontents of your trash:# rmv -lyour .trash directory contains:total 36-rw-r--r-- 1 bball users 11967 Nov 6 14:18 berries.jpg-rw-r--r-- 1 bball users 14010 Nov 6 14:18 bowtie.gif-rw-r--r-- 1 bball users 8681 Nov 6 14:18 face.gif6As before, because the letter l is detected on the command line, the script sets the listvariable to true and then executes the ls command to list the contents of your .trashdirectory. If you’re sure you want to delete these files, you can then use the -e, or empty,command-line option:# rmv -eemptying the trash...empty the trash? n


140 Hour 6trashcan delete aborted.# rmv -eemptying the trash...empty the trash? y# rmv -lyour .trash directory contains:total 0The rmv script asks if you’re sure you want to empty the trash. If you type an n, thedelete is aborted. If you type a y, the trash is deleted. Because the letter e is found on thecommand line, the empty variable is set to true and the statements following the if ...then test line are run. The script prints a message to your display, and then, using theread command, waits for you to enter an answer. The answer is then tested, and if it isyes, the files in the .trash directory are deleted.Using the shell, you can quickly build simple programs to accomplish major tasks. Feelfree to improve this program by adding features or improving on how file names are handledat the command line. One such improvement might be to add the capability to handlewildcards or whole directories. Another improvement might be an interactive deletionof files. See the bash manual page for more information about other shell commands andoperators you can use in your own shell scripts.SummaryThis hour introduced just the basics of using a shell with OpenLinux. Don’t be intimidatedby the command line! Mastery of the intricacies and idiosyncrasies of using anyshell can take lots of practice. Make sure you practice safe computing: define aliases toforce potentially harmful commands to act interactively; think twice before using wildcardswhen deleting files; and never use OpenLinux as the root operator all the time. Themore you learn about OpenLinux, the more confidence you’ll have in tackling problemsand building custom solutions when using the shell.Q&AQ Help! I was using the shell, a program ran awry, and all of a sudden thescreen is full of garbage characters?A Try using the reset command. Chances are that your shell still understands yourkeyboard input. Type reset and press Enter to reset your terminal or console.


Using the Shell 141Q How can I get more information about bash?A Besides the bash manual pages, you can find at least three additional files of informationunder the /usr/doc/bash directory. You can also try searching yourfavorite bookstore for books about this shell.Q What’s the best shell to use with OpenLinux?A That’s a hard question to answer, as each shell has particular strengths or weaknesses.However, the bash shell seems to be the most popular, and it is the defaultshell for other distributions of Linux. Most OpenLinux users are quite happy withthis shell, and many shell scripts developed for Linux work with bash.Exercises1. Locate the default .bashrc settings for new users. Modify this file to include safealiases of the rm, cp, and mv commands.2. What file should you edit to add your own personal aliases?3. Modify the rmv script to change the location or name of the trash directory.4. If you use the -d option without any filenames on the command line, the mv command,through the rmv script, reports an error. How can you fix this?6


HOUR 7Using the X WindowSystemThe X Window System installed on your computer, as you learned in Hour3, “Configuring the X Window System,” is a port of X11 from the XFree86Project, Inc. This graphical interface includes about 3,500 files, with nearly200 programs (clients), more than 500 fonts, and more than 500 graphicimage files in nearly 50 megabytes of software. You can find almost everything(but not all files or programs) for X11 under the /usr/X11R6 directory.This hour shows you several ways to start X11, discusses some of the differentgraphical interfaces, or window managers, you can use during your Xsessions, and provides exercises for several terminal programs (or shell consoles)installed on your system. You’ll also learn about some basic operations,such as copying and pasting text, adjusting your mouse pointer orcursor shape, and doing screen captures. The last section shows you a samplingof X11 clients you might want to try.


144 Hour 7Note that many clients, such as text editors, graphics programs, and evenother X11 window managers, are discussed throughout this book.Starting XWhen you first log in to OpenLinux, you see a short message like this:Welcome to your OpenLinux system!You can start X11 with ‘startx’ or KDE with ‘kde’.The startx and kde commands are almost identical shell scripts used to start an X11session. startx is found under the /usr/X11R6/bin directory, whereas kde is foundunder the /opt/kde/bin directory. To start an X11 session using the fvwm window manager(discussed later this chapter in the section “X11 Window Managers”) with theLooking Glass desktop client, type startx on the command line of your console, andthen press Enter, like this:# startxIf you properly configured X11 to work with your computer’s graphics card (asdescribed in Hour 3), your display clears, and after a few seconds, the X11 desktopappears, as shown in Figure 7.1.FIGURE 7.1The fvwm X11 windowmanager with theLooking Glass desktopclient is one of severalways to use X withOpenLinux.


Using the X Window System 145To start an X session using the K Desktop Environment (discussed in Hour 8, “Exploringthe K Desktop Environment), type kde at the command line, and press Enter, like this:# kdeThe screen clears, and you soon see KDE’s default desktop appear, as shown inFigure 7.2.FIGURE 7.2The KDE desktop is acomplete X11 environmentand includesnearly all the featuresof a modern graphicalinterface.Starting X11 with Different Color DepthsWhen you start an X11 session with kde or startx, X11 uses 256 colors, or eight-bitplanes (one byte, or eight bits per pixel). To start an X session using 16-bit planes (ortwo bytes, or 16 bits per pixel), use the -bpp option, followed by 16, like this:# startx -- -bpp 16or# kde -- -bpp 16The -bpp 16 option is passed on to the X server you selected when configuring X as anoption to use 64,000 colors. Other color depths, such as 24 or 32, might be possibledepending on the capabilities of your graphics card and how you configured your7


146 Hour 7XF86Config file. Although XF86Config, found under the /etc directory, is described inmore detail in Hour 3, the pertinent part of this file is in the Screen section. A sample isshown in Listing 7.1.LISTING 7.1TYPICAL XF86CONFIG SCREEN SECTIONSection “Screen”Driver “svga”Device “NeoMagic”Monitor “Generic Multisync”Subsection “Display”Depth 8Modes “1024x768” “800x600” “640x480”# Virtual 1024 768EndSubsectionSubsection “Display”Depth 16Modes “1024x768” “800x600” “640x480”EndSubsectionSubsection “Display”Depth 24Modes “800x600” “640x480”EndSubsectionEndSectionNote the “Display” subsections in the listing (for a NeoMagic video graphics display).Each subsection starts with a Depth setting, and then lists different Modes, or resolutions.The Depth setting sets the display depth, or number of colors for the X session. If youalways use X with 64,000 colors at a resolution of 800∞600 and don’t want to have totype -- -bpp 16 every time you start X, edit your XF86Config file and simply use a“Screen” section, like this:Section “Screen”Driver “svga”Device “NeoMagic”Monitor “Generic Multisync”DefaultColorDepth 16Subsection “Display”Depth 16Modes “800x600”EndSubsectionEndSectionThe Modes line tells the X server to use a particular number of dots per inch horizontallyand vertically. Your selected X server automatically uses the first available mode value(such as 800∞600) which matches corresponding mode lines in your XF86Config file. InListing 7.1, if all modes are valid, your X session starts with eight bits per pixel and a


Using the X Window System 147display that is 1024 pixels wide and 800 pixels high. To switch to a lower resolution ormode during an X session (such as going from 1024×768 to 800×600), pressCtrl+Alt+KeyPad-. That is, press Ctrl+Alt, and then press the minus (-) key on your keyboard’skeypad. To switch to a higher resolution, press Ctrl+Alt+KeyPad+.The Virtual line in Listing 7.1. enables you to have a display larger than the physicalarea of your screen. This is handy if your computer’s graphics card and monitor onlysupport a lower resolution, such as 800×600, but you need to run an X11 client (program)at a higher resolution, such as 1024×768. The Virtual line in Listing 7.1 is disabledwith a pound (#) sign, but you can enable it by removing the pound sign and thenrestarting X. Your display is then a scrolling window and moves about the larger, virtualdisplay when your mouse pointer is dragged beyond the edge of the screen.Unfortunately, some X clients, such as the graphics drawing xfig or thearcade action game xboing, require larger display areas. Your screen resolutiondepends on how well your graphics card is supported by a particular Xserver, how much video memory is installed on your graphics card, the resolutioncapabilities of your computer’s monitor or laptop’s screen, and howyou have configured your XF86Config file. You cannot, for example, use a1024×768 display on a laptop that only supports a resolution of 800×600,but you might be able to use a virtual resolution of 1024×768 or greater ifenough video memory is installed.Using Virtual Consoles with X11Although you can get to a shell command line during an X session when you usea terminal client, such as rxvt (discussed later this chapter in the section “UsingX11 Terminal Programs”), you can also get to a OpenLinux console when using X onyour desktop computer. OpenLinux supports six different virtual consoles, or loginscreens. When you don’t use X, you can get to six different login prompts by pressingAlt+FX, where X is F1 through F6.NEW TERMFor example, when you first log in to OpenLinux, you’re at the first virtual console. Afteryou log in, press Alt+F2. You then see another login prompt, and you can log in asanother user or start another OpenLinux session. To get back to your first login screen,press Alt+F1.7


148 Hour 7When you log in to OpenLinux and start an X11 session with startx or kde, X,bydefault, uses a seventh virtual screen. Because you started X from the first virtual console,this console is unavailable for use. However, you can get to another virtual console,such as the second, by pressing Ctrl+Alt+F2. You then see the OpenLinux login prompt.To go back to your X session, press Alt+F7. Using this approach, you can go back andforth between your X session and different consoles.Starting Multiple X11 SessionsNot only can you use multiple virtual consoles with OpenLinux during an X session, youcan also start and use multiple X consoles during an OpenLinux session. This means thatyou can log in, start X using one window manager at a particular color depth, and thengo to a different console, log in, and start another X session using a different windowmanager and color depth. Then, during your X session, switch between different consolesand X window managers!Here’s a step-by-step example that shows how to log and use the startx and kde commandsat the same time:1. Start OpenLinux and log in. At the command line, start an X session with KDEusing 256 colors with:# kde2. Press Enter to start the X session (which uses the seventh virtual screen).3. After the KDE desktop appears, press Ctrl+Alt+F2. You’re at the second virtualconsole and an OpenLinux login prompt. Log in to OpenLinux again.4. At the command line, use the startx command to start an X session using 64,000colors with the fvwm window manager and the Looking Glass desktop. Include the:1 and vt8 command-line options to start a second X11 session named :1 usingthe eight virtual screen, like this:# startx -- :1 -bpp 16 vt8The screen clears, and the fvwm and Looking Glass desktop appears (like the oneshown in Figure 7.1).The Looking Glass desktop is an X11 client used to provide a graphical workspaceduring your X11 sessions. The Looking Glass client appears by defaultwhen you use startx to start an X session. When the desktop appears, clickthe Caldera or Netscape icon to read the Looking Glass manual. You can findall the information you need to use this client with X.


Using the X Window System 1495. To go to your KDE session, press Ctrl+Alt+F7. To go to another virtual console,press Ctrl+Alt+F3 (because the first and second are being used). To go back tofvwm, press Ctrl+Alt+F8.Logging in to OpenLinux and X11 with xdmThe default configuration of OpenLinux is to boot Linux to a login prompt for aconsole, or shell command line. You can, however, boot OpenLinux directly to anX11 login prompt. This can be done by passing a kernel message, or boot-prompt option,through the LILO boot prompt or by configuring OpenLinux to start X11 and the xdm, orX display manager client, after booting.NEW TERMYou must properly configure X for your computer’s graphics card before tryingthis, or you can lock up your system!To boot directly to the xdm login screen, turn on your computer, and at the LILO bootprompt, type the following:linux 5After you press Enter, Linux boots and presents the xdm login screen, as shown in Figure7.3. This method works by booting OpenLinux directly to a particular run level, as specifiedin the OpenLinux system initialization table, inittab, under the /etc directory. Runlevel 5 is defined in /etc/inittab as follows:x:5:respawn:/usr/bin/X11/xdm -nodaemonThis line specifies that when OpenLinux is started, the login prompt is provided by xdm.To start your X session (which uses fvwm by default), type your username, press Enter,then type in your password, and press Enter again.To configure OpenLinux to boot directly to this login screen, log in as the root operator,and then open /etc/inittab with your favorite text editor. Scroll through the file untilyou see the following:# Default runlevel.id:3:initdefault:Editing your system’s initialization table is inherently dangerous! Make abackup copy first, and make sure to disable line-wrapping (such as using the-w option with the pico editor) when editing this file.7


150 Hour 7FIGURE 7.3The xdm client is the Xdisplay manager andprovides a loginprompt to X.The initdefault line tells OpenLinux what run level to use by default. To boot directlyto the xdm login screen, change the 3 to a 5, like this:id:5:initdefault:Save the file, exit your text editor, and either use the command /sbin/telinit 5 orreboot OpenLinux with the shutdown command. When you reboot to OpenLinux, yousee the xdm screen, as shown in Figure 7.3.A nice alternative to xdm is the K Display Manager, or kdm. This client offersmore login choices and configurations than the stock xdm client. For detailsabout how to configure kdm, see the section “Configuring kdm” in Hour 8.X11 Window ManagersOne of the great things about X11 is that you have freedom of choice in how youwant to manage your windows and programs on your screen. All the hard workof screen management is done by a window manager, which is simply another X11 programor client. Of course, you don’t have to use a window manager with X. For example,create a file called .xinitrc in your home directory with a single line:NEW TERMxterm


Using the X Window System 151Then use the startx command. This starts X11, but you only have a single terminal windowwith no window borders, scrollbars, buttons, or colors. The computing life in X isvery drab without a window manager!Although freedom of choice is good, one of the bad things about X11 is the possiblyconfusing choice and complexity of window managers: you might be initially overwhelmedby the array of configuration files, scripts, or resource settings.Configuring the fvwm Window ManagerThe fvwm window manager, by Evans and Sutherland Computer Corporation, theMassachusetts Institute of Technology, and Robert Nation, builds on an earlier windowmanager named twm. This window manager is used by default when you start an X sessionwith the startx command and provides elements common to many window managersfor X:●●●●●●●Hierarchical root menus (menus and submenus)Graphics icons (when minimizing a window)3D window buttons (using shading and color)3D scrollbars (draggable and shaded)Customizable display colors and screen elementsWindow manager modules (for icon docks, pagers, and so on)Virtual desktops (multiple screens)Although there is a fvwm configuration file, system.fvwmrc, in the/etc/X11/fvwm directory, the major elements of this window manager are foundin the wm1_modules directory under the /usr/X11R6/lib/X11 directory. Configurationand management of fvwm (and other window managers) is through a series of macro andconfiguration files under the /etc/X11/wmconfig directory that have been processed bythe wmconfig (window manager configuration) command. Settings for menus, colors,borders, keyboard values, and other aspects of window management are processed andbuilt from these files when you start an X11 session using fvwm (and other window managers).This is a complex system but one that provides a rudimentary form of sessionmanagement, or the capability to save settings for use in the next X11 session. Thesefiles are listed in Table 7.1.NEW TERM7


152 Hour 7TABLE 7.1NameAfterStep.M4Common.M4Fvwm1.M4WmConfigdeskrcrc.bindingsrc.configrc.functionsrc.goodstuffrc.menusX11 MACRO AND CONFIGURATION FILESrc.menus.excluderc.modulesrc.optionsrc.stylesxinitrcxsessionrcDescriptionMacros used by the AfterStep window managerMacros and definitions for all window managersMacros used for the fvwm window managerMacros used to reconfigure a window manager’s settings following arestartStartup functions for the Looking Glass clientMacro definitions about how to process configuration filesMouse and keyboard settingsBackground and display font settingsSpecialized mouse and window-handling functionsIcon and application-launching definitionsMenu definitionsClients excluded from menusModule definitions for windows and pagersWindow colors, focus, icons, appearance, placement, decoration, andpager sizeWindow decorations and icon assignmentsInitial setup and settings for starting an X sessionSetup and settings used by xdm when starting an X sessionFor the best overview of how the wmconfig command works, read the file Fvwm-Config-Dokumentation.en.txt under the /usr/doc/wmconfig directory.Fortunately, you do not (and probably should not) edit these files. The settingsand interaction of the macro definitions are quite complex. Unless youknow exactly what you’re doing, leave these files alone.You can change how fvwm displays information through the use of numerousconfiguration menus in the root display. These menus, accessed by pressingAlt+C (or Alt+Shift+C) in a blank area of the desktop, enable you to changemany of the following:


Using the X Window System 153●●●●●●●Fonts for windows, icons, and menusWindow colors (background and foreground)Focus policy (clicking in a window to activate it, or moving the cursor over it, andso on)Set how windows are handled and appearSet the default window manager to useSet the location of modules, icons, or desktop buttonsSet which modules, icons, or desktop buttons appearTo save your settings, you must first select the Enable Autosave Topics item of the desktopmenu. Press Alt+C in a blank area of the desktop. A menu appears, as shown inFigure 7.4.FIGURE 7.4You must first enableconfiguration savingwith the fvwm configurationmenu beforeyou can save X sessionsettings.Click the Enable Autosave Topics item of the desktop menu. You can then change differentsettings through the Config menu. When you finish, again press Alt+C. You see thatthe Config menu has changed and now has a Save Desktop item, as shown in Figure 7.5.FIGURE 7.5Save your windowmanager’s settingswith the Config menu’ssave options.7


154 Hour 7Click the Save Now menu item to save your changes (they are put in the files desk andrc.config in the .wmconfig directory in your home directory.)You can start different X11 clients from the command line of a terminal window orthrough fvwm’s root menu. To use this menu, move your mouse cursor to a blank area ofthe desktop, click your left mouse button, and scroll down to a desired group of programs,as shown in Figure 7.6.FIGURE 7.6Use fvwm’s root menusto launch different X11clients.If you accidentally click the Disable Looking Glass menu item in the rootConfig menu, you can always start Looking Glass by typing lg& in the commandline of a terminal window.The fvwm window manager also supports numerous keyboard commands to control themouse pointer, menus, and the currently active window. Using these commands, it ispossible to control windows or the mouse and select menu items without lifting your fingersfrom the keyboard. Table 7.2 lists some of the more common commands.TABLE 7.2 COMMAND fvwm WINDOW AND POINTER KEYBOARD COMMANDSCommandDescriptionAlt+APops up Applications menuAlt+CPops up Config menuAlt+DPops up Desktop menuAlt+EscDisplays graphic list of windows


Using the X Window System 155CommandAlt+FAlt+GAlt+HAlt+IAlt+PAlt+RAlt+SAlt+TAlt+TabAlt+VAlt+XAlt+YCtrl+Alt+down arrowCtrl+Alt+left arrowCtrl+Alt+right arrowCtrl+Alt+up arrowCtrl+down arrowCtrl+left arrowCtrl+right arrowCtrl+up arrowShift+Alt+TabShift+Ctrl+Alt+down arrowShift+Ctrl+Alt+left arrowShift+Ctrl+Alt+right arrowShift+Ctrl+Alt+up arrowDescriptionPops up Graphics menuPops up Games menuPops up Help menuPops up Internet Connectivity menuPops up Productivity Tools menuPops up Amusement menuPops up Shells menuPops up Terminals menuActivates next windowPops up Software Development menuPops up Text and Publishing menuPops up System administration menuMoves pointer down 100 pixelsMoves pointer left 100 pixelsMoves pointer right 100 pixelsMoves pointer up 100 pixelsMoves active window down to next desktopMoves active window to next left desktopMoves active window to next right desktopMoves active window up to next desktopActivates previous windowMoves pointer down 1 percent of screenMoves pointer left 1 percent of screenMoves pointer right 1 percent of screenMoves pointer up 1 percent of screenIf you like the fvwm window manager, you might also want to try AfterStep, a sophisticatedcustomization of fvwm’s configuration files.Starting AfterStepThe AfterStep window manager, by Frank Fejes, Alfredo Kenji Kojima, and Dan Weeks,provides window management, controls, and other features similar to the commercialNEXTSTEP operating system (see Figure 7.7). These features include the following:7


156 Hour 7●●●●●●3D, configurable iconsA “Wharf,” or icon dock, for launching X11 clientsPop-up, multiple icon menusWindow shade-type window controls (double-click a window’s title bar to draw theshade up or down)Sophisticated title bars, buttons, and other decorationsStyled, pop-up root menusFIGURE 7.7The AfterStep windowmanager providessophisticated windowcontrols, icons, and anapplication “Wharf”for your X sessions.You can use AfterStep as the default window manager through the Default WM menuitem in the root display Config menu. AfterStep uses the same menu and desktop configurationscheme as fvwm, so you can make changes to your desktop and save the settingsfor future use (changes are reflected in the rc.config file in the .wmconfig directory inyour home directory).Starting the twm Window ManagerThe twm, or Tab window manager, found under the /usr/X11R6/bin directory, is one ofthe original window managers for the X Window System. The twm client, developed byTom LaStrange and other authors, provides the most basic window operations, such aswindow titles, icons, root window menus, and other custom mouse or keyboard commands.Figure 7.8 shows a typical twm window management session.


Using the X Window System 157FIGURE 7.8The twm, or Tab windowmanager, providesbasic X11 desktop displayswith programlists, icons, and windowcontrols.Start this window manager, like the others, by clicking the Default WM menu item in theroot display Config menu. However, twm does not use the same menu and desktop configurationscheme as the fvwm or AfterStep window managers. If you make twm thedefault window manager, you can’t go back to using any other manager until you edit therc.config file in the .wmconfig directory in your home directory! Open this file withyour favorite text editor, and look for the WINMGR setting, like this:WINMGR=”twm”You can delete this setting or change it to another window manager, like this:WINMGR=”afterstep”Save the file, and restart X11 to use the new window manager. The configuration file forthe twm window manager, system.twmrc, is found in the /etc/X11/twm directory. Ifyou’re the root operator, you can customize this file to support features and programs ofyour system for all users. If you want to make your own custom twm features, copy thisfile as .twmrc, and save it in your home directory.X11 Terminal ProgramsX11 terminal clients provide a console with command-line access to the shell. Althoughyou don’t need to use a terminal during your X sessions, it might be a good idea to keep7


158 Hour 7at least one open (or iconified) so you can start other programs. Having several windowsopen at one time is also a convenient way to learn new commands because you can havethe manual page displayed in one window while you try out the program in another window.You can also use multiple terminal windows to copy and paste information betweenprograms.This section introduces you to several terminal programs you might want to use withX11: cmdtool, rxvt, xterm, kvt, and kterm. Table 7.3 lists these various terminals.TABLE 7.3 X11 TERMINAL CLIENTS INCLUDED WITH OPENLINUXNameDescriptionansi-xtermcmdtoolcolor-xtermktermkvtrxvtxtermxterm-colorSymbolic link to xterm-colorTerminal window emulator included with Sun’s OpenWindowsSymbolic link to xterm-colorMultilingual terminal emulatorMenu-enabled X11 terminal included with KDEMemory efficent, color-capable terminalStandard X11 terminal included with XFree86Shell script to run xterm as a color terminal (using the xterm-16color entryin the /etc/termcap database)Changing the xterm Terminal SettingsThe xterm client is a color-capable terminal emulator. When started, it displays an openwindow with a command line. You can run programs, do word processing, or performnearly any function you normally do when you aren’t running X11. Like most X11 terminalemulators, xterm features a resizeable window. Depending on the window manageryou use, buttons on the window’s title bar enable you to move, size, minimize, ormaximize the window and might enable you to close or kill the window and any runningprograms started from the window. If you minimize an xterm window, an icon mightappear on the desktop or be placed in an icon dock or taskbar, depending on the windowmanager.If you start xterm from another terminal, you can choose how and where to initiallydisplay the new window through the use of command-line options calledX11 Toolkit options. These are discussed in the section “Learning X11 Basic Operations”later in this hour. One feature xterm shares with the kvt terminal emulators is the capabilityto change fonts on-the-fly.NEW TERM


Using the X Window System 159For example, if you want your terminal to use a larger or smaller font, all you have to dois move the cursor inside the terminal window, hold down the Ctrl key, and press theright mouse button. A menu called VT Fonts with a list of sizes pops up from which youcan select larger or smaller sizes.One really great feature of xterm’s VT Fonts menu is the Selection option.Here’s how it works: First, run the xterm client, and then start the xfontselclient from the command line. The xfontsel client displays different fonts inmany variations, and you can see the effects of different point sizes or orientationon a selected font. After you find an extremely readable font foryour display, click the Select button at the top of the xfontsel window.Then, move your mouse cursor to the xterm window, hold down the Ctrlkey, press the right mouse button, and select the VT Fonts menu itemSelection. Voilà! Your xterm window now uses the font you selected withthe xfontsel client. This is handy for finding the best typeface to use foryour terminal.Although nearly all terminals support scrolling, not all terminal emulators have nicelydrawn scroll bars. You can control whether scrolling is enabled and scroll bars are visibleby holding down the Ctrl key and pressing the middle mouse button (for two-buttonmouse users, make sure you enable three-button emulation and depress both mousebuttons).If you don’t need all these features or need more memory to run programs, you mightwant to use the rxvt terminal emulator, discussed next.Using the Memory-Efficient rxvt TerminalThe rxvt client, or terminal emulator, is a color-capable X11 console window withfewer, but possibly more useful, features than the xterm client, including the following:●●●●Smaller size, so this client uses less memory or swap spaceColor-capable terminal emulatorSupports limited X Toolkit command-line optionsDoes not have Tektronix 4014 emulation, which is not really needed for standaloneLinux X11 workstationsrxvt supports at least one of the same command-line options as xterm—the -e optionto run programs in a standalone X window. The -e option is useful if you want to run7


160 Hour 7programs under X that are normally run from a nongraphical environment (the console),for example:# rxvt -e pico &This command line runs the pico editor (part of the pine mail program) in a standalonewindow. You can create, open, edit, and save files, but when you quit the pico editor, thewindow disappears. This is a great way to run interactive console programs under X.The rxvt client also supports a number of X Toolkit options, as you’ll see in the nextsection. By using these options, you can start your rxvt terminal at any location of yourdesktop, with any available font, and with a selection of foreground and backgroundcolors.Learning X11 Basic OperationsA number of basic operations are important for you to know about when using X11 andX11 clients. Many programs accept similar command-line options, so you can customizethe size, color, and placement of client windows. This section introduces you to some ofthe more common command-line options and shows you how to use them.Not all X11 clients support the same X11 options, known as X Toolkit command-lineoptions. For a full discussion of these options, see the X manualpage found under the /usr/X11/man/man1 directory or an individual client’smanual page for details.Using X11 Client Geometry SettingsYou can use the geometry option, usually in the form of -geometrywidthxheight+xoffset+yoffset, to manage how and where your client’s window isdisplayed.For example, if you want to start an rxvt terminal in the upper left corner of yourscreen, you use the following:# rxvt -geometry 80x25+0+0 &This command starts an 80 character, 25 line rxvt terminal, and places its window at theupper left corner of your display. Here’s a neat trick: If you are using a virtualwindow[nd]capablewindow manager and have several desktops available, you can startterminal emulators not only in your current desktop, but also in other desktops.


Using the X Window System 161For example, if your current desktop is 800∞600, you can easily start other X11 clientsin adjacent desktops by specifying the x and y offsets, as follows:# rxvt -geometry 80x25+801+0# rxvt -geometry 80x25+0+601The first command line starts another terminal window, but at the upper left corner of thedesktop immediately to the right. The second command line starts another terminal window,but at the upper left corner of the desktop immediately below. This is a handy featureto use if you want to set up not only your desktop, but others before you start X11.Using this approach, you can start word processing in one desktop, a Web browser inanother, and a graphics program in a third (assuming you have enough memory).Geometry specifications are useful for building organized, working screensfrom the command line. Build your desktop, starting clients from the commandline or resizing windows, and then use the Save Desktop feature ofthe root display menu to save your window settings.Setting Background and Foreground Colors for X11ClientsYou can also usually set the background and foreground colors of a terminal’s windowwith the -bg and -fg color command-line options. You can find a list of colors supportedby the XFree86 X11 servers in the file rgb.txt in the /usr/X11R6/lib/X11 directory.For example, to start the rxvt terminal emulator with a red background with yellow textfor the foreground, you use the following:# rxvt -bg red -fg yellowIf you’re not using X11 in the 8-bpp (8-bits per pixel) mode (256 colors) with theXF86_SVGA server, you find a more limited selection of colors available. For example,you only have 16 colors available if you use the XF86_VGA16 server or black and white ifyou use the monochrome server, XF86_Mono. You can also try to see the available colorsby using the xcolorsel client or xcmap client, which displays the colors in a grid andgives the rgb (red, green, and blue) values of the color in base 16, or hexadecimal. (Seethe X, xcolorsel, and xcmap manual pages for more information.) Another program totry is the showrgb client, which automatically lists the contents of the rgb database,rgb.txt.7


162 Hour 7Other color options include -bd for color choices of window borders and the -rv and +rvreverse video modes, which are useful for monochrome displays.Setting X11 Client ResourcesThe X Window System also supports further client configuration through the use ofclient resources. These are text files that contain settings for different aspects of how aclient looks or runs. You might also be able to set different resources of a client programwhen it first starts by using the -xrm command-line option to specify a resource string,but most programs only use a resource file.In order to change resource settings, you need to know what resources an X11 clientuses. You can find this information by either reading the program’s manual page or lookingfor any installed settings in a file with (but not always) the client’s name in the appdefaultsdirectory under the /usr/X11R6/lib/X11 directory, as follows:# ls -A /usr/X11R6/lib/X11/app-defaultsAxe Pixmap.No3d XLogo XconqAxinfo Rosegarden XLogo-color Xconq-colorBeforelight Rubik XMailbox XditviewBitmap Seyon XMixer Xditview-chrtrBitmap-color Seyon-color XPaint Xditview.No3dBitmap.No3d Seyon.No3d XPat XeditChooser Skewb XPat.No3d XfdChooser.No3d Triangles XPlaycd XfmClock-color Velvet.ad XPlaymidi XgcCoolmail Velvet.ad.No3d XPostitPlus Xgc.No3dCubes Viewres XPostitPlus.No3d XgopherDino Viewres.No3d XRn Xgopher-colorEditres XBlast XScreenSaver XloadimageEditres-color XCalc XShowimf XmagEditres.No3d XCalc-color XShowimf-color XmanFig XCalc.No3d XSm Xman.No3dFig-color XClipboard XSok XmessageFreeciv XClipboard.No3d XSok.No3d Xmessage.No3dGV XClock XSysinfo XmhGXditview XConsole XSysinfo-color Xmh.No3dGhostview XDaliClock XTar XmineGhostview.No3d XDbx Xterm XosviewHMan XEvil Xterm-color XtartanHexagons XFontSel XTrojka XtetrisKTerm XFontSel.No3d XWatch Xtetris.bwKnews XFrisk Xarchie Xtetris.cML XGammon Xbl XvidtuneMball XGetfile XbmBrowser netscape.cfgMlink XISDNLoad XbmBrowser-color xnwdsadminPanex XLoad XcolorselPixmap XLock Xcolorsel-color


Using the X Window System 163You can see that there are quite a few files with application default settings but that notall of the more than 370 programs for X11 installed on an OpenLinux system have settingsinstalled. Each file contains resource strings for a particular X11 client. Theresource strings can provide not only information that determines how a program is displayed,but the contents and handling of menus, buttons, or other parts of a program.You can use X11 resource strings in the file Xdefaults in your home directory.Resource and configuration settings for selected KDE clients are storedin the .kde/share/config directory in your home directory.The format of resource strings is defined in the X manual page, but many X11 clientmanual pages list different resources with examples for a particular client. For example,if you look at the resource settings for the xpaint drawing program’s main toolbox (containedin the file XPaint in the /usr/X11R6/lib/X11/app-defaults directory), you seethe following values:...!! The top level operation/toolbox menu!XPaint.width: 232XPaint.height: 350...These values tell the xpaint client to draw a vertical toolbox. If you want a horizontaltoolbox instead, you can resize the toolbox, note the dimensions shown by the windowmanager during the resize operation, and use the new settings to change the initial sizeof the toolbox in its default resource settings file, for example:...! The top level operation/toolbox menu!XPaint.width: 702XPaint.height: 122...For details about X resources, see the X man page. For details about different clientresources, see the program’s manual page or other documentation.7


164 Hour 7Make sure your changes reflect your supported screen size, or programsmight start off-screen or with windows too large to be useful. Always usethe exclamation character for comments, and if you edit the default, or originalapplication resource file, copy the original settings first to a commentline.Changing X11 Mouse and Cursor ModesWhen you use X11, you might want to change the way your mouse works or switch theorder of the mouse buttons. This is especially handy if you’re left-handed or if yourmouse responds differently from the desired setup. You can also change the type of cursorused by your window manager.To change your root window cursor, you need to know what cursors are available. Youcan find a list of cursors in the cursorfont.h file under the /usr/X11R6/include/X11directory, for example:...#define XC_exchange 50#define XC_fleur 52#define XC_gobbler 54#define XC_gumby 56#define XC_hand1 58#define XC_hand2 60#define XC_heart 62#define XC_icon 64...As you can see, many types of cursors are listed in this file. Knowing these differenttypes of cursors, use the xsetroot client, or root window utility program, to set your rootcursor image, for example:# xsetroot -cursor_name hand1This changes the root cursor to look like a right-pointing hand. If you are left-handed,you might want to use the left-pointing hand2 cursor!An easy way to see all the cursors is to use the xfd, or X11 font display,client found under the /usr/X11R6/bin directory. Used with the -fncommand-line option, the xfd client displays the entire character set ofthe cursor font, cursor, located in the /usr/X11R6/lib/X11/fonts/miscdirectory.


Using the X Window System 165If you find the left and right mouse buttons inconvenient, change how these buttonsare ordered on your mouse by using the xmodmap client (which can also change keyboardkeys). For example, to reverse the order of your mouse buttons, you can try thefollowing:# xmodmap -e “pointer 3 2 1”This example, from the xmodmap manual page, can help left-handed users.The xmseconfig client, which is part of the XF86Config setup program forXFree86, is a graphical mouse configuration utility. However, it does notreorder mouse buttons, and you must run the client as the root operator inorder to save any changes.You can also customize other mouse settings using the xset, or user preference, client.For example, if you want to speed up your mouse acceleration, or how fast it travelsacross the screen, you can try these settings:# xset m “40 4”If this is too fast for you, try the following:# xset m “4 8”Experiment with different settings. You can really slow down your mouse with the xsetm “0 1000” command line. See the xset client manual page for other X11 settings youcan change, and see if some of them work with your system.How to Copy and Paste in X11Copying and pasting information in X11 involves transferring text between terminal windowsor graphics from one X11 client to another. For example, you can use the xmag programto select a portion of your desktop and then paste the copied graphic into an openxpaint drawing window (see Hour 16, “Graphics Tools”). To do this, first run thexpaint client, go to the File menu, and select New Canvas. Then start the xmag client.You see a tiny corner cursor. If you click an area of the screen you want to magnify, thexmag client displays the selection in a window. You then move your cursor to the xpaintdrawing window, go to the Edit menu, and select Paste. Your selected graphic is pasted inthe xpaint window.7


166 Hour 7Copy and paste operations using KDE are quite different. KDE-aware applicationsfully support copy and paste operation using Copy and Paste menuitems from each client’s Edit menu.If you’re running a word processor in one window and the command line in another terminalwindow, you can copy and paste text between the windows. Both the xterm andrxvt terminals support copy and paste operations using your mouse cursor and mousebuttons. To copy text, you must first highlight the desired text. If you just want a word,double-click the word with your left mouse button. If you want a line of text, triple-clickthe line. If you want more than a word or a line, you need to highlight regions of text.Text regions in terminal windows can be selected in two ways (depending on the capabilitiesof your X terminal client). Move your cursor to the beginning or end of the text, andthen drag up or down with the left mouse button held down to highlight the selected text.You can also click at the beginning of the text with your left mouse button and then,holding down the Shift key, click at the end of the text to highlight a selection.After you highlight text, there are also two ways to paste the selection in another window.One way is to click in the desired window, hold down the Shift key, and press theInsert key. The other way is to click in the window and then press the middle mouse button(or the left and right mouse buttons simultaneously if you’re using a two-buttonmouse to emulate three buttons).The xcutsel client also copies from one window to another. When you run this client,you see two buttons called Copy PRIMARY to 0 and Copy 0 to PRIMARY. To copy textfrom one window to another, first highlight text in one window. Then click on the CopyPRIMARY to 0 button. You can then click on the Copy 0 to PRIMARY button, move tothe window where you want to paste the text, and use either your keyboard or mouse topaste the text.Yet another X11 client for copying and pasting text is the xclipboard client. This programis especially handy for copying sections of text from messages, FAQs, HOWTOs,or other files. Like the xcutsel client, xclipboard places the copied text into a bufferbut has the added benefit of displaying the text, which you can then save into a file orcopy into other windows or programs.If you want to do more than just copy small bits of graphics or text, you can also capturepictures of whole windows or your desktop. The next section shows you how to capture,save, and display pictures from your X11 desktop.


Using the X Window System 167Capturing and Dumping X11 WindowsYou can capture pictures of windows or your entire desktop using several X11 clientsincluded with X11. The first is xwd, or the X11 window dump program. You can use thisclient to take snapshots of your screen or any desired window.The xwd program is easy to use. You want to redirect the output or specify a file on thecommand line because if you don’t, the file is sent to the standard output and scrolls upyour terminal window. To redirect the output, use xwd, like this:# xwd > mydump.xwdThe xwd client also has an -out option that can be used to direct the output, like this:# xwd -out mydump.xwdAfter you press Enter, your cursor turns to a crosshair (+). If you click on the root desktop,the xwd client dumps, or captures, a picture of your entire screen. If you click in awindow, the xwd client captures the contents of the window, even if it is hidden or overlappedby another window.This is handy if you want to capture a series of pictures of a running client, show offhigh scores of games, or create quick slide shows. The captured file is in an X11 windowsdump format, and you can find a number of clients you can use to view the image.One is the xwud (X11 window undump) client. To see your screenshot, you can use thefollowing:# xwud -in mydump.xwdYou can also create a slideshow of your images with the xloadimage client found underthe /usr/X11R6/bin directory. For example, if you create a series of screen dumps, youcan build a looping slideshow of the screenshots with the following:# xloadimage -fit 1.xwd 2.xwd 3.xwd -goto 1.xwdUsing this command line, you can repeatedly page through the dump files by pressingthe N character on your keyboard, or you can press the Q character on your keyboard toquit. The xloadimage client has many features and can also save your screen dump filesin different graphics file formats. See the xloadimage manual page for more information.Many other graphic utilities are included on your OpenLinux CD-ROM. SeeHour 16 for an overview of paint and drawing programs, graphics conversionutilities, and other image viewers, such as the xv client, which not onlycaptures screenshots, but edits, converts, saves, and prints graphics.7


168 Hour 7Customizing the X11 Root Window and Using ScreensaversIf you have a color monitor, you might want to change the default color or pattern of theroot, or desktop, window. You can do this quickly and easily with several X11 clients. I’llalso show you how to put pictures into your background and how to set up and usescreen savers in X11.Setting the Background ColorYou can change the background color of your display with the xsetroot, or root windowutility, which is found under the /usr/X11R6/bin directory. Your choice of color, as Imentioned previously, depends on the number of color depth of your X11 server. Ifyou’re using the SVGA server, you have a choice of 256 colors. For example, you canchange the color with the following:# xsetroot -solid redSetting the Background PatternIf a solid color is too hard on your eyes or too plain for your tastes, you can also use oneof nearly 90 different bitmap graphics files from the /usr/include/X11/bitmaps directoryto set a desktop pattern. For example, to get a red basket-weave pattern for yourdesktop, use the following:# xsetroot -bitmap /usr/include/X11/bitmaps/wide_weave -bg redThis command line tells the xsetroot client to load the bitmap graphic file wide_weavefrom the X11 bitmap graphics directory and display the pattern with a background color.If you have a monochrome display, you’re out of luck with colors. But you can changethe pattern and apparent shade of your background display with different bitmap files.Try the dimple1, dimple3, or flipped_gray bitmap files.Displaying Pictures on the Root DisplayMany users like to display a favorite picture in the root window. If you have a favoritephotograph you’ve scanned or a graphic you like, you can display your image on thedesktop with the xsetroot client, but the image must be in the X11 bitmap format.You can use a client that’s already been discussed—xloadimage. See what graphics fileformats the xloadimage client recognizes with the -supported command-line option, forexample:# xloadimage -supportedType Name Can Dump Description---------- -------- -----------


Using the X Window System 169niff Yes Native Image File Format (NIFF)sunraster No Sun Rasterfilegif No GIF Imagejpeg Yes JFIF-style JPEG Imagefbm No FBM Imagecmuraster No CMU WM Rasterpbm Yes Portable Bit Map (PBM, PGM, PPM)faces No Faces Projectrle No Utah RLE Imagexwd No X Window Dumpvff No Sun Visualization File Formatmcidas No McIDAS areafilevicar No VICAR Imagepcx No PC Paintbrush Imagegem No GEM Bit Imagemacpaint No MacPaint Imagexpm No X Pixmapxbm No X BitmapThe file formats xloadimage can use are listed in the left column. If you have a graphicyou want to display, you can use the following:# xloadimage -onroot cathy.gifThis loads the graphic file, cathy.gif, and displays it (depending on its size) in a tiled,or multiple-view, format. If you only want one large version of your graphic in the rootdisplay, use the -fullscreen command-line option, for example:# xloadimage -onroot -fullscreen cathy.gifThis causes the xsetroot command to load the graphic and zoom to fit the display. Youhave to experiment with different sized graphics to get the best effect for your graphics.The xv client can also be used to put images in your root display. If you useKDE, save your favorite image in JPEG format in the /opt/kde/share/wallpapers directory. You can then select the image as a default wallpaperfor one of your desktops with the KDE Control Center’s Desktop Backgrounddialog box.Screen Saver Settings and ProgramsAlthough displaying a colored pattern or picture on your desktop can be fun, X11 screensavers also offer password control. Even though screen savers aren’t needed to protectmodern computer monitors from the “burn-in” effect of a continuous display, they arefun, and you can find an interesting variety installed along with X11.7


170 Hour 7KDE users can use the KDE Control Center’s Desktop Screen savers dialogbox to control screen saving.Use the xset client, introduced earlier, to manage screen saving under X11. If you wantto see the current settings, use the q command-line option (note that there is no hyphenused), for example:# xset q...Screen Saver:prefer blanking: yes allow exposures: yestimeout: 0 cycle: 600...You can turn on screen saving with the xset client by using the s command-line option,followed by the word on. To set the time in seconds, use the s option, followed by thenumber of seconds you want your X11 server to wait to blank the screen, for example:# xset s 10This sets the time out interval to 10 seconds before the X11 screen saver is activated (justto test screen saving). To enable the screen saver, which is built in to your X11 server,use the s option with the word on, for example:# xset s onAfter 10 seconds, X displays a blank screen. If you want to see graphics and a backgroundpattern, you can use the noblank option for the xset s command-line option, forexample:# xset s noblankAs you can see, a large X is displayed on the screen. To turn off screen saving, use the soff command-line option (don’t forget to change the screen saving interval to somethingmore reasonable, such as 600 for 10 minutes, if you use xset). If this isn’t your idea of ascreen saver, you can try the xscreensaver clients.The xscreensaver and xscreensaver-command clients, by Jamie Zawinski, are foundunder the /usr/X11R6/bin directory. The xscreensaver client has 16 command-lineoptions. Although this hour doesn’t cover all the options, the basic way to use this screensaver is to first run the xscreensaver client in the background, as follows:# xscreensaver -timeout 5 &


Using the X Window System 171This command sets the screen saver to run after five minutes of no keyboard or mouseactivity. You can control this client with the xscreensaver-command client to turn thexscreensaver on or off or to activate it immediately. Although the xscreensaver clienthas a -lock option to password-protect your display, you have to recompile the programto enable this feature.The xscreensaver client comes with nearly two dozen different screen savers, which canalso be run as standalone programs. For example, you can run the fractal drawing program,hopalong, in a window, as follows:# hopalongAfter you press Enter, a fractal image appears in a window (as shown in Figure 7.9), soyou can see what it looks like.FIGURE 7.9The hopalong client ispart of a screen saverfor X11.For a list of the screen savers that work with the xscreensaver client, read the fileXScreenSaver in the /usr/X11R6/lib/X11/app-defaults directory. You can find othersettings in the file, which is the X11 resources file for this client.You might also be interested in the xlock client. Although it is not a screen saver,xclock is a sophisticated terminal-locking program with nearly 50 command-lineoptions and more than 50 different displays built in. The xlock client is helpful if youwant to password-protect your display to prevent others from using your computer whileyou’re away.7


172 Hour 7By default, after you start the xlock program, you must enter your password before youcan use your display again. You can use it as a simple screen saver without passwordprotection to display a variety of animations, for example:# xlock -duration 10 -nolock -mode randomThis command line tells the xlock program to display a random selection of its animations,each of which runs for 10 seconds.The xlock client can also make your desktop an animated display if you usethe -inroot command-line option. This doesn’t protect your system, but youmight find the visuals stimulating!Exploring X11 ProgramsThere’s not enough room in this hour to discuss all the X11 clients on your CD-ROM.You can find discussions about different clients throughout the rest of this book, but thissection shows you some helpful programs that give you more information about yoursystem and some tips and tricks on how to use them.Listing X11 Fonts with xlsfontsIf you want a list of all the fonts recognized by X11 on your system, you can use thexlsfonts client. Use a pager like less or more (discussed in Hour 4, “Reading andNavigation Commands”) if you call the client without any options. You can also usewildcards or patterns to match font names. This can be handy to find a particular font onyour system, for example:# xlsfonts -fn *italic*lucidasans-bolditalic-10lucidasans-bolditalic-10lucidasans-bolditalic-12lucidasans-bolditalic-12lucidasans-bolditalic-14lucidasans-bolditalic-14lucidasans-bolditalic-18lucidasans-bolditalic-18lucidasans-bolditalic-24lucidasans-bolditalic-24lucidasans-bolditalic-8lucidasans-bolditalic-8lucidasans-italic-10lucidasans-italic-10lucidasans-italic-12


Using the X Window System 173lucidasans-italic-12lucidasans-italic-14lucidasans-italic-14lucidasans-italic-18lucidasans-italic-18lucidasans-italic-24lucidasans-italic-24lucidasans-italic-8lucidasans-italic-8As you can see, this lists all the italic fonts installed or recognized by your X11 server.You can use the xlsfonts client to troubleshoot whether fonts are recognized or installedor to find a font name to choose as an X Toolkit option when starting a client.Getting Window Information with the xwininfo ClientYou can use the xwininfo client, or window information utility, to get helpful informationabout a window. When you use this command, you can click another window to geta detailed information listing, for example:# xwininfoxwininfo: Please select the window about which youwould like information by clicking themouse in that window.After you click on the desired window, you see a list of information, such as the following:xwininfo: Window id: 0xc00002 “rxvt”Absolute upper-left X: 8Absolute upper-left Y: 397Relative upper-left X: 0Relative upper-left Y: 0Width: 574Height: 158Depth: 8Visual Class: PseudoColorBorder width: 0Class: InputOutputColormap: 0x21 (installed)Bit Gravity State: ForgetGravityWindow Gravity State: NorthWestGravityBacking Store State: NotUsefulSave Under State: noMap State: IsViewableOverride Redirect State: noCorners: +8+397 -218+397 -218-45 +8-45-geometry 80x11+3-407


174 Hour 7This information can be helpful, for example, if you want to get the specifications abouta window’s geometry settings for the next time you run the program or if you want tochange the default behavior of a window by editing its resource file.Making a Sticky Note Calendar with the xmessageClientThe xmessage client, by Chris Peterson and Stephen Gildea, is a handy way to createquick notes as reminders while you work. This deceptively simple client is easy to use.For example, if you want to make a quick note of a phone number, you can use the following:# xmessage “George called at 10:15; call him back at 555-1212” &This command line displays the xmessage client window with the text of your message.Although this is a simple example, you can also use the xmessage client to display theoutput of program searches or use it in your personal schedules to automatically sendreminders while you work. See Hour 18, “Personal Productivity Tools,” or Hour 24,“Using Scheduling to Automate System Management,” for details.You can also use xmessage as a handy calendar display program if you need to keep acopy of the current calendar on the screen or if you want a calendar on your desktopwhen you start your X session. You can’t find a simple X11 version of the cal calendarprogram, but here’s one you can use:# cal | xmessage -file “-” &This displays the output of the cal calendar program in a square xmessage clientwindow.You can find the ical X11 client under the /usr/X11R6/bin directory, butthis is a personal scheduling utility with a larger calendar display. See Hour18 for details.Keeping Time with X11 ClocksIf you’re a habitual clock watcher, you’re in luck using X11 as you can find severalclocks. You’re sure to find one you like.


Using the X Window System 175Unfortunately, the rclock client, which usually accompanies the rxvt terminal,is not included with OpenLinux. This client is much more than just aclock; it’s an appointment calendar and mail notification program, as in thefollowing example:# rclock -bg red -fg yellow -update 1 -geometry 80x80+718+0 &This command line puts a square red clock with yellow hands (a secondhand is created with the -update 1 option) in the upper right corner of an800×600 desktop. A file called .rclock in your home directory is used createautomatic reminders. The rclock client pops up a reminder message at theappointed time and can run programs at certain times (it checks the fileevery 10 minutes; when email arrives, rclock reverses its display). Look forthis client on your favorite Linux archive Web site!The xclock client displays time, by default, in a standard clock face, but you can makexclock look like a digital clock with the -digital option. You can also control the colorof the standard clock hands or add a chime for the hour and half hour, for example:# xclock -chime -hd red -hl red -update 2 -geometry 80x80 -bg yellowThis command displays an 80×80 pixel chiming xclock with a yellow face, red hands,and a sweeping second hand. If you want a digital version, you can use the following:# xclock -chime -update 1 -digital -bg yellowThis command displays a digital chiming clock with a yellow background. If you likedigital clocks, you might also like the xdaliclock client, which uses animation for itsdigits and has many options to control the digits, coloring, shape, or fonts used in thedisplay, for example:# xdaliclock -24 -cycle -font 9x15 -transparent -geometry +697+3This command displays a transparent digital clock in the upper right corner of an800×600 display with melting digits that constantly change color. If you click on the digitaldisplay, the current day, month, and year are displayed momentarily.SummaryThis hour introduced numerous initial topics relating to the X Window System, such asstart up, using different color depths, navigating through virtual consoles, and startingmultiple X11 displays. You then discovered several window managers for X11, saw howto configure and manage the X11 desktop, and learned copy and paste operations of textand graphics. Finally, you were introduced to several useful X11 utilties and clients touse to make your X session easier.7


176 Hour 7Q&AQ I still can’t get X11 working with my computer’s graphics card and monitor!What can I do?A If you have a troublesome graphics card (which usually happens with the latestequipment), try using a commercial X11 distribution for OpenLinux from a vendorsuch as MetroLink, Inc. (http://www.metrolink.com) or Xi Graphics, Inc.(http://www.xig.com). You can probably get much better support for newer cards.Q What is the best window manager to use for X11?A This is a religious question, and beyond the scope of this book. One good site tocheck for different window managers includes http://www.PLiG.org/~xwinman/where you can find links to at least 40 different GUIs for X.Q How many different window managers for X11 are there?A More than you’ll ever want installed on your computer! There are more than 100.For example, if you want your desktop to look like an Apple Macintosh, try themlvwm window manager at: http://www.bioele.nuee.nagoya-u.ac.jp/member/tak/mlvwm.htmlQ Hey! You haven’t mentioned the GNU’s Network Object Model Environment!What gives?A GNU GNOME development is moving along quite rapidly at the time of this writing.Like KDE, GNOME development is aimed at providing a quality environmentand interface support for all versions of Linux. KDE is included with OpenLinuxand has had the advantage of building increased popularity and adherents beforeGNOME’s latest releases. You can find out more about GNOME by browsing tohttp://www.gnome.org.Exercises1. Create your own information display with the xmessage client. What kind of informationshould be shown?2. Download and install a different window manager. How is it different? How arewindows handled, and what do they look like?3. See Hour 18 for information about using the crontab command. How can thiscommand be used to configure your X11 display to mimic ambient lightconditions?


HOUR 8Exploring the K DesktopEnvironmentIn this hour you’ll learn about one of the newest desktop environments forthe X Window System. Although there are more than 50 different windowmanagers for X11, each with different themes, desktop colors, and decorations(for example, window controls), the K Desktop Environment, or KDE,reigns supreme in popularity with the OpenLinux crowd. You’ll be especiallypleased with KDE because Caldera Systems, Inc. has taken specialpains to configure KDE’s desktop to match programs in the OpenLinux distribution.The hour will help you learn how to overcome the challenge of configuringKDE, and I think you’ll soon agree—KDE is easy to use! Because choosingand using a window manager with X11 is a matter of personal preference,this hour will show you how to configure KDE using the KDE ControlCenter to change different settings, such as the background of the root display,fonts, the mouse, and the keyboard, and how window decorations, suchas title bars, scrollbars, and buttons, appear.


178 Hour 8KDE features some of the latest and most sophisticated features shared by commercialsoftware libraries such as Motif, and the now fading Common Desktop Environment, orCDE (which is now only offered by one vendor, Xi-Graphics, for Linux). These featuresinclude:●●●●●●●●●●●●Drag-and-drop actions (such as copy, move, and delete) for files and devicesPoint-and-click dialog configuration of the desktop to display colors, window borders,and themesPrograms and other data represented as icons on the desktop or in windows withfolder iconsGraphic configuration of your system’s keyboard, mouse, and soundSingle-click convenience to edit files, view graphics, or launch applicationsA desktop trash can for safer file deletionsPop-up menus and built-in help for nearly any desktop action and KDE clientNetwork Transparent Access, or NTA, so you can click on a graphic document inan FTP listing and have a program on your computer automatically download anddisplay the graphic“Sticky Buttons” to put an application or window on every desktopJPEG graphic formats for background wallpaper graphics for the root displaySession management, so open applications and window positions are rememberedbetween sessions (like CDE)A suite of personal productivity tools, such as disk and network utilities, crafted totake advantage of the desktop interface and the capability to import and export datato other toolsKDE is more than just an X11 window manager; it is a complete environmentand comes with more than 100 clients with a consistent interface. Eachclient generally has a File and Help menu, so you can easily open files, quit,or get help. Pundits endorse this similarity, whereas some users prefer otherX11 window and client management. Fortunately, because you’re usingOpenLinux, the choice is up to you!


Exploring the K Desktop Environment 179Starting KDEBy default, you’ll start KDE after logging into the kdm, or KDE display manager login.However, if you’ve disabled the login manager, you should know that there’s anotherway to start KDE. When you log in to your OpenLinux console without X11, you’regreeted with the following:8You can start X11 with ‘startx’ or KDE with ‘kde’.This is true, but if you’ve configured X11 with the xf86config command, and simplytype kde and press Enter, your KDE and X session will start using only 256 colors, or aneight-bit pixel depth. To use a greater color depth, start your X sessions using the-- -bpp, or bits-per-pixel option. For example, to start KDE with thousands of colors,type kde, followed by the -bpp option, like so:# kde -- -bpp 16If you’re fortunate enough to have a graphics card supporting millions of colors, try# kde -- -bpp 24or# kde -- -bpp 32The available color depths are defined in the XF86Config file found underthe /etc directory. Look for the Depth settings in the Display subsection ofthe Screen section. If you configured X11 by editing XF86Config, use poundsign (#) characters to comment out lower color-depth settings. Another wayis to use the DefaultColorDepth option, followed by 8, 15, 16, 24, or 32, inthe Screen section. You can then just type kde to start X11 at higher colordepths. For details about configuring X11, see Hour 3, “Configuring the XWindow System and OpenLinux.”


180 Hour 8When you use xdm to log in to Linux and run X11, you might find thatyou’re unable to run programs as the root operator from a terminal window.This is because you must use the xhost command to temporarily addthe hostname of your computer to the access list of your X server. To do this,you can use this formula: xhost + localhost; su -c “rootcommand”, whererootcommand is the name of the command you want to run as the root operator(such as the control panel or printtool). Afterwards, remove the accesswith: xhost - localhost to preserve your system’s security.Features of the KDE DesktopAs mentioned at the beginning of this hour, KDE has many of the features expected of amodern graphical computer interface. KDE builds on these features to provide an easyto use way of handling files to enable you to be more productive during X sessions.This section highlights some of the ways you can get work done when using the KDEdesktop.Performing Basic Desktop ActionsWhen you first start KDE, you see the kfm, or K file manager window, and a root display,or desktop, as shown in Figure 8.1.The KDE desktop consists of several elements: a taskbar across the top of display, theroot background (or root display), and the desktop panel along the bottom of yourscreen. In the panel, starting from the left, is the Application Starter button (the large‘K’), followed by several icons representing different applications, folders, and directories.There are four buttons representing the default four virtual desktops, or displays,followed by more application icons. (You may see ones for the CriSPlite editor,Netscape, BRU-2000, KDE help, and the Kcalc calculator.)


Exploring the K Desktop Environment 181FIGURE 8.1The KDE desktop isyour introduction topoint-and-click convenienceduring X sessions,and features ataskbar, root displayarea, panel with popupmenus and clientbuttons, and a homedirectory.PathnameLooking Glassconfiguration filesTaskbar8Home DirectoryApplication StarterbuttonWindowlist buttonHomedirectorybuttonVirtual desktopbuttonsRootdisplayDesktoppanelUsing Desktop panelThe panel is used as a convenient tool for holding the Application Starter menu (accessedwhen you click the Application Starter menu), other application icons, the screen lock orlogout button, virtual desktop buttons, and other program icons. To change the panel’ssize or orientation, click the Application Starter button, select Panel then click Configure.A dialog box appears, as shown in Figure 8.2, from which you can select different settings.When you’re finished, click Apply, then the Cancel button.If you want to change how icons are placed or arranged on the panel, right-click adesired icon, and then select Remove (to delete the item) or Move from the small pop-upmenu. If you click Move, you can drag the icon across the panel to a different place. Ifthe panel is getting in the way during your KDE session, click the small button to the farleft of the panel to temporarily hide the panel from your screen. To restore the panel,click the small button again, and the panel reappears.


182 Hour 8FIGURE 8.2The PanelConfiguration dialogbox enables you tochange how the paneland taskbar look andwhere they are placedon your desktop.Editing the KDE Panel MenuTo edit the desktop’s panel menus, click the Application Starter button, select Panel,and then click Edit Menus. The KDE Menu Editor dialog box appears as shown inFigure 8.3. If you’re logged in as the root operator, you can change and edit menu itemson the panel menus by using drag-and-drop to shift items in the menu list or create itemsusing the Empty menu item.If you’re logged in as a regular user, you can only change menu items forwhich you have permission. If you right-click on a KDE panel item, you seethe message “! PROTECTED Button !”. You can, however, edit a singleapplink menu item in your desktop’s panel. To this menu, you can addnearly any other command or client.For example, to create a new menu item, right-click the Empty menu item, and thenselect New. A new Empty menu item appears. Right-click the new Empty menu item,then click Change, and the kmenuedit editor dialog box appears, as shown in Figure 8.4.Fill in the required fields, and select a large icon and menu icon for the menu item. Whenyou finish, click Ok to save the changes. You can now drag and drop the new item anywherein the panel menu’s hierarchy.


Exploring the K Desktop Environment 183FIGURE 8.3The panel menu editorenables you to add orremove menu itemsfrom the panel’smenus.8FIGURE 8.4The kmenuedit dialogbox is used to createor edit new individualmenu items in yourpanel’s menus.Using the kfm File ManagerThe K file manager, or kfm, is near the center of the magic of KDE. This file manager,unlike Looking Glass (discussed in Hour 7, “Using the X Window System”), provides ausable desktop where you can drag, drop, multiple-select, copy, move, or delete icons ofdata files or programs. Many of the desktop actions supported by kfm become apparentwhen you drag or right-click a file’s icon.


184 Hour 8The kfm desktop, which includes your home directory and your root display (as shown inFigure 8.1), is represented by the directory named Desktop in your home directory. Ifyou drag files to this folder, the files’ icons appear on your root display. Similarly, if youdrag a file from another folder or directory to the desktop, it appears in your Desktopdirectory.Configuring KDE with the KDE ControlCenterThe KDE Control Center is the main dialog box through which you can change numeroussettings of your desktop, get system information (such as the currently mounteddevices and capacities), or (if logged in as the root operator) configure and controlKDE’s appearance, background, fonts, and sessions for all users.Click the Application Starter button on your desktop’s panel, and then click KDE ControlCenter to display the Control Center dialog box. The main dialog box appears, as shownin Figure 8.5.FIGURE 8.5The KDE ControlCenter dialog boxprovides access tomany different controlsof your system’s KDEsessions.


Exploring the K Desktop Environment 185Using Display Manager OptionsClick Applications and then Login Manager in the drop-down menu in the ControlCenter to change settings for the KDE Display Manager. You must be logged in as theroot operator to access this portion of the Control Center. The Login Manager dialogbox, shown in Figure 8.6, enables you to change how the kdm dialog box appears whenyou boot OpenLinux.8FIGURE 8.6Use the LoginManager dialog box tochange kdm’s loginscreen and other settings,such as the typeand number of Xwindow managersor users allowed tolog in.By clicking on different tabs at the top of the dialog, you can change many differentfeatures of your kdm login screen:• Appearance — the greeting strings, logo used in the login dialog, window style,and language• Background — the wallpaper, background color, and tiling of images for the wallpaper• Fonts — the greeting font• Sessions — the type of shutdowns allowed, the commands used to shutdown orrestart OpenLinux from kdm, and the types of “sessions” or window managers usedfor the X session after logging in• Users — which system users are allowed to log in, whether the user list is sorted,and the icon used for each user (which may be substituted by a scanned photo!)


186 Hour 8For example, to control which users are permitted to log in to OpenLinux directly to X,click the Users tab in the Login Manager dialog box. The Users dialog box appears, asshown in Figure 8.7. To selectively control user log-ins, click the Show only selectedusers button, and then click and add users to the Selected users section of the dialogusing the >> button.FIGURE 8.7The Users dialog boxcan control who ispermitted to log in toOpenLinux using Xand KDE.To control whether anyone can reboot or shutdown OpenLinux from the kdm loginscreen, when your system shuts down or reboots, and what window managers can beused after logging in, click the Sessions tab of the Login Manager dialog box. Click theAllow to shutdown drop-down menu shown in Figure 8.8, and select who is enabled tostop or restart OpenLinux. When finished, click the Apply button.


Exploring the K Desktop Environment 187FIGURE 8.8The Sessions dialogbox can control whocan shut down orrestart OpenLinux andwhat X window managerscan be used.8Changing Your Desktop’s WallpaperKDE comes with nearly 150 different wallpapers you can use to fill the root display, orbackground of your desktop. To configure the current desktop’s wallpaper, click thedrop-down Desktop menu, and then click Background. You can also click the ApplicationStarter button on the desktop panel, and select Settings, then Desktop, and thenScreensaver.The Background dialog box, shown in Figure 8.9, enables you to set the name of eachdesktop, each desktop’s colors, and whether the desktop uses a wallpaper. To set a differentwallpaper, click the Wallpaper pop-up menu in the Wallpaper section of the dialogbox, and then click Apply.KDE wallpapers are graphics files in JPEG format. To add to the choice ofwallpapers or to use your own wallpapers, log in as the root operator, andcopy your favorite graphics (in JPEG format) to the /opt/kde/share/wallpapers directory. You can also select wallpaper graphics from anyOpenLinux directory by clicking on the Browse button in the Backgrounddialog box.


188 Hour 8FIGURE 8.9Use the Backgrounddialog box to setyour desktop’s name,colors, and wallpaper.Changing Your ScreensaverKDE comes with 24 different screensaver settings. To configure the screensaver of yourKDE desktop, click Screensaver from the Desktop drop-down menu in the KDE ControlCenter. You can also click the Application Starter button on the desktop panel, and thenselect Settings, then Desktop, and then Screensaver.The Screensaver dialog box, shown in Figure 8.10, has a number of settings, such as thetype of screensaver, the time delay before activating the screensaver, and whether youwant to require a password to go back to work. After you make your changes, click theApply button, and then click OK to close the dialog box.Right-click different corners of the sample display in the Screensaver dialogbox to set automatic screen-saving or screen-locking! A small pop-up menuappears, and you can select Save Screen or Lock Screen for each corner. Forexample, if you set the lower-left corner of the sample display to startscreen saving, the next time you move your mouse pointer into the left cornerof the display (and leave it there for a second), screen saving starts.


Exploring the K Desktop Environment 189FIGURE 8.10The Screensaver dialogbox has differentsettings you can use totest a screensaver, seta time delay, orrequire a password.8Changing Default FontsKDE can also use different fonts for menus, buttons, the panel, or your panel’s clock. Toset the fonts of your KDE desktop, click the Application Starter button on the desktoppanel, and select Settings, then Desktop, and then Fonts. You can also click KDE ControlCenter from the Application Starter menu, then click Desktop, and then click Fonts.The Fonts dialog box, shown in Figure 8.11, shows a list of the different desktop fonts,along with a pop-up menu of typefaces. First, click a type of display item, such as thePanel clock font, and then select a typeface, type style (such as bold or italic), and a size.The sample text area of the dialog box changes. To effect your changes, click the Applybutton, and then click OK to close the dialog box.


190 Hour 8FIGURE 8.11The KDE fonts dialogbox enables you tochange the fonts usedfor menus, buttons, orthe desktop panel’sclock.Installing System SoundsClick the Sound drop-down menu in the KDE Control Center, and then click SystemSounds to configure KDE to use sound during your X sessions. KDE recognizes 28 separatesystem events to which you can assign a sound. Table 8.1 shows a list of currentlysupported events, such as opening or closing windows. To have KDE play a sound whenit first starts, in the Sound dialog box, as shown in Figure 8.12, first click enable systemssounds, and then click the Startup system event. Next, drag the icon of a sound file intothe blank Sounds: area of the dialog, and click the Apply button. The next time you startKDE, you hear the sound file play.TABLE 8.1K DESKTOP ENVIRONMENT SYSTEM SOUND EVENTSDesktop ElementEventsDesktop Changing to 1-8SystemStartup, Logout, Logout MessageWindowActivate, Open new, Close, Shade Up, Shade Down, Iconify,DeIconify, Maximize, UnMaximize, Sticky, UnSticky, TransNew, Trans Delete, Move Start, Move End, Resize Start,Resize End


Exploring the K Desktop Environment 191KDE sounds must be in WAV format. If you’ve installed StarOffice 5.0, a fulldirectory of various sounds is located under the Office50/gallery/Soundsdirectory. Navigate to the Sounds directory through your home directory,then drag the file Applause.wav into the Sound dialog box, click the Startupevent, and then click Apply. The next time you start KDE, you’ll hearapplause!8FIGURE 8.12The Sound dialog boxis used to assignsounds to KDE systemevents.Changing Keyboard and Mouse SettingsClick Keyboard from the Input Devices drop-down menu in the KDE Control Center totoggle keyboard character repeat (repeated printing of a character when a key is helddown), and whether each key-press generates a key-click sound. Click the Apply button,as shown in Figure 8.13, when you finish with your selection.


192 Hour 8FIGURE 8.13Use the Keyboarddialog box to toggleKeyboard repeat andkey-click sounds.Click Mouse to change how fast your mouse cursor moves across the screen and thesequence of mouse buttons for right- or left-handed users. You can also click theApplication Starter button on the desktop panel, and select Settings, then Input Devices,and then Keyboard or Mouse to get to these settings.FIGURE 8.14The Mouse dialog boxcan be used to makeKDE sessions easierfor left-handed mouseusers!


Exploring the K Desktop Environment 193Changing Window Buttons, Properties, and Title BarsClick the Windows drop-down menu to access the Buttons, Mouse, Properties, andTitlebar dialog boxes. You can also click the Application Starter button on the desktoppanel and then select Settings and Windows to get to these settings. Toggle each buttonunder Left, Right, or Off in the Button dialog box shown in Figure 8.15 to add, remove,or place different window controls.8FIGURE 8.15The Buttons dialog boxis used to change theappearance of allwindows during yourKDE sessions.In the Titlebar dialog box shown in Figure 8.16, click different buttons to change howKDE windows’ title bars appear (controlling elements such as shading or whether a pictureis used). Drag the Title Animation slider to change how fast a window’s title movesback and forth for a KDE client (when the title is wider than the window’s title bar). TheMouse action pop-up menu is used to set how windows react when you double-click inthe title bar. (The default setting might use a “window shade” effect, but under X11, normallya window enlarges or shrinks)For more complex window control, click Properties to use the Windows dialog box,shown in Figure 8.17, to tell KDE how to move, place, resize, or activate windows onyour desktop. For example, the Focus Policy section tells KDE how to make a windowactive. The default action is that you must click on a window to activate it, or enable it toreceive keyboard input; other policies make a window active when your mouse pointer isover the window.


194 Hour 8FIGURE 8.16The Titlebar dialogbox sets how KDEwindows act and lookduring your KDEsessions.The Mouse dialog box under the Windows drop-down menu is used to sethow you want KDE windows to react to your mouse clicks. You can find adozen different mouse actions (such as left, middle, or right clicks on activewindows) you can customize.FIGURE 8.17You can fine-tune howKDE handles windowson your desktop withthe Windows dialogbox.


Exploring the K Desktop Environment 195Controlling Cursor Movement Through DesktopsThe Borders dialog box, which you can also access through the Settings and Desktopmenu items from the Application Starter menu of your panel, is indispensable when controllingcursor movement between virtual desktops. By default, you have to click a virtualdesktop button on your desktop’s panel to move between desktops. But if you clickthe Enable active desktop borders item, and then click the Apply button, you move to adifferent desktop by moving your mouse cursor to the edge of the current desktop.8Don’t want to click the panel’s desktop buttons or drag your mouse to movebetween desktops? Use the keyboard instead! Press Ctrl+Tab to walkthrough the desktops. Press Alt+Tab to walk through (activate) windows inthe current desktop.In the Borders dialog box, shown in Figure 8.18, drag the different sliders to set the timedelay for desktop switching and the width of the sensitive edge of each desktop.FIGURE 8.18The Borders dialogbox is used to tell KDEwhether to use themouse to movebetween desktops, howfast to make the switch,and when to make thechange.SummaryThis hour introduced you to the basics of configuring the K Desktop Environment. Thereare many features and different programs specifically tailored to work with KDE, andmore appear every day.


196 Hour 8Q&AQ Where is KDE installed?A The major portion of KDE is installed under the /opt/kde directory in yourOpenLinux file system. The various KDE clients are found under the/opt/kde/bin directory. Each user also has a .kde directory installed in the homedirectory, which is used to store personal settings and configurations.Q How can I find out more about KDE?A Click the KDE Help item on your panel’s Application Starter menu. KDE’s documentationis written in HTML and is displayed by the kdehelp client. The documentationfiles are found under the /opt/kde/share/doc/HTML directory inGerman, English, Spanish, Finnish, Italian, and Norwegian. The language used forall help files is determined by a symbolic file named default, which points to adesignated language directory. Other languages can be used by changing theLocale setting in the Language item under the Desktop settings in the KDE ControlCenter.Q Where can I find more KDE applications?A Browse to http://www.kde.org for a list of the latest programs and applicationsuites for KDE. A full office suite of productivity programs called K Office (whichincludes a word processor and spreadsheet) is currently under development.Exercises1. Create a new application link for a program, such as WordPerfect, Applixware, orStarOffice, and then install the icon into your desktop’s panel. (Hint: read “The KFMHandbook” Usage section for details).2. Download, create, scan, and edit a favorite picture for use as a background for oneof your KDE desktops, and then install the picture as your wallpaper.3. Add different sounds to KDE’s system events.4. Change the orientation of the panel and taskbar to offer the maximum screen realestate for your display.


PART IIIConnecting to theOutside WorldHour9 Using Communications Programs10 Connecting to the Internet11 Configuring Internet Email12 Configuring Internet News13 Internet Downloading and Browsing


HOUR 9Using CommunicationsProgramsIn this hour, you’ll learn about communicating with the outside world usingprograms installed from this book’s CD-ROM. You’ll learn how to set upyour serial port or modem, configure and use two communication programs,and send and receive faxes with Linux.Although your CD-ROM contains all the software you need to run Linuxcommunications programs, you do need a serial communications port andmodem to dial out with your Linux system. I assume you’re familiar withmodems, communication terms such as baud rate, parity, or stop bits, andhow to connect your modem to your computer.


200 Hour 9Setting Up and Testing Your ModemYour first task is to find your spare serial port. You should be able to find the port on theback of your computer, and it most likely has 9 or 25 pins. If you’re using a laptop, youmight have a 9-pin male serial port, an RJ-11 telephone jack for an internal modem, or aPCMCIA modem card with an RJ-11 telephone jack.You can find your serial port in Linux by looking in the device or /dev directory. Manydevices are defined there, such as hard drives, floppies, and printers, but you should lookfor devices of type ttyS, for example:# ls /dev/ttyS*/dev/ttyS0 /dev/ttyS1 /dev/ttyS2 /dev/ttyS3These devices correspond to the traditionally defined DOS serial ports (with addressesthat might be similar or different for your computer), as shown in Table 9.1.TABLE 9.1 DOS AND LINUX SERIAL PORTS AND ADDRESSESDOS Port Linux Device AddressCOM1 /dev/ttyS0 0x2F8 IRQ 4COM2 /dev/ttyS1 0x2F8 IRQ 3COM3 /dev/ttyS2 0x3E8 IRQ 4COM4 /dev/ttyS3 0x2E8 IRQ 3If you have a laptop with a PCMCIA modem card, you can’t use your modem (or anyother PCMCIA devices) until you enable those services and tell Linux to look for PCM-CIA devices when it starts. To enable your PC card modem, make sure you’re logged inas the root operator, and then edit the file named pcmcia in the /etc/sysconfig directoryto look like this:PCMCIA=yesPCIC=i82365PCIC_OPTS=CORE_OPTS=This tells Linux to install PCMCIA services. Save the file, and then reboot Linux. YourPC card modem (and other PC cards, if installed) should be recognized during thereboot.


Using Communications Programs 201If you have trouble with PCMCIA devices, read David Hinds’ PCMCIA-HOWTO, which you can find under the /usr/doc/pcmcia directory. If youwant the latest information about PCMCIA support for Linux, browse tohttp://hyper.stanford.edu/HyperNews/get/pcmcia/home.htmlTo download the latest drivers (kernel modules) for OpenLinux, go toftp://csb.stanford.edu/pub/pcmciaIf you have trouble with setting up your serial ports, read Greg Hankins’Serial-HOWTO, also under the /usr/doc/HOWTO directory. There is a completediscussion on setting up your serial ports and troubleshooting installation.To read the document, which is a compressed text file, use the zless pager,like so:9zless /usr/doc/HOWTO/Serial-HOWTO.gzYou can check to make sure that your serial ports are enabled by checking portions of theLinux startup message with the dmesg command. Pipe the output of the dmesg commandthrough the less pager to display the boot messages and look for the Serial driver messagelike this (press the Q key when you’re finished to quit):# dmesg | less...Serial driver version 4.13 with no serial options enabledtty00 at 0x03f8 (irq = 4) is a 16550Atty03 at 0x02e8 (irq = 3) is a 16550A...A portion of the dmesg file is reproduced here, so you can see what to look for. The outputhere indicates that the system has serial ports of the MS-DOS equivalent of COM1and COM4 at the IRQs enclosed in parentheses. If you do not see a serial driver or serialport listing, you must make sure that serial-line support is enabled for your Linux kernel.By default, OpenLinux comes with serial support, so this is probably not a problem.Test your modem interactively with the minicom program discussed in the section“Dialing Out with Communications Programs.”Creating /dev/modem with the lisa CommandUse the lisa command to set up your modem. The lisa command creates a symboliclink, /dev/modem, after you select your modem type and modem serial port. Make sureyou’re running as the root operator, or use the su - command, and then start lisa withits --modem option, like this:# su -c “lisa --modem”


202 Hour 9After you press Enter, you see the lisa dialog box, as shown in Figure 9.1.FIGURE 9.1The lisa administrationprogram configuresthe selectedmodem.Scroll through the list of options to highlight the type of modem used with your computer(nearly all modems today are Hayes-compatible), and press Enter. The lisa commandasks you to select the serial port used by the modem, as shown in Figure 9.2.FIGURE 9.2Scroll through the listof serial ports, andpress Enter to selectyour modem’s serialport.Scroll through the list of serial ports to highlight the serial port for your modem. Afteryou press Enter, lisa asks you to select the highest speed used by your modem. If youhave a 33.6 modem, select 57600 bps. If you have a 56K modem, select 115200 bps (asshown in Figure 9.3).


Using Communications Programs 203FIGURE 9.3Scroll through the listof serial port speedsand press Enter toselect the highestspeed for yourmodem’s serial port.9After you press Enter, you are asked to enter your fax number. Enter your fax numberand press Enter, or just press Enter to finish configuring your modem. The lisa commandquits and makes a symbolic link (discussed in Hour 5, “Manipulation andSearching Commands”) from the selected device to a file called /dev/modem.You can verify this operation by listing the file /dev/modem with the ls command, likeso:# ls -l /dev/modemlrwxrwxrwx 1 root root 5 Dec 29 15:43 /dev/modem -> ttyS0You can do the same thing as lisa from the command line using the lncommand to create the symbolic link yourself. For example, if you have yourmodem connected to COM2, make sure you’re running as root, and enterthe following:# ln -s /dev/ttyS1 /dev/modemThis creates a symbolic link, /dev/modem, which points to the serial port connectedto your modem.Dialing Out with Communications ProgramsThis section covers two communications programs that come with your OpenLinux distribution:minicom and seyon. The minicom program can be used either with or withoutrunning X11. The seyon program must be used while you’re running the X WindowSystem.


204 Hour 9There is also an old communications program, called cu, under the /usr/bin directory.This program is not as friendly as minicom or seyon, but if you’re interested in setting upand trying this program, read the cu man page, and definitely read the uucp softwaredocumentation under the /usr/doc/uucp directory.Setting Up and Calling Out with minicomThe minicom program, created by Miquel van Smoorenburg and located under the/usr/bin directory, is a friendly communication program you can use to dial out andconnect with other computers or BBSs. You can use minicom without running X11. Ifyou’re running X11, you can try to use the xminicom shell script, which is also locatedunder the /usr/bin directory.The xminicom shell script, started by typing xminicom & at the command lineof an X11 terminal window, might not work under the OpenLinux 1.3 distribution.However, here’s a replacement for the xminicom you can use. Log inas the root operator, and then create a text file with your favorite text editor(such as pico, discussed in Hour 14, “Text Processing”), like this:# pico -w xminicomThe -w option disables line-wrapping. Type in the following line:xterm -bg black -fg green -cr red -n minicom -geometry 80x25➥-e minicomThis command line starts an xterm terminal with a black background, greentext, red cursor, the name minicom, use of 80 characters by 25 lines, andrunning the minicom program inside the window. If you’re using pico, pressCtrl+X to save the file. Next, use the chmod command to make the text filean executable program, like this:# chmod +x xminicomFinally, copy the new xminicom command to the /usr/bin directory with thesame or a different name.The first time you use minicom, make sure you’re running as the root operator so you canset up and save minicom’s default file, minirc.dfl, which is created and saved in the/etc directory. Assuming you’re using X11, you can start minicom with the following:# xminicom &This command runs the xminicom script and starts minicom in an X11 terminal window.To get help on how to use minicom, press Ctrl+A, and then press the Z key. Figure 9.4shows the minicom help screen.


Using Communications Programs 205FIGURE 9.4The minicom communicationsprogram featuresbuilt-in help forthe user.9To configure minicom, press Ctrl+A, and press the O key to get to the configure screen.Scroll down and select Serial Port Setup, and press the Enter key. You can then type inthe Serial Device by pressing the A key. Type in the device your modem is connected to,such as /dev/ttyS1, or the symbolic link, /dev/modem, if you created the link. Figure 9.5details the serial port setup screen.FIGURE 9.5Configure the serialport for minicom bypressing a letter andtyping a new value.For example, to change your modem’s speed, press the letter E. A new dialog boxappears, as shown in Figure 9.6. To change the baud rate, press the key correspondingto the letter next to the desired baud rate. When you finish, press Enter to return to theserial setup dialog box.


206 Hour 9FIGURE 9.6Set a new serial portspeed for your modemby pressing a letter.Press the Enter key, select Save setup as dfl, and press the Enter key again, followed bythe Escape key. Your system defaults should be set. You can then try to call out with thefollowing (substituting the correct phone number for XXX-XXXX):ATDTXXX-XXXXThis command uses the modem’s AT command, DT, to dial out using a dial tone (for a fulllist of your modem’s commands, consult your modem’s manual). After you press Enter,your modem dials the phone number. To exit the program, press Ctrl+A, press X, andthen press Enter.If you have a number of phone numbers of other computers to call, you can enter them inminicom’s phone directory. You can also set up minicom to send or retrieve files usingdifferent file transfer programs. For details about these and other features, read theminicom manual page. You can also find documentation under the /usr/doc/minicomdirectory, which contains extensive details of using other features of this program.Setting Up and Calling Out with the seyon X11 ClientThe seyon communications program, by Muhammad M. Saggaf, runs only under the XWindow System and has an extensive list of features. Although seyon is not as simple orinitially friendly as minicom, it does have the following:●●●Built-in helpA built-in telecommunications scripting language to automate calling up and loggingin to other computer systemsA built-in text editor for writing telecommunications scripts


Using Communications Programs 207●●A command-line shell dialog box for running commands, which displays output inthe main communication windowButtons to set up modem speed, parity, and stop bitsIf you created a symbolic link to /dev/modem, the seyon program automatically recognizesand works with your modem. All you have to do to call out and connect withanother computer is to type your AT command string with the phone number to dial outand connect.If you need to tell the seyon client the specific device for your modem, click on the Setbutton in the seyon Command Center window (which appears automatically when youstart the client) to bring up the Settings window. Click on the Port button in the Settingswindow, and type in the name of the device, /dev/cua1 for example, in the Values?window. Figure 9.7 shows seyon and its settings windows.9FIGURE 9.7The X11 client, seyon,has point-and-clickconvenience formodem setup.Main seyon windowMain seyon controlsHelp windowBaud ratesettingsCommunicationsettingsClick on the OK button, and click on the Close button of the Settings window. If youwant to start the seyon program with a default modem speed, number of bits, or parity,edit the file $HOME/.seyon/. This directory is installed automatically when you install theseyon program. You can make changes to the following lines in the startup file:


208 Hour 9...# set baudset baud 19200# can be 5, 6, 7, or 8# set bits 8set bits 8# can be 0 (= no parity), 1 (= odd parity), or 2 (= even parity)# set parity 0set parity 0# can be 1 or 2# set stopBits 1set stopBits 1...If you need help when using the seyon program, you can click on the Help button in theseyon Command Center window. A window pops up with the seyon manual page, andyou can scroll through the text for help (the help screen is shown in Figure 9.7).Setting Up Your Linux System for Dialing InYou can also set up your OpenLinux system so that your computer’s modem answers thephone and enables you to log in. You can then run a bulletin board system (BBS), wordprocessors, and spreadsheet programs. You can even dial out on another line if you haveat least two modems connected to your computer and two phone lines in your home.Most of the details and custom configurations are in the Serial-HOWTO under the/usr/doc/HOWTO and /usr/doc/getty_ps directories, but the three basic steps outlinedhere should work for nearly any modem.Setting up your OpenLinux system to accept incoming calls involves editingthe /etc/inittab file and can potentially hang your system if you make anerror. Always have a backup boot disk handy, and make a copy of the/etc/inittab file before you make changes.First, log in as the root operator, and run minicom. Use the AT command &V to displayyour modem’s profile, or default setup, for example:AT&VACTIVE PROFILE:B1 E1 L1 M1 N1 Q0 T V1 W0 X4 Y0 &C1 &D2 &G0 &J0 &K3 &Q5 &R1 &S0➥&T5 &X0 &Y0 ~Z0


Using Communications Programs 209S00:000 S01:000 S02:043 S03:013 S04:010 S05:008 S06:004 S07:045➥S08:002 S09:006S10:014 S11:095 S12:050 S18:000 S25:005 S26:001 S36:007 S37:000➥S38:020 S44:020S46:138 S48:007 S51:012 S52:012 S53:010 S54:010 S95:000You might see other values for your modem’s internal profile and registers, but you needto make sure that your modem is at least set to the following:E1 Q0 V1 S0=1 &C1 &S0You can set your modem to these values by using the AT command, for example:ATE1Q0V1S0=1&C1&S0&WOK9Note that at the end of the AT command string, using the &W AT command saves themodem configuration as a default. You can also see the OK prompt echoed back to youfrom your modem after entering the string, and you can again issue the AT&V commandto verify the settings.The second step is to create a directory named default under the /etc directory, likethis:# mkdir /etc/defaultThen, use the cp command to copy the file uugetty.autoanswer from the/usr/doc/getty_ps directory, renaming the file to match your modem’s serial portdevice, like so:# cp /usr/doc/getty_ps-2.0.7h/Examples/uugetty.autoanswer➥/etc/default/uugetty.ttyS0This command line shows that the desired serial port is /dev/ttyS0, which correspondsto the DOS COM1 port. Now edit the copied file with your favorite text editor, and lookfor the following line:ALTLOCK=cua2Change the default values of cua2 to match the extension and serial port of your modem,like this:ALTLOCK=ttyS0Save the file and exit your editor.The final step involves a one-line edit of /etc/inittab, the system initialization table. Ifyou look in this file, you see these lines:# less /etc/inittab...# Run gettys in standard runlevels


210 Hour 91:12345:respawn:/sbin/getty tty1 VC linux2:2345:respawn:/sbin/getty tty2 VC linux3:2345:respawn:/sbin/getty tty3 VC linux4:2345:respawn:/sbin/getty tty4 VC linux5:2345:respawn:/sbin/getty tty5 VC linux6:2345:respawn:/sbin/getty tty6 VC linux...Each of the lines represents a different Linux runlevel documented at the beginning ofthe /etc/inittab file. This discussion doesn’t cover runlevels or the details of howOpenLinux boots, but all you have to do to enable dial-in logins for your Linux system isto change the following line:3:2345:respawn:/sbin/getty tty3 VC linuxChange it as follows:3:2345:respawn:/sbin/uugetty ttyS0 38400 vt100Save the file, and use the shutdown command to restart your system. This inittab entrytells OpenLinux to start the getty command after you boot and have getty monitor your/dev/ttyS0 serial port for incoming calls. The value 38400 is not a modem baud rate butcorresponds to an autobaud entry (which works at 38400 or lower speeds) in the/etc/gettydefs file. If you call in to your OpenLinux system, the modem synchronizeswith your calling modem’s speed and then presents a login prompt.When you log in to OpenLinux, the contents of the /etc/issue file areprinted on your display right before the login prompt. This file is created bythe startup script rc.local in the /etc/rc.d directory every time you startOpenLinux as part of the booting process. As the root operator, you can customizethe rc.local script to change the contents of the /etc/issue file ifyou want a different login banner.If you set up your system to accept incoming calls and want to use minicom,run minicom as the root operator. Then configure the serial device nameunder serial port setup in the configuration menu to match the name ofyour modem’s actual device, such as /dev/ttyS1, and make sure the name isnot a symbolic link, such as /dev/modem.


Using Communications Programs 211Sending and Receiving FaxesIf your modem supports fax protocols, chances are that you can send and receive faxesusing OpenLinux. Sending and receiving faxes under OpenLinux involves graphics translationof both received files and files you want to send. Your OpenLinux distribution onthe CD-ROM contains the efax family of fax software and documentation. Have yourmodem’s documentation on hand and read the efax manual pages and documentationunder the /usr/doc/efax directory carefully before you start.Faxing with the efax SystemThe efax system, by Ed Casas, is a simple and easy-to-use fax system that, according toits documentation, is best suited to a single-user, standalone Linux system. This softwareconsists of a series of programs and scripts and supports Class 1 and 2 fax modems.9The system is made up of the following programs:●●●/usr/bin/efax—The faxing program/usr/bin/efix—A graphics conversion program used to prepare text files for faxingor to convert files to different graphics formats/usr/bin/fax—A shell script used to create, send, receive, display, or print faxfilesIf you want to preview or fax PostScript graphics files, you also need to have the gsPostScript interpreter and companion viewer, gv, installed on your system. For viewingreceived faxes, you can use the X11 client xv (discussed in Hour 16, “Graphics Tools”).You need to edit the /usr/bin/fax script to configure faxing. But beforeyou make changes to the script, do yourself a favor and make a copy first. Ifyou make errors or delete the file, you need a copy to reinstall the efaxsoftware.Before you start sending or receiving faxes, take a look at the /usr/bin/fax shell script.This program is the front-end to fax service with efax, but you need to check severalsections in the file to make sure the script is configured properly. For example, the firstsection lists the names of the efax programs:FAX=/usr/bin/faxEFAX=/usr/bin/efaxEFIX=/usr/bin/efix


212 Hour 9These should not pose a problem because the programs are installed in the correct placewhen you installed the software. The next section lists your modem:DEV=modemYou can use the word modem if you created a symbolic link. However, if you have Linuxset up to answer incoming calls for logins, use the actual name of the device (suchttyS0, using our previous example). The next section to check is the type of faxing yourmodem supports:# CLASS=1CLASS=2# CLASS=2.0Comment or uncomment the proper support by using the pound sign (#), but make sureonly one CLASS is listed. For example, if your modem supports the minimal Class 1 faxservice, change these entries to look like the following:CLASS=1# CLASS=2# CLASS=2.0After this, you can customize your faxes with your phone number:# Use only digits, spaces, and the “+” character.FROM=”0 000 000 0000”# Your name as it should appear on the page header.NAME=”Your Name Here”Enter your phone number in the FROM line, such as “1 202 555 1212”, and change theNAME entry to your name, such as “Eric Goldfarb”. Finally, set the default page size forfaxing, for example:PAGE=letter# PAGE=legal# PAGE=a4Comment or uncomment the different page sizes, but use only one. After you finish makingyour changes, try the fax command to test your configuration and modem, using thetest command-line option, for example:# fax test---------------------------------------Please wait, this will take a minute...------------------------------------------ /usr/bin/fax ---


Using Communications Programs 213FAX=/usr/bin/faxEFAX=/usr/bin/efaxEFIX=/usr/bin/efixDEV=cua1CLASS=2...You get a three-page listing of information about your configuration and your modem’sresponse to the fax script’s queries. If you want to see this information at your leisure,redirect the output of the text to a file, for example:9# fax test > faxtest.txtYou can then read about any error messages or problems with missing software.Assuming everything is okay, you can then try faxing a document using the fax command:# fax send -l 8207442 faxtest.txtThe -l option tells the fax program to send a low-resolution (98 lines per inch) fax,using the fax testing information you created. To send a high-resolution (196 lines perinch) fax, no option is needed, for example:# fax send 8207442 faxtest.txtfaxtest.txt.nnn is up-to-date/usr/bin/efax: Tue Dec 29 21:38:02 1998 efax v 0.8a Copyright 1996➥Ed Casasefax: 38:02 opened /dev/modemefax: 38:03 dialing T8207442efax: 38:26 connectedefax: 38:32 session 196lpi 9600bps 8.5”/215mm 11”/A4 1D - - 0msefax: 38:32 header:[98/12/29 21:38 Eric Goldfarb (1 317 123 1234)➥--> 8207442 p. 1/3]efax: 39:06 sent 20+2156 lines, 38961+0 bytes, 34 s 9167 bpsefax: 39:09 sent -> faxtest.txt.001efax: 39:10 header:[98/12/29 21:38 Eric Goldfarb (1 317 123 1234)➥--> 8207442 p. 2/3]efax: 39:37 sent 20+2156 lines, 32200+0 bytes, 27 s 9540 bpsefax: 39:40 sent -> faxtest.txt.002efax: 39:41 header:[98/12/29 21:38 Eric Goldfarb (1 317 123 1234)➥--> 8207442 p. 3/3]efax: 39:50 sent 20+2156 lines, 9635+0 bytes, 9 s 8564 bpsefax: 39:55 sent -> faxtest.txt.003efax: 39:56 done, returning 0As you can see, the fax script automatically recognizes that your file is a text file becauseof the extension. You can also send PostScript graphics files by fax. If you want to testsending such a graphic, try this command line:# fax send 8207442 /usr/share/ghostscript/4.03/examples/tiger.ps


214 Hour 9The fax shell script converts the PostScript graphic to fax format and sends it to theremote fax (albeit in black and white, not color).To set your computer to automatically wait for incoming faxes, you can use the faxscript’s wait command-line option, for example:# fax waitrunning /usr/bin/fax answer/usr/bin/efax: Tue Dec 29 22:38:02 1998 efax v 0.8a Copyright➥1996 Ed CasasYou can also use the background operator to put the shell script in the background. Youcan check on the status of your Linux fax machine with the status command-lineoption, for example:# fax statusUSER PID %CPU %MEM SIZE RSS TTY STAT START TIME COMMANDroot 785 1.8 0.6 1032 404 p2 S < 21:45 0:00 /usr/bin/efax -d/dev/from: /var/spool/fax/modem.785efax: 45:23 opened /dev/modemefax: 45:25 waiting for activityThis shows that the efax command is waiting on the /dev/modem serial port for incomingfaxes. To check whether you’ve received any faxes, you can use the fax command’squeue command-line option, for example:# fax queueFax files in /var/spool/fax :-rw-r--r-- 1 root root 18449 Dec 29 21:51 1229215055.001-rw-r--r-- 1 root root 15001 Dec 29 21:54 1229215350.001-rw-r--r-- 1 root root 16229 Dec 29 21:54 1229215350.002This output shows that two faxes have been received. The first is a one-page fax receivedat 9:51 p.m. The other is a two-page fax received three minutes later. These faxes arewaiting in the /var/spool/fax directory (created automatically when you first run thefax command with the wait command-line option). Each page of a fax is saved as a separatefile, and pages of the same fax have the same filename with the date and time, followedby the page number as an extension.To view a fax, you can use the fax command’s view option. For example, to view theone-page fax, as shown in Figure 9.8, use the fax command with the view option, followedby the fax’s filename, like this:# fax view 1229215350.001/var/spool/fax/1229215055.0011229215055.001 ...


Using Communications Programs 215FIGURE 9.8The fax commandautomatically runs theX11 xv graphic programto view or printyour incoming faxes.9To view all the pages of a fax, use a wildcard, such as an asterisk (*), with the first partof a multiple page fax name. To use the previous two-page fax as an example, type acommand line like this:# fax view 1229215350.*The fax program cycles through the files and displays each page with the viewer youspecified in the fax shell script. You can use the X11 xv client to print your faxes, or youcan try the fax command’s print command-line option to print your faxes, for example:# fax print 1229215350.001/var/spool/fax/1229215055.0011229215055.001 ...This prints the first page of the incoming fax. You can print all the pages of a multiplepage fax with the following:# fax print 1229215350.*If you want to delete a fax, use the rm command, for example:# rm /var/spool/fax/1229215350.*


216 Hour 9If you want, you can try to use the fax command’s rm command-line option.However, this is potentially dangerous and might delete files in the currentdirectory, especially if you use a plain asterisk (*) as a filename. You shouldspecify the fax filenames explicitly when using this command-line option.The efax family of commands is a simple and versatile way to send and receive faxeswith Linux. The fax command has more commands than are documented in the manualpage, including support for voice modems and creating cover pages. Read the fax commanditself for more details.Sending Fax Documents with the ksendfax ClientIf you use the K Desktop Environment, or KDE, you can use ksendfax to quickly selectand send a fax. Although not included with the KDE distribution on your OpenLinuxCD-ROM, you can download a copy from http://www.kde.org. Follow the links to theApplications section and download the file ksendfax-0.3.1.tar.gz. Building andinstalling ksendfax is easy. First log in as the root operator and decompress the file withthe tar command, like this:# tar xvzf ksendfax-0.3.1.tar.gzChange the directory into the ksendfax directory, and then build and install the packageby using the configure and make commands, like this:# configure; make installThe ksendfax client is installed. If you’re logged in as the root operator, start ksendfaxby clicking the Application Starter button on your desktop’s panel, selecting the Graphicsmenu, and then clicking the KsendFax menu item. However, if you’re not logged in asthe root operator, start the program from the command line of a kvt terminal window,like this:# su -c ksendfaxThe main dialog box appears. Type in a filename to send in the File Name section, orclick the Browse button to choose a file. Next, type in the remote fax machine’s numberin the Fax no. field, as shown in Figure 9.9.To configure ksendfax with your favorite fax program, such as efax, click thePreferences menu item under the Options menu. Next, type in the command string forksendfax to use to send a fax (as shown in Figure 9.10). For example, to use the faxscript with ksendfax, enter the following:/usr/bin/fax send ‘@@Phone’ ‘@@FName’


Using Communications Programs 217FIGURE 9.9Using the ksendfaxclient is an easy wayto send a fax.9When you finish, click the OK button. To send the fax document, press Ctrl+S, click theSend Fax button, or click the Send Fax menu item under the File menu. A small dialogbox appears, showing the communications progress of your faxing operation.To find out how to configure ksendfax for other fax programs forOpenLinux, click the Help menu item under the ksendfax Help menu. Thereare tips and tricks on getting ksendfax to work with at least three differentfax software packages.FIGURE 9.10To use ksendfax withyour fax program, youmust enter a commandstring in thePreferences dialogbox.


218 Hour 9Sending Fax Documents with mgetty+sendfaxmgetty+sendfax is a package of software that uses the mgetty command, which youinstall in /etc/inittab much like the uugetty example shown previously, and the sendfaxprogram, which is used to send faxes. The installation and configuration of this softwareis a little more complicated than setting up efax. This section shows you how to setup, configure, and use this software to send and receive fax documents with yourmodem.This package of software includes many files (too many to list here). The examples inthis section concentrate on the important ones and show you how to configure the sendfaxsoftware and quickly send a fax. Your first step is to make sure you’re logged in asthe root operator. You need to change the directory to the mgetty+sendfax directoryunder the /etc directory. You see a number of files there, for example:# ls -Adialin.config fax.deny faxrunq.config mgetty.config voice.conffax.allow faxheader login.config sendfax.configYour first job is to create the fax.allow and fax.deny files if they do not exist. In thefax.allow file, enter the names of users you want to enable to have fax service. Enter atleast two names: root and your username.Next, edit the faxheader file, and enter your name and phone in the sample header line,for example:FAX FROM: John H. Doe 1 202 555 1212 TO: @T@ PAGE: @P@ OF @M@You should use the comment character, #, when you make changes to thesendfax configuration files, and retype your changes on a new line. Thissaves you trouble if you make mistakes and need to return the file back toits original state.The sample header line appears across the top of your faxed pages on the receiving faxmachine. Next, edit the sendfax.config file, then look for the fax-devices section, andchange the name of the device your modem is attached to (such as /dev/ttyS1 forCOM2), for example:# which devices to use for outgoing faxes#fax-devices tty4c:tty4dfax-devices ttyS1


Using Communications Programs 219This tells the sendfax programs that your fax modem is attached to /dev/ttyS1. Next,enter your fax number, which is sent to the remote fax machine, for example:# which fax number to transmit to the receiving station#fax-id 49 89 xxxxxxxxfax-id 1 317 123-1234This identifies your fax machine to the remote fax. You also need to enter the type ofdialing you want to use when sending a fax, for example:# which command is used to dial out? (Could be ATD, ATDP, ATX3D0W...)#dial-prefix ATDdial-prefix ATDT9This tells the sendfax software that you want to dial out using tone dialing. Save the file,and exit your text editor. At this point, you’re almost ready to start sending faxes.To send a one-page fax using the sendfax program, you must first convert a text file intothe Group 3 fax format. You can do this by using the graphics conversion program pbmtext,found under the /usr/bin directory with the pbm2g3 program, for example:# cat myfile.txt | pbmtext | pbm2g3 > myfile.g3This pipes the file myfile.txt through the pbmtext command, which outputs a portablebitmap graphics format into the pbm2g3 command, which then converts the piped streamof characters into the fax graphic format. After you do this, you can send the file (assumingyou’re the root operator) with the following:# /usr/sbin/sendfax -v -l ttyS1 -C cls2 -r 5551212 myfile.g3Trying fax device ‘/dev/ttyS1’... OK.Dialing 5551212... OK.sending ‘myfile.g3’...This runs the sendfax program. The -v command-line option tells sendfax to give somefeedback during the faxing operation. I specify the ttyS1 serial port with the -l optionand send the fax through a Class 2 fax modem with -C cls2 command-line option. Thephone number 555-1212 is specified with the -r option, and the file, myfile.g3, is thefile you created with the preceding command-line pipe.Unlike efax, the sendfax command only supports Class 2 fax modems. If youhave a Class 1 modem, use the fax shell script.


220 Hour 9You can also set up your Linux system to automatically receive incoming faxes with themgetty program. Used much like the uugetty program, mgetty also requires at least onechange to its configuration file in the /etc/mgetty+sendfax directory. The change youcan make (as the root operator) is to edit the phone identification entry in the filemgetty.config, for example:# set the local fax station id#fax-id 49 89 xxxxxxxxfax-id 1 317 123 1234This sets the local fax machine phone number. After you do this, edit the /etc/inittabfile as described earlier, and use mgetty to listen to the serial port, for example:3:2345:respawn:/usr/sbin/mgetty -s 38400 ttyS1As mentioned before, any edits of the /etc/inittab file are potentially hazardous.Always have a spare boot disk and make a backup of the file first.After you make this change, save the file, and reboot the computer. Now, not only areyou able to receive faxes, but you can also dial in from an outside line and run Linuxprograms. To see if any faxes have arrived, you have to explicitly look at the/var/spool/fax/incoming directory, for example:# ls -A /var/spool/fax/incomingfn4878f9aS1-_IBM-APTIVA-M61-_.01 fn4878f9aS1-_IBM-APTIVA-M61-_.02This shows that there is a two-page fax awaiting reading. You can read the faxes by firstconverting them to the portable bitmap file format, for example:# cat /var/spool/fax/incoming/*.01 | g32pbm > faxpage1.pbmAfter you convert these fax files to the portable bitmap format, you can then use the X11xv client or the ImageMagick display X11 program to read or print your faxes.As you can see, you have several choices of software when faxing documents withOpenLinux. The sendfax program has many other options. Read its man page and documentationunder the /usr/doc/mgetty+sendfax directory to find out the details.SummaryThis hour showed you how to configure your OpenLinux system to work with your computer’smodem. You also learned how to set OpenLinux to answer incoming calls andhow to send and receive fax documents.


Using Communications Programs 221Q&AQ I’d like to learn more about modems and faxing. What resources are there?A First, read the documentation for the efax and mgetty+sendfax programs to learnmore about using these programs with OpenLinux. If you’d like to read a good,non-specific operating system overview of using modems and modem software,read Peter Chen’s What You Need to Know about Modems, athttp://www.vix.com/flexfax/Modems-PeterChen.Q I’d like to turn off the high-pitched squeal my modem makes when itconnects. How do I do this?A Read your modem’s documentation for the specifics, but in general, the ATM0 commandturns off your modem.Q I want to hear the modem dial out and connect, but I don’t want it to be soloud!A Try using the ATM1 command to enable sound, and then try to use the ATLx command,where x represents a number from 0 (low) to 3 (high) speaker volume. Thisfeature is not supported by all modems.Q My modem sometimes disconnects during my on-line sessions!A If you have call waiting, it is possible that an incoming call can disrupt yourmodem. Try adding *70 to the front of any dial string (such as ATDT*70) to disablecall waiting.9Exercises1. Try to call a local Bulletin Board Service (BBS) and connect with the seyon orminicom program.2. Create a graphic, then save it in PostScript format, and try to send it as a fax.See Hour 16 for more information on creating graphics during your OpenLinuxsessions.


HOUR 10Connecting to theInternetIn this hour, you’ll learn how to set up your Linux system to connect to theInternet using the serial line Point-to-Point Protocol known as PPP.Connecting to the Internet is one of the biggest hurdles many newOpenLinux users face after installing OpenLinux, configuring OpenLinux towork with their computer’s sound card, and configuring the X WindowSystem to work with their computer’s graphics card. After following thedirections in this lesson, you can connect to the Internet through your InternetService Provider (ISP), and do email, Web browsing, and file transfers.This hour shows you how to connect to your ISP manually in the simplest,most basic way possible. I also point you to sources of information for moredetails so that you can troubleshoot or fine-tune your connection. You’ll thenlearn how to use two easy-to-use graphical interface programs, kppp andxisp, to set up, start, and stop your PPP connection.


224 Hour 10I’m recommending you use a PPP connection for a number of reasons:●●●●●●●Although it’s complex, it is easy to set up.You can find documentation and details on the protocol in a number of HOWTOdocuments.You can read the comp.protocols.ppp newsgroup about PPP and thecomp.os.linux.networking newsgroup for specific Linux information.It offers security on both ends of the connection.It is a common protocol supported by nearly all ISPs.OpenLinux comes with several programs you can use to set up your PPP connection.It is flexible enough to accommodate different types of connections.This hour starts by listing some of the hardware and software prerequisites forOpenLinux and then asks for some necessary information you need from your ISP. Usingthat information, you’ll first create a set of customized scripts you can use to manuallystart or stop your connection. I’ll then show you how to set up a PPP connection usingtwo graphical interface programs: the kppp client for the K Desktop Environment and thexisp graphical interface client for X11.You’ll also learn about some handy utilities you can use to diagnose your connection andsome other programs you can use to monitor your sessions.Hardware You NeedYou probably already have all the hardware you need: a modem, a modem cable if yourmodem is external, and a phone line. However, you must have a modem you can usewith OpenLinux. You cannot use any of the following modems with OpenLinux:●●●●●●●●●3Com/U.S. Robotics 56K V.90 Winmodem3Com/U.S. Robotics 56K Winmodem PC Card3Com/U.S. Robotics Sportster 33.6 WinmodemAztech Systems 56K PCI modemCardinal 56K Windows Fax modemDiamond SupraMax 56K ISA/PCI modemsHayes 56K Accura V.90 PCI Win modemMotorola FM56 ISA/PCI modemsMwave adapters (but might work as sound card)


Connecting to the Internet 225●●●●Viking Components 56K ISA Windows modemWinStorm 56K PCI Data/Fax Speaker phone modemZoltrix Phantom/Spirit 56K modemsAny other modem requiring Windows-only softwareIf you plan to purchase a modem to use with OpenLinux, do not buy anymodem considered a winmodem. These useless pieces of junk were recentlyintroduced into the computer industry by manufacturers to save money andincrease profits in hardware production. Winmodems use fewer chips than“real” modems and depend on operating system-specific software drivers(and your computer’s CPU) in order to work. Unfortunately, many computermanufacturers (especially those that make and sell laptop computers) do nottell you that a provided or built-in modem does not work with any operatingsystem other than Windows. Beware! If you’re not sure about whatmodem to buy, get an external modem that works with any operatingsystem, not just Windows.10One of the great things about OpenLinux is that it runs well even on older computers.Although graphics-intensive applications such as X can tax the capabilities of older,slower PCs, you don’t need X11, a fancy display monitor, or a 16MB VRAM accelerated3D video card to use PPP. You do, however, need a working serial port and modem.If you’re able to use your modem under Linux to dial out and connect using the minicomprogram or C-Kermit, chances are you won’t have any problems. If you’re using a laptopwith a PC Card modem and the cardmgr PCMCIA device manager recognizes and initializesyour modem, you should be okay, as any recognized card is identified and listedwhen you boot OpenLinux.One way to check for serial-port recognition is to use the dmesg program, which displaysthe boot messages shown when you start OpenLinux. Run the dmesg program (pipedthrough the less command), and look for lines in the output describing serial ports similarto these:# dmesg | less....tty00 at 0x03f8 (irq = 4) is a 16550Atty01 at 0x02f8 (irq = 5) is a 16550Atty03 at 0x02e8 (irq = 3) is a 16550A....


226 Hour 10Using dmesg is convenient, especially if the boot messages scroll by too fast for you toread. These lines show that three serial ports were found using the devices ttyS0, ttyS1,and ttyS3. Another consideration is your modem’s speed. You might remember when2400- or 9600-baud modems were the greatest innovation since touch-tone dialing. Ifyou’re still using an older modem and refuse to upgrade to the newer V.90 modems untilmodel prices drop, you can still connect to the Internet with PPP; most older modemsautomatically synchronize with the newer models lodged in your ISP’s modem bank.Want to lessen the chances of problems when connecting with your ISP?Find out what modems your ISP uses, and buy the same model for yourcomputer system.If you want to listen to radio stations, watch live video, or upgrade your Red Hat Linuxsystem through your phone connection, you want the fastest modem and Internet connectionyou can afford. Although I don’t advocate you try to get any work done through a1200- or (shudder) 300-baud connection (which borders on masochism, but can be done,as ATM machines prove), you can use email, FTP, and text-only Web browsing at 9600speeds.It’s up to you, and besides, isn’t that what OpenLinux is all about—freedom of choice?Linux Software You NeedIn order to set up your PPP connection, you need to make sure that your Linux kernelsupports PPP. You might have PPP support compiled into the kernel or loaded as a modulewhen you start Linux. One of the ways to check to see if PPP support exists on yoursystem is to again use dmesg:# dmesg | less...PPP: version 2.2.0 (dynamic channel allocation)TCP compression code copyright 1989 Regents of the University of➥CaliforniaPPP Dynamic channel allocation code copyright 1995 Caldera, Inc.PPP line discipline registered....You see similar lines.


Connecting to the Internet 227By default, OpenLinux loads PPP support via a loadable Linux kernelmodule. If you do not see PPP, you must either recompile the kernel withbuilt-in PPP support, build the PPP module and use the insmod command toload the driver, or make sure you have selected the proper Linux kernel duringyour OpenLinux installation (with the word “modular” in its filename).You also need networking support enabled, especially TCP/IP. See Hour 2,“Installing Linux,” for details.You also need the chat program, found under the /usr/sbin directory, and part of thepppd daemon software package. The chat program is used during the dialing process todial out and connect to your ISP’s modem. Along with chat, you need the pppd daemon,also installed in the /usr/sbin directory. If pppd is installed, you can find a ppp directoryunder the /etc directory containing some or all of the following files:10# ls /etc/pppchap-secrets options ppp-on-dialerconnect-errors pap-secrets ppp-onip-upppp-offIf you don’t see the ppp-on or ppp-on-dialer files, you can copy them from the/usr/doc/ppp-2.2.0f directory.The first setup you learn during this hour requires you to make changes to the ppp-onfile, which is an executable script. Next, you might want to check to see if the fileresolv.conf exists under the /etc directory. If it doesn’t, don’t worry; it’s a short filecontaining one or two lines, and I show you what to type in the file.Finally, you might want to see if you have the ifconfig, minicom, netstat, ping, androute commands on your system. You use these later in this chapter to run some tests onyour connection.Need to look for a command? Try the whereis or locate commands like so:whereis ifconfig to see where the ifconfig command is located on yoursystem or locate ifconfig to print a list of any files or directories usingifconfig.


228 Hour 10Information You Need from Your ISPIn order to connect to the Internet using PPP through your ISP, you need to first, obviously,have a PPP account. When you sign up for your service, your ISP account representativemost likely assumes you want a setup and software for either a Windows orMacintosh computer system. If you say “Neither. I’m using Caldera’s OpenLinux,” andthe response you get is either a blank stare, dead air on the phone, or “What’s Linux?”don’t panic!You might get lucky. Linux is growing in popularity, and many ISPs in the U.S. andaround the world recognize and support Linux users. If your ISP is aware of Linux, askfor the minimum system requirements, any setup guides, or install tips. This book’s CD-ROM contains the latest, stable releases of the software you need, so you don’t have toworry anyway.Assuming your ISP doesn’t know about Linux, here’s what you need from your ISP:●●●●Your account information, meaning your username (login name) and password, soyou can log in to your ISP’s computer.Your ISP’s modem connect number(s), so you can dial out and connect.Whether your ISP assigns you a static Internet Protocol (IP) address or assignsyour IP address dynamically (the examples in this hour assume dynamic addresses,but I show you where you can make changes for a static IP address).The IP addresses and names of your ISP’s primary Domain Name Server and secondaryDomain Name Server. This information goes into the /etc/resolv.conffile (as explained in this chapter’s section “Editing the resolv.conf File”) in thefirst example.The DNS IP addresses are in the form of four 8-bit numbers, and look somethinglike 205.198.114.1 or 205.198.114.20. These are the address oraddresses of the servers used or maintained by your ISP that translate hostnames,such as metalab.unc.edu, into numeric IP addresses, so you can connect,query, or address other computers and users around the world. Thissection doesn’t go into the details about the mechanics of IP addressing, andthis book does not cover all aspects of networking under Linux. If you wantmore complete details, see the Linux Network Administrators Guide underthe /usr/doc/LDP/nag directory.


Connecting to the Internet 229●●The name or IP address of your ISP’s mail server, so you can send and retrievemail (you might also need a separate username and password for your ISP’s mailserver). You need this information in Hour 11, “Configuring Internet Email.”The name or IP address of your ISP’s news server, so you can read Usenet newsand subscribe to newsgroups. You need this information in Hour 12, “ConfiguringInternet News.”Finally, ask for the Uniform Resource Locator, or URL, of your ISP’s World Wide Webhome page and your home page, if your ISP provides this service. Your ISP’s Web pagesmight provide technical bulletins, help files, or other information that helps in troubleshootingconnections.Setting Up a PPP Connection ManuallyArmed with this information, you can now learn how to specify your ISP’s DNS serverand how to create or edit your connection script, ppp-on. Although specifying your ISP’sDNS server (s) is not necessary to initiate or maintain your connection, you need thisinformation later with the kppp and xisp clients and when you learn about Internet emailand news.10Editing the resolv.conf FileThis is a simple process. First, make sure you’re logged in as the root operator. Thenlook in the /etc directory for a file called resolv.conf. If it’s there, open it with yourfavorite text editor, such as pico (see Hour 14, “Text Processing”), and add the searchkeyword, followed by the domain name of your ISP, and the IP addresses of your ISP’sDNS servers. If your ISP only has one, that’s okay. If your ISP has more than one, that’sokay too. Create and open the file, like so:# pico /etc/resolv.confEnter the lines, using this format:search erols.comnameserver 205.198.114.1nameserver 205.198.114.20Close the file. That’s all there is to do! Next, you create or edit a script you can use tostart a PPP connection.


230 Hour 10Editing the PPP Connection ScriptsBefore you start, you should know that using this script is only one way to start a PPPconnection. This approach requires you to be logged in as the root operator. You alsolearn a much simpler approach later in this chapter.I don’t go into the detailed methods because I want to get you online quickly. When youget a working connection, I suggest you take a look at the pppd manual pages, RobertHart’s PPP-HOWTO under the /usr/doc/HOWTO directory, Al Longyear’s PPP-FAQunder the /usr/doc/FAQ/PPP-HOWTO directory, the ISP-Connectivity mini HOWTO, orany pertinent sections in the Linux Network Administrators Guide under the/usr/doc/LDP/nag directory.The first thing to do is to make sure you’re logged in as the root operator. Then, look inthe /etc/ppp directory for a file called ppp-on. If it’s there, first make a copy (you cancall it anything you want), or rename ppp-on to ppp-on.org. If ppp-on isn’t there, copyit from the /usr/doc/ppp-2.20f directory. Listing 10.1 shows you parts of the script,written by Al Longyear:LISTING 10.1THE ppp-on CONNECTION SCRIPT...TELEPHONE=555-1212 # The telephone number for the connectionACCOUNT=username # The account name for logon (as in ‘George Burns’)PASSWORD=password # The password for this account (and ‘Gracie Allen’)LOCAL_IP=0.0.0.0 # Local IP address if known. Dynamic = 0.0.0.0REMOTE_IP=0.0.0.0 # Remote IP address if desired. Normally 0.0.0.0...DIALER_SCRIPT=/etc/ppp/ppp-on-dialer...exec /usr/sbin/pppd lock modem crtscts /dev/modem 57600 \asyncmap 20A0000 escape FF $LOCAL_IP:$REMOTE_IP \noipdefault netmask $NETMASK defaultroute connect \$DIALER_SCRIPT &You need to change several parts of this script. For the most part, you only need to makea few changes. Some of the critical elements are the following:TELEPHONE—Enter your ISP’s modem connect number here.ACCOUNT—Enter your username or login name (usually assigned by your ISP).PASSWORD—Enter your password here (usually assigned by your ISP).


Connecting to the Internet 231DIALER_SCRIPT—Enter the complete pathname of your dialing script, which uses thepppd daemon’s companion chat program. The chat program does the dialing, connecting,and login for you. If you can’t find a copy of this script, which is calledppp-on-dialer, look under the /usr/doc/ppp-2.2.0f directory. (Listing 10.2 showsthe ppp-on-dialer script.)If your ISP’s computer does not present a login: and password: prompt, youhave to change the ogin: and assword: strings in this script to match theones from your ISP.LISTING 10.2THE ppp-on-dialer DIALING SCRIPT...exec /usr/sbin/chat -v \TIMEOUT 3 \ABORT ‘\nBUSY\r’ \ABORT ‘\nNO ANSWER\r’ \ABORT ‘\nRINGING\r\n\r\nRINGING\r’ \‘’ \rAT \‘OK-+++\c-OK’ ATH0 \TIMEOUT 30 \OK ATDT$TELEPHONE \CONNECT ‘’ \ogin:--ogin: $ACCOUNT \assword: $PASSWORD10Next, examine the pppd command line in the ppp-on script, and change /dev/modem tomatch the device your modem is connected to. If you want, you can use the approachoutlined in Hour 9, “Using Communications Programs,” to make a symbolic link fromyour modem’s serial port to /dev/modem.If you have a 14.4 modem, use 19200 as the numeric value; if you have a28.8 or 33.6 modem, try 57600. If you have a 56K or V.90 modem, try using avalue of 115200. You might be able to connect at a faster speed, especiallywith newer modems.


232 Hour 10If your ISP assigns IP addresses automatically (dynamic IP addresses, oraddresses that might be different each time you log in), you’re all set. But ifyou must connect to a specific (static, or fixed) IP address, you need toremove the noipdefault option from the pppd command line in listing 10.1.You also need to change the $REMOTE_IP string to the IP address provided byyour ISP (you can do this in the pppd command line or further up in thescript in the $REMOTE_IP variable).Finally, make sure both the ppp-on and ppp-on-dialer scripts are executable by checkingwith ls -l or modifying with the chmod program:# chmod +x /etc/ppp/ppp-on*You’re now ready, assuming your modem is connected to your computer and your phoneline is connected to your modem, to try a connection.Manually Starting and Stopping PPPConnectionsThis section shows you how to connect to your ISP and start your Internet session. Thereare several ways to do this. The first way you see is the most basic way to connect withthe minicom program without using the scripts you just created. Then, you learn how touse your PPP connection script, ppp-on.The minicom program, discussed in Hour 9, is a communications program youcan use to dial out and connect to other computers or information services,such as bulletin board systems, or BBSs. See the minicom manual page formore information.Using minicom to ConnectUsing minicom to connect with your ISP has an advantage in that your account informationand password are not recorded in the system logs under the /var/log directory. Youcan use minicom each time you want to use the Internet, but you might find the processtedious. I’m showing you this approach first, because you might find it useful in verifyingthat the login and password entries you specified in your ppp-on-dialer script work.


Connecting to the Internet 233Here is the step-by-step method. You can do this because one of minicom’s features isthat it has the capability to quit without resetting your modem. This means you can useminicom to dial out, connect, and then quit, enabling you to start your PPP session withthe pppd daemon. Make sure you enter your ISP’s DNS server information in/etc/resolv.conf first! Here’s how:1. Run minicom.2. Type ATDT, followed by your ISP’s modem number.3. Wait for the connection and your ISP’s prompt, and then log in with your usernameand password. Note whether the login and password prompts are different. If so,write them down so you have the information you need to edit the chat programoptions in your ppp-on-dialer script. After you type your password and pressEnter, you might see a string of garbage characters sent back from your ISP’s computer;this is normal and indicates your ISP’s computer has started PPP.4. Press Ctrl+A, and then press Q to exit minicom without a modem reset.5. From the command line, log in as the root operator, and then type the following:10# pppd -d detach /dev/modem &After a second or so, you’re connected! (Well, check first—try some of the programs discussedlater.)Using Your ppp-on Script to ConnectUsing the ppp-on script to establish your PPP connection is easy. Make sure you’relogged in as root, and type the following to start the connection:# /etc/ppp/ppp-onYou don’t have to log in as the root operator to start a PPP connection withthe ppp-on script. Use the su command instead, like so:su -c /etc/ppp/ppp-onPress Enter. After you enter the root password, the script runs.Notice that you have to type the entire pathname to the script. If your connection works,you can either move the script to the /usr/local/bin directory or make a symbolic linkto the script with the following (you can call it whatever you want; just don’t use pppd):# ln -s /etc/ppp/ppp-on /usr/local/bin/start-ppp


234 Hour 10After you start the script, you can hear your modem connect to your phone line, dial out,and then connect with your ISP’s modem. After several seconds, you are connected!Here’s a tip: if you don’t like the sound of your modem or find it disruptive(especially if you have to work in a quiet environment), use your modem’sAT command set to turn off the modem’s speaker. Run minicom, then typeATM0, hit the Enter key, and then type AT&W, followed by the Enter key tosave the settings. Now you can start stealth PPP connections! The first commandturns of the speaker; the second command saves this setting to themodem’s NVRAM (nonvolatile RAM).Stopping the PPP ConnectionTo stop your PPP session, use the ppp-off script, found in the /etc/ppp directory. Touse it, type the following:# /etc/ppp/ppp-offThis script works by finding your network interface, ppp0, which you can test by usingsome of the programs in the next section and then using the kill command to kill theprocess ID of ppp0 (the kill command is discussed in the next hour).If you’re interested in the details on setting up other serial-line connections,such as Serial-Line IP, or SLIP, look under the /usr/doc/slip-login-2.1.2directory.Configuring a PPP Connection with kpppThe kppp client included with KDE is an easy-to-use graphical interface you can use toconfigure, start, and stop PPP connections. This section shows you how to configurekppp to work with an ISP. You must be running X11 to use kppp, but you can use kpppwithout KDE.To start the kppp client, type kppp, and press Enter at the command line of an X11 terminalwindow. If you’re using KDE, click the Application Starter button on your desktop’spanel, and then click Kppp from the Internet submenu. The kppp dialog box appears, asshown in Figure 10.1.


Connecting to the Internet 235FIGURE 10.1The kppp client can beused to set up, startup, and shut downPPP connectionsduring X11 sessions.Configuring Your kppp ConnectionClick the Setup button (shown in Figure 10.1) to start your configuration. The kpppConfiguration dialog box appears. To define a new connection, click the New button. Inthe New Account dialog box, as shown in Figure 10.2, type a connection name andphone number.10FIGURE 10.2The kppp client’s NewAccount dialog box isused to define PPPconnections.When you finish, click the IP tab at the top of the dialog box. If you have a static(assigned) IP address, click the Static IP Address button, and then enter the address. Ifyou have a dynamic (randomly assigned) IP address, click Dynamic IP Address. Whenyou finish, click the DNS tab to display the DNS Servers entry dialog box, as shown inFigure 10.3.First, type your ISP’s domain name, and then enter the first IP address of your ISP’sDNS server. Next, click the Add button to add the IP address to the kppp list. Repeat thisstep until you enter all the DNS IP addresses. When you start a connection with kppp,the program temporarily adds these addresses to /etc/resolv.conf and then deletes theentries when you close the connection. When you finish entering the DNS addresses,click the Login Script tab in the dialog box.


236 Hour 10FIGURE 10.3The kppp client’s DNSServers dialog box isused to define theaddresses of yourISP’s Domain NameService computers.This is a critical step in configuring your PPP connection. Click in the blank field next tothe Expect button (as shown in Figure 10.4), type the phrase ogin:, and click the Addbutton. This tells kppp to look for part of the phrase login: after it connects with yourISP’s computer.FIGURE 10.4The kppp client’sLogin Script dialogbox is used to define aseries of expectedphrases and responsesto log you into yourISP’s computer andstart your PPPconnection.Next, click the Expect button, and select the Send item from the pop up menu (as shownin Figure 10.5). Type your username (assigned by your ISP), and click the Add button.This tells kppp to send your username when it detects the phrase ogin: during theconnection process.


Connecting to the Internet 237FIGURE 10.5The kppp client sendsyour username andpassword according toexpected phrases in itslogin script.Next, again select the Expect item, type ssword: (to represent the phrase password: sentby your ISP’s computer), and click the Add button. Finally, select the Send item, typeyour password (assigned by your ISP), and click the Add button. When you finish, clickOK. You return to the kppp main Configuration dialog box. Click the Device tab to setthe modem device you want kppp to use.10In the dialog box (as shown in Figure 10.6), click each pop-up menu to select theModem Device, Flow Control, Line Termination, Connection Speed, Modem Lock File,and Modem Timeout. If you have a 56K or V.90 modem, the settings in Figure 10.6 workjust fine. When you finish, click the Modem tab.FIGURE 10.6The kppp client’sDevice dialog box isused to define yourmodem, its speed, andother settings.


238 Hour 10To see exactly what prompts are used by your ISP, follow the preceding stepsin the section “Using minicom to Connect.” Write down the prompts, anduse them when you build your login script with kppp. This helps you later ifyou are having trouble and need to figure out what’s going on during aconnection.In the Modem tab’s dialog box, click the Modem Commands button to view the defaultmodem commands used by kppp. If your modem requires any special settings, enter theproper commands in the Initialization String field as shown in Figure 10.7. When youfinish, click the OK button.FIGURE 10.7Configure your modemin the kppp EditModem Commandsdialog box by enteringAT commands orresponse strings.To finish your kppp configuration, click the PPP tab to view the kppp Setup dialog box,as shown in Figure 10.8. Use the different settings in this dialog box to control how kpppacts after it starts or stops or when you stop your X11 session. For example, if you selectDock into Panel on Connect, a tiny modem icon with flashing red and green send andreceive lights docks into the far right of your desktop’s panel when you connect. Whenyou finish, click OK. You’re now done configuring kppp!


Connecting to the Internet 239FIGURE 10.8The kppp client’s PPPdialog box is used todetermine how kpppshould act dependingon where you are inyour X11 session.Starting and Stopping PPP with kpppTo start your PPP connection, select your ISP from the kppp drop-down menu, and thenclick the Connect button (as shown in Figure 10.9). If you select the Show Log Window,a window appears as kppp attempts the connection. This is a handy diagnostic tool youcan use to watch the progress and conversation between kppp and your ISP’s computer.When the PPP connection is made, kppp docks into your desktop’s panel as a smallmodem icon. The kppp client also makes temporary domain and name server entries inyour OpenLinux system’s /etc/resolv.conf file.10FIGURE 10.9Click the Connectbutton in the kpppclient’s main dialogbox to start a PPPconnection.To get information about your PPP connection, right-click the modem icon on your desktop’spanel, and then click the Restore menu item. A small dialog box appears with thename of your ISP. To view details about your connection, click the Details button, and alarge dialog box appears, as shown in Figure 10.10.


240 Hour 10FIGURE 10.10The kppp client featuresseveral dialogboxes with informationabout your PPPconnection.To shut down your PPP connection, either click the Disconnect button in the small dialogbox or select Disconnect after right-clicking the kppp icon in your desktop’s panel.Configuring a PPP Connection with xispThe xisp client included with OpenLinux is another easy-to-use graphical interface youcan use to configure, start, and stop PPP connections. This section shows you how toconfigure xisp to work with an ISP. You must be running X11 to use xisp.To start the xisp client type su -c “xisp&” and press Enter at the command line of anX11 terminal window. After entering the root operator password, the X-ISP dialog boxappears, as shown in Figure 10.11.FIGURE 10.11The xisp client can beused to set up, start up,and shut down PPPconnections duringX11 sessions.


Connecting to the Internet 241Configuring a New xisp AccountSelect the Options menu and click Account Information to start your configuration. Thexisp Account Information dialog box appears (as shown in Figure 10.12). To define anew account, click a blank line under ISP name. A small dialog box appears. Type yourISP’s name, and click OK. Enter the ISP’s phone number, your account name, and youraccount’s password. Note that your password is not echoed on the screen, so make sureto type it in correctly! Also, if you need any other options, such as password authentication,click the appropriate buttons. When you finish, click OK.FIGURE 10.12Use the xisp client’sNew Account dialogbox to define a newPPP account.10Next, select the Options menu, and click the Dialing and Login menu item (as shown inFigure 10.11). The xisp Dialing and Login dialog box (similar to the kppp dialog boxshown in Figure 10.5) appears. Enter the expected characters and responses for your ISPand select other desired options from the dialog box, as shown in Figure 10.13. Note thatyour password in the send column is echoed back to the screen (so make sure no one islooking over your shoulder)! When you finish, click the OK button.FIGURE 10.13The xisp clientautomates PPPconnections with loginscripts similar to thosefor the kppp client.


242 Hour 10Next, select the Options menu and click the Communications Options menu item (asshown in Figure 10.11). The Communications Options dialog box appears as shown inFigure 10.14. Select the appropriate modem device and baud rate. Most of other defaultsettings can be used as is. When you finish, click the OK button.FIGURE 10.14Select the appropriatecommunicationsoptions for yourOpenLinux systemwhen configuring anew account with thexisp client.Now, select the Options menu again, and click the TCP/IP Options menu item (as shownin Figure 10.11). The TCP/IP Options dialog box appears as shown in Figure 10.15. Ifyour ISP assigns IP addresses dynamically, simply click the Yes button for ip-if/up, andthen type the primary and secondary DNS addresses for your ISP. When you finish, clickthe OK button. You’re done!FIGURE 10.15The TCP/IP xispdialog box is used todefine the addressesof your ISP’s DomainName Servicecomputers.Although xisp is supposed to manipulate your system’s /etc/resolv.conffile, it might not. You might have to put your ISP’s DNS addresses in your/etc/resolv.conf before starting your connection. This information isabsolutely necessary for Web browsing and other Internet activities.


Connecting to the Internet 243Starting and Stopping PPP with xispTo start your PPP connection, start xisp, and then click the Connect button. As xispattempts to make the connection, the progress and status scroll by in the main xisp window(as shown in Figure 10.16). When you are logged in to the Internet, your IP addressappears in the IP: field. The xisp client also keeps track of your time online and yourconnection speed.FIGURE 10.16Click the Connect buttonin the xisp client’smain dialog box tostart a PPP connectionand Internet session.10To shut down your PPP connection, click the Disconnect button. If you need help withxisp, read its manual page, select the General Info menu item from its main dialog box,or see the README files under the /usr/doc/xisp directory.Checking the ConnectionYou can diagnose, troubleshoot, or get more information about your PPP connection in anumber of ways. You can use networking utility programs during your connection to test,time, and diagnose the ppp0 interface. You can also examine system logs to look for anyproblems occurring during startup, connecting, and disconnecting.This section introduces you to a few of these networking programs and shows you whereto look in your system logs for more information.Using the ifconfig CommandAlthough the ifconfig command, found under the /sbin directory, is generally used innetwork administration by the root operator to configure network interfaces (a skillnot covered in this book; see the Linux Network Administrators Guide), you can useifconfig to see the status of your PPP connection.


244 Hour 10This command can also be helpful when you’re running programs, such as newsreaders,which appear “frozen” but are actually sending and receiving data without displayingupdates on your screen. To use ifconfig, just enter the following:# /sbin/ifconfiglo Link encap:Local Loopbackinet addr:127.0.0.1 Bcast:127.255.255.255 Mask:255.0.0.0UP BROADCAST LOOPBACK RUNNING MTU:3584 Metric:1RX packets:17257 errors:0 dropped:0 overruns:0TX packets:17257 errors:0 dropped:0 overruns:0ppp0 Link encap:Point-Point Protocolinet addr:207.226.80.52 P-t-P:207.226.80.4Mask:255.255.255.0UP POINTOPOINT RUNNING MTU:1500 Metric:1RX packets:676 errors:0 dropped:0 overruns:0TX packets:545 errors:0 dropped:0 overruns:0The command lists the current active network interfaces. Look at the ppp0 listing, andyou can see the number of bytes received and transmitted (in the form of packets) overyour PPP interface. Calling the program intermittently from another console or terminalwindow under X shows you the progress of data being sent and received.Using the netstat CommandThe netstat command is the definitive command for checking your network activity,connections, routing tables, and other network messages and statistics. Try this commandif you’re interested in a flexible listing of what’s going on. For example, you can try thefollowing (and the sample output is abbreviated here):# netstatActive Internet connections (w/o servers)Proto Recv-Q Send-Q Local Address Foreign Address Statetcp 1 0 localhost:1644 localhost:1322 CLOSE_WAITtcp 0 0 localhost:2579 localhost:6000 ESTABLISHED...tcp 0 0 serial52.staffnet.:4216 megan.staffnet.com:pop ESTABLISHEDActive UNIX domain sockets (w/o servers)Proto RefCnt Flags Type State I-Node Pathunix 2 [ ] STREAM CONNECTED 417...unix 2 [ ] STREAM 419 /dev/logunix 2 [ ] STREAM CONNECTED 1982unix 2 [ ] STREAM 1983 /dev/logThe netstat command has more than a dozen different command-line options. See thenetstat manual page for more information.


Connecting to the Internet 245Using the ping CommandThe ping command is useful for verifying that your ISP’s IP addresses are valid and fortesting the response times of your ISP’s host servers. Ping sends test packets of data andmeasures the time it takes for the host to send back the information, as in the followingexample:# ping staffnet.comPING staffnet.com (207.226.80.1): 56 data bytes64 bytes from 207.226.80.1: icmp_seq=0 ttl=254 time=176.9 ms64 bytes from 207.226.80.1: icmp_seq=1 ttl=254 time=180.0 ms64 bytes from 207.226.80.1: icmp_seq=2 ttl=254 time=170.0 ms64 bytes from 207.226.80.1: icmp_seq=3 ttl=254 time=170.0 ms64 bytes from 207.226.80.1: icmp_seq=4 ttl=254 time=170.0 ms64 bytes from 207.226.80.1: icmp_seq=5 ttl=254 time=170.0 ms64 bytes from 207.226.80.1: icmp_seq=6 ttl=254 time=169.7 ms...10--- staffnet.com ping statistics ---7 packets transmitted, 7 packets received, 0% packet lossround-trip min/avg/max = 169.7/172.3/180.0 msAs you can see, the ping command sends each packet and reports the amount of time (inthousandths of a second) it takes for the packet to be echoed back. By default, ping continuesto send and receive information until you tell it to quit with Ctrl+C. Using the -f,or flood, option is not a nice thing to do to your ISP (or any other host computer for thatmatter), as it creates network overhead and unnecessary network traffic. If you want totest the connection for a short period of time, use the ping command’s -c option, followedby a number, to have ping only send a specific number of packets, like this:# ping –c 10 staffnet.comUsing the route CommandThe route command, generally used to set up or delete networking routes for interfaces,can also be useful in showing you what is going on with your ppp0 interface. You can trythe following:# /sbin/routeKernel IP routing tableDestination Gateway Genmask Flags Metric Ref Use Ifacepm2.staffnet.co * 255.255.255.255 UH 0 0 0 ppp0127.0.0.0 * 255.0.0.0 U 0 0 2 lodefault pm2.staffnet.co 0.0.0.0 UG 0 0 3 ppp0This listing (similar to the netstat -r command) shows that in addition to a normalloopback interface (127.0.0.0, defined in your /etc/hosts file), a ppp0 interface is currentlyactive. For more details about the route command, see its manual page.


246 Hour 10Reading Your System LogIf you want to read in detail about what is going on while your scripts are executing, takea look through your system log for a file called messages under the /var/log directory.Try the following (as the root operator):# less /var/log/messagesLook for the start of the pppd daemon in the ppp-on script. Notice that your dialer scriptuses the chat program, which does most of the work and then quits, followed by pppdgetting and setting the network IP addresses, as follows:...Nov 5 16:29:49 localhost pppd[370]: pppd 2.2.0 started by root, uid 0Nov 5 16:29:51 localhost chat[371]: timeout set to 3 secondsNov 5 16:29:51 localhost chat[371]: abort on (\nBUSY\r)Nov 5 16:29:51 localhost chat[371]: abort on (\nNO ANSWER\r)Nov 5 16:29:51 localhost chat[371]: abort on➥(\nRINGING\r\n\r\nRINGING\r)Nov 5 16:29:51 localhost chat[371]: send (rAT^M)Nov 5 16:29:51 localhost chat[371]: expect (OK)Nov 5 16:29:51 localhost chat[371]: rAT^M^MNov 5 16:29:51 localhost chat[371]: OK -- got itNov 5 16:29:51 localhost chat[371]: send (ATH0^M)Nov 5 16:29:51 localhost chat[371]: timeout set to 30 secondsNov 5 16:29:51 localhost chat[371]: expect (OK)Nov 5 16:29:51 localhost chat[371]: ^MNov 5 16:29:51 localhost chat[371]: ATH0^M^MNov 5 16:29:51 localhost chat[371]: OK -- got itNov 5 16:29:51 localhost chat[371]: send (ATDT659-9041^M)Nov 5 16:29:51 localhost chat[371]: expect (CONNECT)Nov 5 16:29:51 localhost chat[371]: ^MNov 5 16:30:10 localhost chat[371]: ATDT659-9041^M^MNov 5 16:30:10 localhost chat[371]: CONNECT -- got itNov 5 16:30:10 localhost chat[371]: send (^M)Nov 5 16:30:10 localhost chat[371]: expect (ogin:)Nov 5 16:30:10 localhost chat[371]: 57600^MNov 5 16:30:12 localhost chat[371]: ^MNov 5 16:30:12 localhost chat[371]: ^MNov 5 16:30:12 localhost chat[371]: Staffnet PM0 login: -- got itNov 5 16:30:12 localhost chat[371]: send (username^M)Nov 5 16:30:12 localhost chat[371]: expect (assword:)Nov 5 16:30:12 localhost chat[371]: username^MNov 5 16:30:12 localhost chat[371]: Password: -- got itNov 5 16:30:12 localhost chat[371]: send (password^M)Nov 5 16:30:12 localhost pppd[370]: Serial connection established.Nov 5 16:30:13 localhost pppd[370]: Using interface ppp0Nov 5 16:30:13 localhost pppd[370]: Connect: ppp0 /dev/modemNov 5 16:30:16 localhost pppd[370]: local IP address 207.226.80.171Nov 5 16:30:16 localhost pppd[370]: remote IP address 207.226.80.214,,,


Connecting to the Internet 247You can look at portions of your log to troubleshoot whether your modem is working oryour ISP’s modems are working. Hopefully, everything goes well, but if you have a hardtime connecting or setting up your scripts, take the time to read the chat and pppd manualpages, along with the PPP-HOWTO and PPP-FAQ.If you’re still having trouble, make sure to read Robert Hart’s PPP-HOWTO,along with Al Longyear’s PPP-FAQ, which go into much more detail aboutsetting up PPP connections. You can find a lot of handy hints about settingup, testing, and troubleshooting your connection. If security is a big issue foryou, make sure to read these documents, too. You can also check with thecomp.os.linux.networking, comp.os.linux.setup, or comp.protocols.pppUSENET newsgroups for specific information or tips on using PPP.The next two hours show you how to set up your email and newsreader programs so youcan send and receive email and read some favorite USENET newsgroups.10SummaryThis hour you learned several ways to set up an Internet connection to your ISP using thePPP protocol. As you observed, OpenLinux comes with several connection and troubleshootingutilities that make getting connected to the Internet easier than ever before.Q&AQ My modem dials and connects to my ISP, but the connection dies almostimmediately! What’s going on?A Make sure you have entered the proper log in sequence either in your ppp-onscript, or in the appropriate dialog boxes for the kppp or xisp clients. Try manuallyconnecting to your ISP with the seyon or minicom programs and note the promptstrings from your ISP’s computer.Q I manually connected with minicom, but after I log in to my ISP’s computerand press Enter, I see strings of garbage characters echoed back!A This is probably normal and shows that your ISP’s computer has started PPP. Exitminicom without resetting your modem, and test your connection.


248 Hour 10Q OK, I’ve established my connection. Now what?A You should first try to ping a remote host computer, or attempt an FTP connection.For information about other Internet activities, see Hour 11, “Configuring InternetEmail,” Hour 12, “Configuring Internet News,” or Hour 13, “Internet Downloadingand Browsing.”Exercises1. After establishing your PPP connection, try using other Internet utilities, such asthe whois command, to get information about your ISP. At the command line of aterminal window, type whois, followed by the domain name of your ISP, and pressEnter. What do you see?2. Try using the ping command to see how fast packet information is returned to yourcomputer. Test the speed with different host computers on the Internet and measurethe difference.


HOUR 11Configuring InternetEmailThis hour shows you how to set up your OpenLinux system to handle electronicmail. You’ll also explore various programs you can use to read andsend mail, such as the pine mail program and Netscape Messenger.First you’ll learn to set up your system to send and receive mail, building onyour experience in setting up and connecting to your ISP using PPP.Setting Up and Getting Your EmailThere’s not really much to do to set up your system to send and receivemail, although configuring the main mail daemon, sendmail, is complexenough to be considered a black art, suitable only for UNIX wizards. Youshouldn’t be intimidated though, because you can use email right after youinstall OpenLinux.


250 Hour 11I can’t discuss all the details about UNIX mail in this hour, but you shouldunderstand how electronic mail works in general. The main programs involved inemail are, in technical terms, transport agents and user agents. A transport agent is aprogram, usually a daemon, that sends mail files from one computer to the next automatically.A user agent is a program, also called a mail reader, that you use to manage messages.You’ll learn how to use these programs in this hour.NEW TERMAfter you install OpenLinux, you can find nearly all the programs you need to compose,send, and receive mail. The transport agent used for OpenLinux is sendmail, and it isconfigured and run automatically when you boot the operating system. As far as useragents and electronic mail utilities, you have a wide choice from at least nine (listed inTable 11.1).TABLE 11.1Namebiffcoolmailelmfastmailfetchmailfrm, nfrmmailmessagesmlmushmuttNetscape MessengerpineprintmailprocmailreadmsgxbiffxfmailxmailboxxmhELECTRONIC MAIL PROGRAMS FOR OPENLINUXDescriptionMail notification utility3D animated mail notification utility for X11Interactive mail programBulk email programEssential POP, IMAP, or ETRN mail retrieval programHandy mailbox message list utilitiesBasic mail programHandy mailbox message counting utilityMail user agent for X11Shell for electronic mailMutt mail user agentMail user agent component of Netscape Communicator newmail,wnewmailMail notification utilitiesProgram for Internet News and EmailFormat utility to prepare mail for printingRecipe-based mail processorHandy mail message extractionutilityMail notification utility for X11Mail user agent for X11Mail notification utility for X11Mail user agent for X11


Configuring Internet Email 251Because you’re probably connecting to the Internet with a PPP connection, the generalapproach to handling mail outlined in this hour is to do the following:1. Log in and establish a PPP connection.2. Retrieve mail using a retrieval utility or user agent.3. Disconnect (or stay connected for a few quick replies).This is a similar approach to other ways of handling mail. If you’ve experimented withfree email dial-in account programs (such as Juno) for other operating systems, youknow the general approach is to minimize connect time by composing and replying tomail offline, then connecting, sending and retrieving mail, and followed by logging off.If you want details about Linux mail handling along with pointers to other sources ofinformation, read Guylhem Aznar’s Mail-HOWTO under the /usr/doc/HOWTO directory.Retrieving Your Email with fetchmailBy now you’re probably wondering how to get your email from your ISP. If you recallfrom the preceding hour, you need the IP address or name of your ISP’s mail server. Toget your mail, you need fetchmail, which can be found in the /usr/bin directory. Thefetchmail program was written by Eric S. Raymond, an outstanding programmer, outspokenproponent of Open Source software, and all-around good guy (who wants to beknown by his initials, esr).11This program has many features, including a daemon mode, or backgroundmode, that periodically checks to see if you have mail while you’re connected toyour ISP. The fetchmail program can recognize and retrieve mail using all standardInternet mail-retrieval protocols, such as the following:NEW TERM●●●●●●●●●POP2POP3RPOPAPOPKPOPCompuServe POP3 with RPASDPSIMAPESMTP ETRN


252 Hour 11To retrieve electronic mail, you need to know what protocol your ISP uses (most ISPssupport POP3, APOP, or IMAP), along with your username and password on the mailserver.Put all this information together, connect to your ISP, and then grab all your waitingemail with the fetchmail command. Include the -p option, followed by the type of protocolused, followed by the name of your ISP’s mail server, and ending with the -uoption and your username, like this:# fetchmail -p POP3 pop.erols.com -u bballEnter password for bball@pop.erols.com:2 messages for bball at pop.erols.com (3524 octets).reading message 1 of 2 (2335 octets) .. flushedreading message 2 of 2 (1189 octets) . flushedYou have new mail in /var/spool/mail/bballAfter you press Enter, fetchmail prompts for your password (so you can gain access toyour ISP’s mail server), then retrieves your mail, and flushes (or deletes) your mail fromyour ISP’s mail server. If you want to keep copies of your mail on your ISP’s mail server(not recommended), include the -k (keep) option on the command line.Unfortunately, the version of fetchmail (4.0.7) included with OpenLinux 1.3is sadly out of date. The current version at the time of this writing is 4.7.4and includes numerous improvements. To get a newer version, browse toftp://metalab.unc.edu/pub/Linux/system/mail/pop. To get the latest version,browse to http://www.tuxedo.org/~esr/fetchmail. You can find .rpmand .tgz versions at both sites.To make retrieving email easier, fetchmail uses the contents of a file called.fetchmailrc you can create in your home directory. In fact, if you use the—fetchmailrc option, followed by the name of a different file, you can easily retrievemail from different accounts or ISPs. The contents of a .fetchmailrc file are spelled outin detail in the fetchmail man page but generally consist of the following:poll mailserver protocol POP3 username yourusername password yourpasswordUse your favorite text editor to create your own .fetchmailrc, and replace mailserverwith the name of your ISP’s mailserver (such as pop.erols.com), POP3 with your ISP’smail server protocol, yourusername with your username, and yourpassword with yourpassword. Save the file, exit your editor, and then retrieve your mail, like so:# fetchmail


Configuring Internet Email 253If you want fetchmail to periodically check for waiting mail (say, every five minutes),use its daemon, followed by the number of seconds to specify the interval betweenchecks. When you use this mode with the -d option, fetchmail runs as a backgroundprocess. Start the command as follows:# fetchmail -d 300fetchmail also has a nifty option, -c, which merely checks to see if you have mail waitingand reports the number of messages, along with the size. For example:# fetchmail -c2 messages for bball at pop.erols.com (3435 octets).By default, your mail goes into a single file with your username under the/var/spool/mail directory.Remember: The fetchmail program is designed to work only one way; it retrieves yourmail from your ISP’s mail server and then tells your ISP’s mail server to delete (or keep)your mail after messages are sent. Now that you’ve retrieved your mail, how do yousend, read, or reply to messages? This is where user agents, or mail reading programs,come in.11If you get an error when retrieving mail, make sure that the sendmaildaemon has started. This service, listed as the Mail Transfer Agent under thelisa command’s Configure daemon/server autostart menu, ensures properreceipt and delivery of mail (in addition to mail forwarding).Sending Mail with Mail ProgramsThis section introduces you to three basic mail programs you can use under Linux. Theexplanations start with one of the oldest, the mail program, and then follow with twoscreen-oriented programs, elm and pine.Using the mail ProgramThe mail program, found under the /bin directory, is the simplest mail program you canuse. It is not screen-oriented, and works on a line-by-line basis with single-letter commands.However, this program is easy to use to create and send messages. For example,to create a quick message, call mail with an email address on the command line like this:# mail tball@mcp.comSubject: Howzit going?Hope everything is OK with you.Just wanted to drop a quick line!.EOT


254 Hour 11The mail program responds by asking for a Subject: line. Enter your message subject,and then press Enter. Next, type each line of text in the body of your message. When youfinish, put a period (.) on a line by itself, and press Enter. The mail program sends themessage.Retrieving your messages is easy. After you connect to your ISP and retrieve your mailusing fetchmail, type mail on the command line, for example:# mailMail version 8.1 6/6/93. Type ? for help.“/var/spool/mail/bball”: 5 messages 1 unread1 MAILER-DAEMON@staffn Thu Jan 7 18:51 12/510➥”DON’T DELETE THIS MES”2 majordomo@rim.calder Sun Nov 8 11:26 54/2067➥”Welcome to caldera-us”3 majordomo@rim.calder Sun Nov 8 11:26 25/982➥”Majordomo results: Re”4 bball@staffnet.com Thu Jan 7 18:23 69/2805➥”Welcome to caldera-us”>U 5 bball@staffnet.com Thu Jan 7 18:23 40/1658 “test”&The mail program retrieves your mail from the /var/spool/mail directory, prints itsversion, lists information about each message, and presents the ampersand (&) as aprompt. Note that a right angle bracket (>) precedes the current message. The basic mailcommands are as follows:●●●●●●●●●●t—Type, or list, the current messagen—Go to the next message and list it+—Move to the next message and list it-—Move backwards to the previous message and list ith—Reprint list of messages (after listing a message)d—Delete the current messageR—Reply to senderr—Reply to sender and all recipientsq—Quit, saving messages in the default mailbox, mboxx—Quit, and don’t save messages in mboxOne handy way to send a long message quickly is to use the command-line redirectionoperator of your shell. For example, if you compose a long message in your favorite texteditor, you can send the message with the following:# mail -s “How is it going?” myfriend@somewhere.com < mymessage.txt


Configuring Internet Email 255Using this approach, the mail program creates a message with a subject you specify withthe -s option (note that you must enclose the subject lines that contain spaces betweenquote marks) and then puts the file mymessage.txt into the body of the message. Becareful, though, because the message is sent right away without asking you if you reallywant to send it.There are many different ways to use the mail program. You might find it useful. See themail manual page for more information. Although using mail can be quick and convenient,the next two mail programs are a lot more interactive and offer features most peoplehave become accustomed to when they send and receive mail.Configuring and Using the elm Mail ProgramThe elm program, more than 10 years old, was originally developed by Dave Taylor andis now under cooperative development by a team of more than 40 programmers known asThe Elm Development Group. This program features an interactive screen and can beused from the console or the command line of an X11 terminal window.Unlike pine, elm must be started in a window with at least 14 rows, or itcomplains and quits.11When you first start elm, you’re asked if you want to create elm’s default mail folder,Mail:# elmNotice:This version of ELM requires the use of a .elm directory in your homedirectory to store your elmrc and alias files. Shall I create thedirectory .elm for you and set it up (y/n/q)?Press the Y key, and press Enter. elm has features similar to mail and pine (discussed inthe next section). For example, you can, as in mail, send a message from the commandline using the mail command example you saw earlier, for example:# elm -s “How is it going?” bball@staffnet.com < author.msgSending mail...Mail to bball@staffnet.comMail sent!After you retrieve your mail, elm reads your messages and displays your them as shownin Figure 11.1


256 Hour 11FIGURE 11.1The elm mail programdisplays messages in alist.You can use elm to delete, forward, save, or compose messages. Customize some of itsfeatures by typing an o (for options) while in elm’s main display (as shown in Figure11.2). Type a letter, then type a new value for features such as the default editor (usedwhen you compose or reply to messages), and press Enter. These custom features aresaved in an elmrc file under the .elm folder in your home directory when you press the< key.FIGURE 11.2The elm setup dialog isused to set variousoptions.Make sure to read the manual page for elm before you start using it. You can also finddocumentation under the /usr/doc/elm directory. If you want more information aboutelm, you can also check the following:http://www.myxa.com/elm.html


Configuring Internet Email 257Configuring and Using the pine Mail ProgramThe pine (Pine Is No longer Elm) mail program, which you can find under the /usr/bindirectory, was developed by the University of Washington as an interactive mail andnews reader. This means that not only can you use pine for sending or reading yourmail, but you can also use it to read Usenet newsgroups. Usenet and different news readersare discussed in the next hour, “Configuring Internet News.” This section focuses onconfiguring and using pine for electronic mail.The pine program also comes with an extremely easy-to-use editor called pico, whichmight easily become your favorite Linux text editor because it can be used with anyother program and not just pine. See Hour 14, “Text Processing,” for more details aboutthe pico editor.The pine program is easy to set up and use. Most of the work is done for you automaticallywhen you first start the program. The first time you use this program, it reports thefollowing:# pineCreating subdirectory “/home/bball/mail” where Pine will storeits mail folders.The pine program starts up and creates a directory called mail along with a .pinercconfiguration file in your home directory. You see an initial greeting screen (as shown inFigure 11.3).11FIGURE 11.3The pine mail programworks with your consoleor through an X11terminal window.


258 Hour 11Before you start composing or sending mail, configure pine to recognize your username,your ISP’s mail server, and, as you’ll see later, your ISP’s news server. Although you cancompose mail and use pine’s postpone feature to save your composed messages, youcan’t send mail until you tell pine who you are or the name of your ISP’s mail server.To do this, first start pine, and then type an s and then a c to get to pine’s configurationscreen (see Figure 11.4).FIGURE 11.4Specify the personalname, user domain,smtp server, and nntpserver in the pinemailer configurationscreen.Enter your personal name, the domain of your ISP, the name of your ISP’s mail server,and if you know it, the name of your ISP’s news server. Then type an e, and pine asks ifyou want to save the changes. Your configuration is then saved in the .pinerc file inyour home directory. Although you can edit this file in your favorite text editor, usingpine is a lot easier.To compose a message, press the c key, and you’re in pine’s compose mode (seeFigure 11.5).FIGURE 11.5Composing a mailmessage with fileattachments to multiplerecipients in thepine compose mode.


Configuring Internet Email 259You can specify multiple recipients to your message by typing a comma between names.You can also send file attachments by typing the name of the file in the Attchmnt: field(if it is in your home directory) or the complete path of your file (if it is somewhere elseon your file system).As you compose your message, use your cursor keys to move around the text. There area number of editing keys you can use to change your text. Lines of text can also bedeleted or undeleted for cutting and pasting. These keys, listed in table 11.2, correspondwith the pico editor.TABLE 11.2 PINE MESSAGE COMPOSITION EDITING COMMANDSActionKeystrokeBack one characterCtrl+BBackspaceCtrl+HCancel messageCtrl+CDelete characterCtrl+DDelete lineCtrl+KDown one lineCtrl+NForward one character Ctrl+FHelp on editingCtrl+HInsert text from fileCtrl+RJustify paragraphCtrl+JBeginning of lineCtrl+AEnd of lineCtrl+ENext wordCtrl+@Page downCtrl+VPage upCtrl+YPostpone (save) message Ctrl+OSpellcheckCtrl+TUp one lineCtrl+PWord searchCtrl+W11When you finish composing your message, send the message immediately by usingCtrl+X, or postpone the message by using Ctrl+O. Using this approach, you can createor reply to messages when you’re not connected to your ISP and send them later.


260 Hour 11When you retrieve your mail, pine looks in the /var/spool/mail directory, and thenextracts the messages from your mail file and puts them into the default folder, INBOX, inthe directory named mail in your home directory. You can also create other folders andsave and delete messages in different folders to organize your mail. Of course, you canalso use the procmail approach discussed in the section “Configuring procmail andWriting Recipes to Fight Spam” later in this chapter to automate some of this process foryou.The folder index of your messages is displayed in a list, and you can select messages byscrolling up and down with the cursor keys (see Figure 11.6). From the main list of messages,you can delete, undelete, save, read, and export messages to your directory. Toread a message, just hit the Enter key.FIGURE 11.6You can selectmessages through themessage list of a pinemail folder.The pine program has a number of command-line options and other features, such asbuilt-in help, which you access with the question mark (?) from the pine main menu.Configuring and Using Netscape Messenger for EmailNetscape Messenger, a component of the Netscape Communicator suite of Internetclients, is a graphical electronic mail client for the X Window System. You can start thisprogram from the Communicator menu in the Netscape Navigator window by clickingthe Messenger button on Netscape’s component bar. You can also start it through the useof the -mail option with the netscape command like this:# netscape -mail &


Configuring Internet Email 261When the client launches (as shown in Figure 11.7), select the Edit menu, and then clickthe Preferences menu item. When the Preferences dialog box appears, click the Mail &Groups item, and then click the Identity list item. Type in your name and email address,as shown in Figure 11.8.FIGURE 11.7Netscape Messenger isan easy-to-use interfaceto electronic mailin X11.11FIGURE 11.8Enter your name andemail address, alongwith any other desiredinformation (such asyour organization), inthe Messenger Identitydialog box.


262 Hour 11By default, Netscape Messenger sends the text of your email message formattedin HTML. This is okay if you’re sending mail to another Netscapeuser but is a messy way to communicate with others who use mail, elm, orpine. Turn off the HTML message format by clicking the Messages list itemunder Mail & Groups and then deselecting the HTML messages push buttonunder the Message Properties section of the Messages dialog box.Next, click the Mail Server list item. This dialog box (shown in Figure 11.9) is used toset several critical items, such as server names and your ISP’s mail retrieval protocol.Type your username (usually the name you use to log in to your ISP), and then type thename of your ISP’s mail server in the Incoming mail server field (leave the outgoingserver entry set to localhost). Next, click to select the type of mail server protocol usedby your ISP.FIGURE 11.9You can use theMessenger Mail Serverpreferences dialog boxto set critical informationneeded to retrieveand send mail.Click the More Options button to change other settings, such as the defaultmail folder or how often you want Messenger to check for waiting email.


Configuring Internet Email 263When finished, click OK to save your changes. In the main Messenger window, click theGet Msg button (shown in Figure 11.7). Messenger asks for your password. Click theOK button to retrieve your messages. New messages appear in a list in the Messengerwindow. To read a message, click the desired message in the message list, and its textappears in the bottom half of the Messenger window.At this point, you can use the various Messenger buttons to reply to, forward, save,print, or delete the message. To compose a new message, click the New Msg button inMessenger’s menu bar. The Messenger Compose window appears, as shown inFigure 11.10.FIGURE 11.10Compose new messages,address multiplerecipients, andattach Web pages orfiles throughMessenger’s Composewindow.11Click in the To: field to enter a recipient. To enter multiple recipients, press Enter aftertyping in an email address. Next, click in the Subject: field, and enter a subject. If youwant to send an attachment with the message, click the Attach button in the composewindow’s menu bar, or select the File menu and the Attach menu item. Click your mousein the blank area of the Compose window (below the formatting bar), and type in a message.When you finish, you can save the message as a draft, spellcheck the message, orsend the message by clicking on the Send Now button.Subscribing to Mailing ListsWhen you feel confident that your mail system is working, you might want to subscribeto a mailing list. Mailing lists are handled by automatic mail servers and work by relayingmessages generated to all members of a mailing list. One smart way to subscribe tomailing lists is to sign up for a digest version in which the day’s message traffic is condensedinto a mailing once or twice a day.


264 Hour 11You can find out more about mailing lists by browsing to the following:http://www.lsoft.com/lists/listref.htmlChances are that you can find a mailing list (the preceding site enables you to searchmore than 21,000 of the 135,000 available lists at the time of this writing) of interest toyou. Have fun!To participate in discussions about OpenLinux using email and to exchangeinformation with other OpenLinux users, send a message tomajordomo@rim.caldera.com with the following line in the body of themessage:subscribe caldera-users youremailaddress@yourisp.comAn electronic mail message asks you to confirm your subscription. Reply tothe message according to its directions. For more information about this service,send a message to majordomo@rim.caldera.com with the word help inthe body of the message. You receive a reply with lots of details about usingCaldera’s mailing lists. For the digest version of Caldera’s OpenLinux list,send a message to majordomo@rim.caldera.com with the following line inthe body of the message:subscribe caldera-users-digest youremailaddress@yourisp.comConfiguring procmail and Writing Recipes toFight SpamWe’re all used to getting junk mail or telemarketing calls. Day after day, weNEW TERMreceive offers for credit cards, home equity loans, new long-distance service, orgreat deals on prime cuts of pot roast at the local food market. You can do somethingabout unwanted postal mail, junk faxes, and telemarketing calls, but there’s no currentnationwide regulation regarding junk email, otherwise known as SPAM (not to be confusedwith the famous canned meat product).Fortunately, many State’s Attorney General offices around the United Statesare heeding the hue and cry against spammers, or junk emailers. Somestates, such as California, now have civil penalties that are enforced againstthese bonehead spammers. This type of action is long overdue!


Configuring Internet Email 265You can, however, use procmail, which is found under the /usr/bin directory,to filter your incoming mail. You need to create a directory, create several files,write a small script, and customize how your incoming mail is handled by writing shortfilters, or procmail recipes. It only takes you a minute or so to set up your system toorganize incoming mail and dispose of junk mail.NEW TERMThe first step is to create a text file, called .procmailrc, in your home directory. Then,type in the following, specifying the name of your mail directory (if you use pine, thedirectory is mail), the location of the .procmail directory (which you’ll soon create),and the name of your procmail filter file:MAILDIR=$HOME/mailPMDIR=$HOME/.procmailINCLUDERC=$HOME/.procmail/rc.mailfilterSave this file. Next, create a text file called .forward in your home directory. This fileneeds to contain the following line:“|IFS=’ ‘ && exec /usr/bin/procmail -f- || exit 75 #username”This command line controls procmail, and you should use your username instead of“username.” Now, make your .forward file world readable and your home directoryworld searchable with the chmod command. See the following example (making sureyou’re in your home directory):11# chmod 644 .forward# chmod a+x .You’re almost done. Now, with the mkdir command, create a directory called .procmail,change directory into it, and create a text file called rc.mailfilter.This file is to contain your procmail filters, or recipes. Although these recipes can beextremely complex (so complex, in fact, that you can write your own mail delivery service),this section presents simple recipes to get you started.First, examine a sample message’s mail headers (which contain the From:, To:, orSubject: lines). The British MG sports cars digest has the following subject line in eachmessage:Subject: mgs@autox.team.net digest #905 Mon Nov 17 10:09:07 MST 1997Each digest message can contain almost 100,000 characters and is sent twice a day,so it is nice to have all these digests go into their own mail folder, which you can callmgdigest. To do this, you enter the following line in rc.mailfilter::0:*^Subject:.*digestmgdigest


266 Hour 11This small recipe saves any incoming message with a subject line containing the worddigest into a mail file called mgdigest in your mail program’s mail directory (if you subscribeto other digests, such as Caldera’s, you need to create separate recipes with morespecific Subject line criteria). Note that you don’t have to create this mail file yourself. Itis created for you when you first retrieve mail and procmail finds a match. You can alsouse another recipe to have all mail files from your friends saved to a specific folder, forexample::0:*^From:.*aol.comAOL“Okay,” you’re asking, “but what about junk email?” Well, you know what you want todo with junk email—trash it! For Linux users, there’s a special place to which you cansend junk email: the old bit bucket, /dev/null. So if you get an unwanted message froma place like hotlips4u.com, you can send this type of garbage to the boneyard with thefollowing::0:^From:.*hotlips4u.com/dev/nullJunk email is usually easily recognized because the message contains someform of clever subject line to interest you. Other clues include that younever requested the information in the message or that the sender,receiver, or reply-to sections of the message are forged (this is unethical andfraudulent behavior). Never reply to junk email, even if the mail contains amessage such as “To never receive this message again, reply to bonehead@spammers.com with a message containing the word UNSUBSCRIBE in thebody of text.” This is a trap to verify your email address, and you could endup receiving even more junk mail!The mail message isn’t stored on your hard drive, and you don’t have to bother with anymail from that address again. Using this approach is simplistic, however, and if you get alot of junk mail, you might want to experiment with more complex recipes that can filterout everything except people with whom you want to exchange mail.If you want to add some more features to your procmail service, read the procmailrcmanual page. For a great selection of procmail recipes, see the procmailex manualpage, which details numerous examples, ranging from simple to complex.


Configuring Internet Email 267Want more information about procmail, writing procmail recipes, and filtering yourmail? Look for Nancy McGough’s Filtering Mail FAQ, which is posted regularly to thecomp.mail.misc, comp.mail.elm, comp.mail.pine, and other newsgroups. Readingnews from Usenet also happens to be the next hour’s subject!SummaryThis hour introduced you to just several of the electronic mail programs available forOpenLinux. You can find these programs, and many others, available on this book’s CD-ROM.Q&AQ When I try retrieving mail from my ISP, fetchmail reports an error! What’sgoing on?A Make sure that you specified the correct protocol with fetchmail to match yourISP’s mail server protocol. Make sure that sendmail is running. Also, make surethat you use the latest version of fetchmail. For additional troubleshooting information,see the fetchmail FAQ under the /usr/doc/fetchmail directory.Q I want to receive mail from a Microsoft Exchange server or through myCompuServe account. How do I do this?A See the fetchmail FAQ under the /usr/doc/fetchmail directory. There are tipsand tricks you can use to get your mail and traps to avoid during your OpenLinuxPPP sessions.Q I’ve set fetchmail to retrieve mail periodically from my ISP. How can I tell ifmail has been received?A There are many different mail notification programs included with OpenLinux.Some work with the console, whereas others only function during X11 sessions.See the newmail or biff man pages to get started. (Others are listed in the table atthe beginning of this hour)Q When I use fetchmail, it reports that the “connection failed” and “failed:temporary name server error.” What’s going on?A You must first establish a PPP connection with your ISP. Also make sure that youcorrectly entered the name of your ISP’s mail server in your .fetchmail rc file.11


268 Hour 11Exercises1. Experiment with different mail programs, such as xmh, mutt, or xfmail. How arethese programs different? What do you like or not like about these programs?2. Create different procmail recipes to organize or filter your incoming mail. Saveall junk email in a folder called spam, and then later sort through the mail and forwardpertinent copies to the appropriate State Attorney General’s office with acomplaint.


HOUR 12Configuring InternetNewsThis hour introduces you to Usenet news and shows you how to set up anduse the tin, slrn, and K Desktop Environment’s krn newsreader programsand the Discussions component of Netscape Communicator to read Usenetnews during your PPP connection. Reading news can be an endless sourceof amusement, help, and even frustration (especially if the “signal-to-noise”ratio is low).Usenet is an international network of computers around theworld that share news and mail. Originally developed by TomTruscott and James Ellis in 1979, Usenet was a collection ofsoftware that provided bulletin-board style communicationbetween two university computer systems in North Carolina. In10 years, Usenet grew to 10,000 computer systems, andalthough Usenet was originally started to support computerquestions and answers, the number of different newsgroups,or discussion areas, grew to nearly 1,000 in the late 1980s.


270 Hour 12Usenet newsgroups are organized in a hierarchy, usually by topic or type of discussion.For example, the Linux newsgroups are generally organized under the alt.os,comp.os.linux, or linux topics. Here is a partial list of Linux newsgroups of interest toU.S. readers; there are also many Linux newsgroups in other languages:alt.os.linux.calderacomp.os.linux.advocacycomp.os.linux.announcecomp.os.linux.answerscomp.os.linux.hardwarecomp.os.linux.misccomp.os.linux.networkingcomp.os.linux.portablecomp.os.linux.setupcomp.os.linux.xThis shows that most Linux subjects, such as setup, hardware, or X11, are organizedunder the topic of computers, operating systems, and Linux. You’ll find many other subjectsorganized the same way. Although there’s no guarantee you’ll find the exact subjectyou’re looking for, chances are you’ll easily find a newsgroup discussing a subject you’reinterested in.Today, there are dozens of different Usenet software transport programs and newsreadersand more than 50,000 different newsgroups.All newsreaders offer these basic functions:●●●●●Subscribing or unsubscribing to newsgroupsBrowsing messages and reading follow-up messages (threads)Directly mailing a reply to the author of a messagePosting a follow-up message to a newsgroup messageSaving the contents of a message (usually to a directory called News in your homedirectory)The tin reader uses a newsgroup index file called .newsrc (whereas slrn uses a filenamed .jnewsrc), which is normally located in your home directory. These programs donot require the X Window System, so you can read news after connecting to the Internetthrough your Internet service provider (ISP). The krn newsreader, which requires X11,also uses an index file in your home directory but with a name beginning with .newsrcfollowedby the name of your ISP’s news server. You’ll see how to configure krn later inthis hour.


Configuring Internet News 271Although you can start both tin and slrn and tell the programs to retrieve a completelist of active newsgroups from your ISP’s news server, you’ll waste a lot of time whilethe programs retrieve the list (nearly 50,000 items at the time of this writing). Instead,create the .newsrc file with your favorite text editor and then enter the newsgroups youwant to browse:news.announce.newusers:comp.os.linux.announce:comp.os.linux.development.apps:comp.os.linux.development.system:comp.os.linux.hardware:comp.os.linux.misc:comp.os.linux.networking:comp.os.linux.setup:comp.os.linux.x:comp.windows.x:comp.windows.x.i386unix:rec.autos.antique:alt.humor.best-of-usenet:rec.humor:Not all ISPs provide access to all existing Usenet newsgroups. Many newsgroups,especially those with prurient content, may be excised or filteredout. If your ISP doesn’t offer a specific newsgroup you’re interested in, youcan use your favorite Web browser (discussed in Hour 13, “InternetDownloading and Browsing”) to read news throughhttp://www.dejanews.com.Notice that the list does not have to be in alphabetical order. You must have a colon followingthe newsgroup. If you type in a newsgroup not supported by your ISP, both tinand slrn will ignore the name, and both programs will display the list of newsgroups inthe same order in which you typed them in the .newsrc file.Developing your own list of newsgroups will speed up your newsreading considerably.12Reading Usenet News with the tinNewsreaderIain Lea’s newsreader, tin, which is found in the /usr/bin directory, is a full-screennewsreader that reads a list of newsgroups from the .newsrc in your home directory. Thetin reader is easy to use (see Figure 12.1). You can navigate through its display withcursor keys, read messages with the Enter key, and reply with a single keystroke.


272 Hour 12FIGURE 12.1The tin newsreaderdisplays newsgroupsin a cursor-driven list.To read Usenet news with tin, you must tell the program the name of your ISP’s NNTP,or news server. You should have received this information when you signed up for service.Once you have the name, you can tell tin the NNTP server name in at least twoways: by creating an nntpserver file under the /etc directory, which will only work fortin, or by creating an environment variable named NNTPSERVER, which will work for tinand slrn.You do not have to create the nntpserver file or the NNTPSERVER variable ifyou use the kppp client to connect with your ISP. The kppp client will createtemporary entries in the hosts file in your OpenLinux /etc directory.To create the nntpserver file, first make sure you’re logged in as root. Then, using a texteditor (such as pico), create a file call nntpserver in the /etc directory. There’s no specialformat to the file; all you have to do is type the name of the news server:news.erols.comSave the file and exit your editor. However, a better way to tell tin your ISP’s newsserver is to define an environment variable named NNTPSERVER. Creating environmentvariables is discussed in Hour 6, “Using the Shell.” One way to create the NNTPSERVERvariable, if you always use the bash shell, is to log in as root and then edit a file namedprofile in the /etc directory. Enter the following into the file, and make sure theNNTPSERVER variable is placed in the export statement:NNTPSERVER=news.erols.comexport NNTPSERVER


Configuring Internet News 273You can then read the variable into your environment with# source /etc/profileAfter reading the new variable from this file, you can check for the NNTPSERVER variableby piping the output of the env or printenv command through the fgrep command:# printenv | fgrep NNTPSERVERNNTPSERVER=news.erols.comYou can also log out, log back in, and check again. Once defined, the NNTPSERVER variablewill work for tin and slrn.After you have defined your NNTPSERVER, connect with your ISP and call tin with thiscommand line:# tin -nqrThe -n option tells the tin program that you want it to only load newsgroups from your.newsrc file, whereas the q option specifies a quick start without checking for any newnewsgroups. Finally, the r option tells tin to read your news remotely from your ISP’sNNTP server. Once tin reads the groups and gathers any new news, it will display thenewsgroups in a list (see Figure 12.1). Read a group’s messages by using the Up orDown cursor keys to highlight a newsgroup name and then pressing Enter. The list ofmessages will appear, as shown in Figure 12.2.If you don’t want to use tin with its -r option but need to retrieve yournews from a remote server, use the rtin version of tin with remoteretrieval compiled in.12FIGURE 12.2Listing a newsgroup’smessages with the tinnewsreader.


274 Hour 12To read a message, scroll through the list (using the arrow keys) and press Enter.The message will appear. Although many OpenLinux Usenet readers like to lurk,or just read messages, you can reply directly by electronic mail to the person who postedthe message by pressing the r key and composing a reply or follow-up to the messageand post your comments by pressing the f key. Table 12.1 lists the main tin commands.NEW TERMTABLE 12.1 COMMON tin COMMANDSActionCommandBackward search through articles ?Follow up with post (when reading message)fForward search through articles /List articles in highlighted group or read messageEnterPost a new article to current groupWQuit reading, quit listing, or quit tinqRead tin’s helphReply by email (when reading message)rSave current message to disksSearch for article author (in message list)aSubscribe to group (in group list)sUnsubscribe to group (in group list)uYou can configure many tin settings, such as the default editor to use while posting orreplying to messages. Edit the tinrc file under the .tin directory in your home directory.For other details about this newsreader, read the tin manual page.Reading Usenet News with the slrnNewsreaderThe slrn newsreader, by John E. Davis, in the /usr/bin directory, is a newsreader liketin. However, slrn has some nifty features not supported by the tin program:●●●●Message headers and messages are displayed at the same time.Extensive custom colors for different parts of the display and messages areavailable.Mouse-cursor–aware mode.Different NNTP servers can be specified on the command line.


Configuring Internet News 275Figure 12.3 shows the slrn screen.FIGURE 12.3The slrn newsreaderfeatures mouse-awaremenus and split-screenviewing of messagesand message contents.The slrn program features a split display once you’re reading messages in a newsgroup.You can also run slrn without specifying an NNTPSERVER variable with the -h commandlineoption:# slrn -h news.staffnet.comYou’ll also be able to browse quickly once you learn most of its keystroke commands,which are listed in Table 12.2.12Here’s a tip on an undocumented feature you won’t find in the slrn manualpage: You can scroll up and down through messages by using the left orright mouse buttons of your mouse. Use slrn in a menu-driven mode byenabling mouse support. This is handy if you run slrn in an xterm or rxvtwindow under X11.


276 Hour 12TABLE 12.2 COMMON slrn COMMANDSActionCommandClose current articlehFollow-up post to current articlefForward copy of article by emailFGo to next newsgroupNMark all articles in group (or message list) as read cPost article to current grouppQuit reading articles (in current group)qQuit slrn (from group list)qRead the next article in current groupnReply by email to current articlerSave current articleoSearch for article (in message list) /Search for newsgroup name (in group list) /Subscribe to current groupsUnsubscribe from current groupuWhen you start slrn, the program looks under the /var/lib/slrn directory for a filecalled slrn.rc, which contains system-wide defaults for the program. You should copythis program as .slrnrc to your home directory and make your changes to this file.Although there are many different customizations you can perform, I cover a few here toget you started.First, look for the hostname, username, realname, and replyto entries in the file. Theseentries look something like%hostame “YOUR.HOSTNAME”%set username “jd”%set realname “John Doe”%set replyto “jd@somthing.com”Change these entries to your username, your real name, and your email address:hostname “erols.com”set username “bball_NO_SPAM”set realname “William Ball”set replyto “bballREMOVE_TO_REPLY@erols.com”


Configuring Internet News 277Note that you must remove the percent character (%) from the beginning of each of theselines to enable the options. I have also included the _NO_SPAM and REMOVE_TO_REPLYphrases in the username and replyto entries. These are to foil those insidious, nefarious,and insipid computer users who use “harvesting” software to extract email addresses andbuild spam lists from Usenet postings.Using an invalid but easily correctable email address in newsgroup posting(such as bball@_ALL_SPAMMERS_SHOULD_BE_HANGED_erols.com) is one way toprotect yourself against ending up in a junk emailer’s spam list. See Hour 11,“Configuring Internet Email” to see how to automatically trash any incomingjunk mail. Fortunately, a number of state governments in the UnitedStates, such as California, now have a $500 penalty for each piece ofunwanted junk email. I hope other states will follow with similar legislationto help stem this electronic plague.To enable mouse support, also look in your .slrnrc file for% Enable xterm mouse support: 1 to enable, 0 to disableset mouse 0Change set mouse 0 to set mouse 1 to enable menu- and mouse-driven modes in slrn.Yet another change you might want to make concerns how slrn displays messages andmenus. Look for the color section of the .slrnrc file:%-------------------------------------------------------% Colors%-------------------------------------------------------color header_number “black” “white”color header_name “black” “white”color normal “black” “white”color error “red” “white”color status “yellow” “blue”color group “blue” “white”color article “blue” “white”color cursor “black” “white”color author “blue” “white”color subject “black” “white”color headers “black” “white”color menu “yellow” “blue”color menu_press “blue” “yellow”color tree “red” “white”color quotes “red” “white”color thread_number “blue” “white”color high_score “red” “white”color signature “red” “white”color description “blue” “white”color tilde “black” “white”12


278 Hour 12These lines are in the format of display item, foreground color, and background color.According to the slrn manual page, these colors can beblackredgreenbrownbluemagentacyanlightgraygraybrightredbrightgreenyellowbrightbluebrightmagentabrightcyanwhiteWith a little bit of work, you can devise your own display.Make your changes and then save the file. To use color during your newsreadingsessions, start slrn with its -C or color option:# slrn -CWhen slrn starts, you’ll have a color display and you can use your mouse to click menuitems at the top of the screen, click a newsgroup to see lists of messages, or click a messagein a message list to read the message.The slrn newsreader is a flexible, customizable program that will work in black-andwhiteor color, with or without X11, and with the keyboard and your mouse.Reading Usenet News with the krn ClientThe krn client, included with KDE, is a graphical interface to reading Usenet news. Youmust run X11 in order to use the program (but you don’t have to use KDE). If you useKDE for your X11 sessions, start krn by clicking the Application Starter button on yourdesktop’s panel, selecting the Internet menu item, and then clicking the News client item.If you use some other window manager, you can start krn from the command line of aterminal window like this:# krn &After you press Enter, the krn main dialog will appear, as shown in Figure 12.4.To configure krn, select the Options menu and then click Identity. The identity dialogwill appear, as shown in Figure 12.5. Enter your real name, your email address (if youwant, use the previous method for slrn to mask your address from spammers), and yourOrganization. (This field cannot be left empty, so you can use the default hyphen (-)entry.) This information will be used when you reply by email or follow up to a newsgroupposting. When finished, click OK to save your settings.


Configuring Internet News 279FIGURE 12.4The krn newsreaderfeatures the familiarKDE graphical interfacewith a menu bar,buttons, and scrollingwindow.FIGURE 12.5The krn identity dialogsets your usernameand email address.Next, open the Options menu and click NNTP Options. In the dialog, shown in Figure12.6, type the name of your ISP’s mail server. Then, click in the NNTP Server field andtype the name of your ISP’s news server. If you want krn to connect to your ISP’s newsserver as soon as it starts, select the appropriate option. If you need a username or passwordto access your ISP’s news server, enter the correct username and password. Thesesettings are used when krn connects to your news server and when you email a reply to aUsenet post. When finished, click OK to save your settings.12FIGURE 12.6The krn NNTP optionsdialog is where you setaccess options foremail and newsservice when newsreading.


280 Hour 12You can set other options, such as how long you want to hold onto messages or how toprint, through other menu items under the Options menu.The main krn dialog features a row of buttons you can use to connect to or disconnectfrom your news server, list or find groups, subscribe or unsubscribe to groups, check forunread articles, or post new articles. To get an initial list of newsgroups from your ISP,click the Get list of active groups button (left of the Find group button with the smallmagnifying glass). krn will then ask whether it can connect to your ISP’s news server.Click OK.This operation might take several minutes as krn builds a list of newsgroups from yourserver. You’ll see the size of the group file along with the message “Getting active listfrom server” at the bottom of krn’s window. When krn is finished, click the small plussign (+) to the left of the All newsgroups folder.The folder will open and list each top hierarchy of Usenet’s newsgroups as another seriesof folders. Scroll through the list, and continue to click open folders until you reach adesired newsgroup, such as alt.os.linux.caldera. The newsgroup will appear, asshown in Figure 12.7.FIGURE 12.7The krn clientretrieves a list ofnewsgroups fromyour ISP and displaysthem in a hierarchy offolders.Click and highlight a newsgroup name and then press the Subscribe button from krn’smenu bar. The small, blank document icon of the newsgroup will change to a documentwith a small quill attached. Repeat this step to build your list of subscribed newsgroups.The next time you start krn, your newsgroups will appear in the Subscribed folder.To retrieve all available messages in the newsgroup, double-click the newsgroup name.The krn main newsreading window will appear after all unread messages have beenretrieved and will show a list of articles (messages). If you click an article, its text willappear in the lower half of the newsreading window, as shown in Figure 12.8.


Configuring Internet News 281FIGURE 12.8The krn newsreadingwindow features scrollbars and a point-andclickinterface forreading, replying to,or following up onnewsgroup articles.The numerous buttons in the window’s menu bar let you●●●●●●●●●Navigate through the newsgroup’s articlesSearch for subjectsPrintSave to diskReply to by emailFollow up with a postReply and follow upForward by emailMark as read or unread12Click your mouse button on the Sender, Date, Lines, or Subject column headingsto sort the article list.


282 Hour 12Reading Usenet News with NetscapeDiscussionsWithout a doubt, one of the most popular Internet software suites for OpenLinux isNetscape Communicator. You can use the Netscape Discussions component ofCommunicator to read Usenet news. If you’re using KDE, click the Netscape icon inyour desktop’s panel to start Netscape, and then select the Communicator menu and clickthe Collabra Discussions menu item.You can also start Netscape and jump right into Discussions from the command line of aterminal window by using the netscape command and the -news option:# netscape -news &After you press Enter, the Discussions window will appear. It looks similar to Netscape’sMessenger, as shown in Figure 12.9.FIGURE 12.9Before configurationto read Usenet news,Netscape Discussionslooks very similar toNetscape’s Messenger,or email window.To configure Discussions to read news, first Open the Preferences menu and then clickPreferences. Next, in the dialog shown in Figure 12.10, click the Groups Server under theMail and Groups list item. Type the name of your ISP’s news server, and specify thedirectory you’d like to use to save newsgroups messages. When finished, click OK.


Configuring Internet News 283FIGURE 12.10The Preferences dialogis where you set thename of your ISP’snews server and yournews directory.You’ll be returned to the Discussions window. To get a list of newsgroups from your ISP,click the Join Groups button in the window’s menu bar. A newsgroup dialog will appear,as shown in Figure 12.11. Make sure your ISP’s news server is selected at the bottom ofthe dialog and then click the Get Discussion Groups button.FIGURE 12.11The newsgroup dialogis used to retrieve andsubscribe to variousUsenet newsgroups.12


284 Hour 12Discussions will retrieve the list of newsgroups available from your ISP. This operation,similar to that for krn, might take some time. When Discussions finishes, you’ll see a listof newsgroups, sorted by hierarchy. Scroll through the list and open folders until youreach a newsgroup you like. Next, click the newsgroup and then click the Join button tosubscribe. A small blue checkmark will appear to right of the newsgroup name. Repeatthis step until you have subscribed to the desired number of groups. When finished, clickthe OK button.Instead of clicking the Join button, you can click the tiny ball to the right ofeach newsgroup name to make the checkmark appear and subscribe to thegroup.You’re returned to the main Discussions window. Click the small plus sign (+) next to thename of your ISP’s news server in the list of folders in the window. The list of your subscribed(joined) groups will appear. To retrieve articles for a newsgroup, double-click thenewsgroup’s name in the list. Discussions will launch the newsreading window with thelist of articles for the group, as shown in Figure 12.12.FIGURE 12.12The Discussions newsreadingwindow listseach newsgroups articlesin a scrolling list.Use the buttons on the newsreading window’s menu bar during your group session.


Configuring Internet News 285To quickly jump to a list of articles for a different newsgroup, click the dropdownmenu at the current newsgroup’s name (as shown in Figure 12.12) andselect a new group.Before Posting to a Usenet GroupYou should keep in mind several things when you feel tempted to post a message to aUsenet newsgroup. First, it’s much better to lurk for a while before posting. Chances arethat you’ll find the answers you need before you post a message. Make sure you’re postingto the right newsgroup or newsgroups. Check to make sure you’re not cross-posting,or sending messages that may be off topic in other groups. Make sure you ask the rightquestion in the right newsgroup. Woe be to the unfortunate miscreant who asks forWindows 98 advice in comp.os.windows! At best, you’ll be ignored, and at the worst,you’ll be flamed unmercifully and termed a luser (a user who’s a loser).Keep in mind that Usenet is worldwide. Your comments, opinions, jokes, and observationsmight not be welcome, funny, or relevant to other members of the Usenet community.What is true in the United States might not be true in other countries.If you’re thinking about advertising your business or service in Usenet newsgroups, postyour “advertisement” in the proper newsgroup (for example, if you have something tosell). Spamming newsgroups with your ads, in this author’s opinion, should be cause forretribution worse than social ostracism. There are more than one or two of the 50,000-plus newsgroups where you can post messages to sell stuff.Asking for help? You’ll have much better success in getting help from other people ifyour subject line is a good summary of your request:12Subj: Help! How do I recover my Linux filesystem?Finally, one of the things you should know about Usenet is that there are, for all practicalpurposes, no rules. You’ll converse with all kinds of people from countries all over theworld. Some people are nice, and others are, well, not so nice. The good news is that thegood-hearted newsgroup posters are in the majority.Every new Usenet person should subscribe to news.announce.newusers. This newsgroupcontains FAQs, etiquette guidelines, and handy tips to help you find answers.You’ll read about the history of Usenet and find interesting statistics and a copy of thelatest, complete listing of newsgroups.


286 Hour 12SummaryThis hour introduced four different Usenet newsreaders for OpenLinux. As you probablylearned, each program allows you to easily read news but offers different features andrequires a different configuration. Reading Usenet news is an addictive pastime that canoffer great rewards when you’re looking for information or troubleshooting tips aboutnearly any subject.Q&AQ What other newsreaders are included on my OpenLinux CD-ROM?A You’ll find several other newsreaders for the console or the X Window Systeminstalled with OpenLinux. Try running the knews, trn, nn, or xrn readers from thecommand line of a terminal window. These programs are also capable newsreaders(although perhaps not as popular with the Linux crowd as with users of other variantsof the UNIX operating system).Q Are there any newsreading utilities included with OpenLinux?A Yes. See the pnews, lmove, lpost, newsetup, and newsgroups commands.Q I’d like to read my news articles after closing down my PPP connection withmy ISP. Is there a program I can use to do this?A Use the suck command. This program will download articles from your ISP andsave the news feed according to the command line you specify, such as to a singlefile, separate files, or indexed file format suitable for other newsreaders. See thesuck man page for details.Q Is it true that I can use the pine email program to read Usenet news?A Yes! The pine program is almost two programs in one. Although most people willuse pine primarily as a mail handler, pine can be an efficient way to read newsand can save you disk space if you don’t have much room on your hard drive forother programs (especially if you’re using a laptop computer). Specify your ISP’snews server in the .pinerc file in your home directory or through pine’s setupand config commands. To read news, make sure you’re connected to your ISP andthen run pine. Move to the folder list view, press the Enter key, and then movedown to the news collection expanded list and press the Enter key.


Configuring Internet News 287Exercises1. Use krn’s search for newsgroup function to find a newsgroup about a topic whenreading news. Which button in krn’s window is used to search for a newsgroup?2. Find out how many newsgroups your ISP supports. Are all newsgroups availablethrough your service? Were any limitations on the number of groups spelled out inyour service contract?3. Editing a text list of groups (such as .jnewsrc or .newsrc) for reading news is ahandy way to limit the availability of newsgroups for the younger crowd. How elsecan you limit or protect this list from being modified?12


HOUR 13Internet Downloadingand BrowsingThis hour introduces you to programs you use to get information and programsfrom the Internet. I assume that you are signed up with an InternetService Provider (ISP) and that you configured your OpenLinux system tostart and stop Point-To-Point Protocol network connections.If you already have an account with a local ISP but have notconfigured your Linux system to connect to the Internet, readHour 10, “Connecting to the Internet,” for instructions.I first introduce you to two Internet file transfer programs and then coversome of the many World Wide Web browsers you can find for Linux.


290 Hour 13Using File Transfer Protocol Programs toGet FilesThere are several ways to retrieve files from other computers on the Internet. Youcan use email or a Web browser, but if you’re interested in just getting files intoyour computer, you can use the ftp (file transfer) program. The ftp program is one ofthe oldest programs to support the standard File Transfer Protocol, or FTP, and was theoriginal program designed to transfer files. The FTP protocol enables you to send andreceive files interactively with get and put commands.NEW TERMThe next section shows you how to use two FTP transfer programs, ftp and ncftp.Retrieving Files with the ftp CommandThe ftp command, found under the /usr/bin directory, has five different command-lineoptions but is most often used with a hostname, or name of a remote computer, forexample:# ftp ftp.mcp.comThis command line specifies that you want to connect to the ftp server at MacmillanPublishing. You don’t have to specify a hostname on the command line because you canrun the ftp program interactively, repeatedly connecting to and disconnecting from differentcomputers. The ftp command has more than 70 different built-in commands,including a help facility. This hour doesn’t cover all the different commands, but you canget more information about these commands by reading the ftp program’s manual pageor by using the built-in help command.Some of the commands you’re most likely to use, especially when all you want to do isretrieve some programs or source code from Linux sites, are the following:!—Prompts for and runs a shell command. This is a handy way to view the contentsof files, delete files you download, or check on how much hard drive space you haveleft.ascii—Downloads any specified files in text form.binary—Downloads any specified files in binary form. You must use this commandbefore downloading most compressed Linux files.bye—Closes any open connection and exits the ftp program.cd —Changes directories, for example:> cd ..


Internet Downloading and Browsing 291close—Closes the current connection.get—Downloads a specific file from the current directory to your current directory,for example:> get killbarney.tgzls —Lists files or directories in the current directory.mget—Downloads several files, one after another, that match a specified pattern, forexample:> mget kill*.tgzopen—Opens a connection to a specified host, for example:> open ftp.mcp.comprompt—Toggles interactive prompting (such as the use of y or n when downloadingmultiple files).For example, to run the ftp command interactively, all you have to do is type thefollowing:# ftpftp> helpCommands may be abbreviated. Commands are:! debug mdir sendport site$ dir mget put sizeaccount disconnect mkdir pwd statusappend exit mls quit structascii form mode quote systembell get modtime recv suniquebinary glob mput reget tenexbye hash newer rstatus tickcase help nmap rhelp tracecd idle nlist rename typecdup image ntrans reset userchmod lcd open restart umaskclose ls prompt rmdir verbosecr macdef passive runique ?delete mdelete proxy sendftp> help exitexitterminate ftp session and exitftp> help byebyeterminate ftp session and exitftp> bye#13


292 Hour 13If you have a shell or login account with your ISP, you can run into problemswhen downloading large files if your ISP enforces disk quotas, which limitthe amount information that can be stored in a user’s directory. See if yourISP lets you first change the directory to a /tmp directory if using ftp, andthen open a connection to download any large files. The /tmp directory islater cleaned out by any housekeeping crontab routines to make more storageroom, and you can download large files without hitting hard limits onquotas.To demonstrate the ftp program in action, I show you a sample session used to downloada compressed file from the University of North Carolina’s famous Linux repository(formerly known as sunsite, but now named MetaLab):# ftp ftp.metalab.unc.eduConnected to helios.metalab.unc.edu.220- Welcome to UNC’s MetaLab ftp archives!220- (at the site formerly known as sunsite.unc.edu)220-220-You can access this archive via http with the same URL.220-220-example: ftp://metalab.unc.edu/pub/Linux/ becomes220- http://metalab.unc.edu/pub/Linux/220-220-For more information about services offered by MetaLab,220-go to http://metalab.unc.edu220-220-WE’RE BACK TO USING WUFTPD.220-You can still get tarred directories if you issue the following➥command:220- get dirname.tar220-You can also get gzipped or compressed tarred directories by➥ following220-the .tar with .gz or .Z, respectively.220-220-Have any suggestions or questions? Email ftpkeeper@metalab.unc.edu.220-220 helios.oit.unc.edu FTP server (Version wu-2.4.2-academ[BETA-13](6)➥Thu Jul 17 16:22:52 EDT 1997) ready.Name (ftp.metalab.unc.edu:bball): anonymous331 Guest login ok, send your complete e-mail address as password.Password:230 Guest login ok, access restrictions apply.Remote system type is UNIX.Using binary mode to transfer files.ftp> cd pub/Linux


Internet Downloading and Browsing 293250-README for250-250-Linux: A copylefted Unix-like operating system for 80[3456]86,250- DEC Alpha, Sun SPARC, Motorola 68k, PowerPC/PowerMac,250- ARM, Mips R[3,4]x00, Fujitsu AP/1000+ and more to come.250-250-Mirrors are better! Look at the MIRRORS file to find one near you.250-250-Email linuxguys@sunsite.unc.edu with comments/complaints about this➥archive.250-250-Please see HINTS for information on how to get most effective use➥out of250-this archive. HINTS was last updated on 17 March 1997.250-250 CWD command successful.ftp> cd apps250-README for /apps250-250-What you’ll find here: large useful packages and applications for➥Linux250-250-250 CWD command successful.ftp> ls200 PORT command successful.150 Opening ASCII mode data connection for /bin/ls.total 41-rw-rw-r-- 1 347 1002 1573 Jul 04 1998 !INDEX-rw-rw-r-- 1 347 1002 2697 Jul 04 1998 !INDEX.html-rw-rw-r-- 1 347 1002 2823 Jul 04 1998 !INDEX.short.➥htmldrwxrwsr-x 26 347 1002 512 Jul 19 1998 .drwxrwsr-x 25 67 1002 1024 Jan 26 05:28 ..drwxrwsr-x 2 347 1002 512 Mar 25 1997 MGR-rw-rw-r-- 1 347 1002 91 Jul 04 1998 READMEdrwxrwsr-x 2 347 1002 512 Sep 03 21:15 appliancedrwxrwsr-x 2 347 1002 512 Dec 27 18:59 caidrwxrwsr-x 2 347 1002 512 Dec 24 19:44 chinesedrwxrwsr-x 4 347 1002 2560 Jan 25 22:44 circuitsdrwxrwsr-x 2 347 1002 512 Apr 01 1997 conferencingdrwxrwsr-x 2 347 1002 1024 Nov 27 18:49 cryptodrwxrwsr-x 12 347 1002 512 Jul 04 1998 databasedrwxrwsr-x 4 347 1002 512 Jan 25 21:14 doctoolsdrwxrwsr-x 7 347 1002 512 Mar 28 1998 editorsdrwxrwsr-x 6 347 1002 512 Jul 15 1998 financialdrwxrwsr-x 13 347 1002 512 Jan 25 22:47 graphicsdrwxrwsr-x 8 347 1002 1024 Sep 27 20:03 hamdrwxrwsr-x 7 347 1002 1024 Oct 20 20:34 mathdrwxrwsr-x 2 347 1002 1536 Jan 25 22:55 miscdrwxrwxr-x 2 347 1002 512 Oct 22 19:10 office13


294 Hour 13drwxrwsr-x 2 347 1002 1024 Jan 22 21:05 religiondrwxrwsr-x 4 347 1002 1024 Dec 08 20:31 reminderdrwxrwsr-x 7 347 1002 512 Mar 28 1997 serialcommdrwxrwsr-x 19 347 1002 1536 Jan 11 15:47 sounddrwxrwxr-x 6 347 1002 1536 Nov 19 21:37 texdrwxrwsr-x 2 347 1002 2048 Jan 25 21:02 videodrwxrwsr-x 6 347 1002 512 Jul 09 1998 wpdrwxrwsr-x 13 347 1002 512 May 19 1997 www226 Transfer complete.ftp> cd appliance250-README for apps/appliance250-250-What you’ll find here: household appliance control250-250-250 CWD command successful.ftp> ls200 PORT command successful.150 Opening ASCII mode data connection for /bin/ls.total 250-rw-rw-r-- 1 347 1002 634 Sep 03 21:15 !INDEX-rw-rw-r-- 1 347 1002 2454 Sep 03 21:15 !INDEX.html-rw-rw-r-- 1 347 1002 1197 Sep 03 21:15 !INDEX.short.➥htmldrwxrwsr-x 2 347 1002 512 Sep 03 21:15 .drwxrwsr-x 26 347 1002 512 Jul 19 1998 ..-rw-rw-r-- 1 347 1002 79 Sep 03 21:15 README-rw-rw-r-- 1 754 1002 861 Aug 24 05:05 alarm-0.20b.lsm-rw-rw-r-- 1 754 1002 6559 Aug 24 05:05 alarm-0.20b.tar.gz-rw-rw-r-- 1 347 1002 14895 Aug 25 1997 cheaplightswitch➥ -1.0.tgz-rw-rw-r-- 1 347 1002 666 Aug 25 1997 cheaplightswitch.➥lsm-rw-rw-r-- 1 347 1002 29617 May 19 1998 irx-v0.1.tgz-rw-rw-r-- 1 347 1002 691 May 19 1998 irx.lsm-rw-rw-r-- 1 347 1002 469 Jun 16 1998 netlitng.lsm-rw-rw-r-- 1 347 1002 28081 Jun 16 1998 netlitng.tgz-rw-rw-r-- 1 347 1002 1007 Jul 14 1997 twd-0.2.lsm-rw-rw-r-- 1 347 1002 21903 Jul 14 1997 twd-0.2.tgz-rw-rw-r-- 1 347 1002 580 Jan 22 1996 x-automate➥-1.00.lsm-rw-rw-r-- 1 347 1002 110006 Jan 23 1996 x-automate➥-1.00.tgz-rw-rw-r-- 1 347 1002 1290 Mar 07 1997 x10-amh-v1.06.lsm-rw-rw-r-- 1 347 1002 12168 Mar 07 1997 x10-amh-v1.06.tgz226 Transfer complete.ftp> binary200 Type set to I.ftp> get netlitng.tgzlocal: netlitng.tgz remote: netlitng.tgz200 PORT command successful.


Internet Downloading and Browsing 295150 Opening BINARY mode data connection for netlitng.tgz (28081 bytes).226 Transfer complete.28081 bytes received in 8.35 secs (3.3 Kbytes/sec)ftp> bye221 Goodbye.#The session shows that I specified the ftp server at MetaLab as the host computer Iwanted to connect to and retrieve files. By convention, many system administratorscreate and maintain a user called ftp and a directory called ft to accommodate thedistribution of information, software, and software updates.An ftp user with a directory under the /home directory exists on yourOpenLinux system. This directory (/home/ftp) is where you end up if you login anonymously. If you log in to your computer with your username andpassword, you end up in your home directory.By convention, when you use the ftp program to connect to other computers, you enteryour username at the Name: prompt as anonymous, followed by a password in the form ofa mail address, such as user@somewhere.com.You can see that after I logged in, I changed the directory to the pub/Linux directory. Ithen changed to the apps directory and changed directory to the appliance directory. If Ihad known the full path to the directory I wanted, I could have specified that pathnamein a single cd command, for example:cd pub/Linux/apps/applianceI then enabled the ftp command’s binary transfer mode, retrieved the file netlitng.tgzwith the get command, and then logged off and exited the ftp program with the byecommand. As you can see, using the ftp command is not hard and is an easy way toretrieve files.You can also open an anonymous ftp connection to your own computer to demonstratehow ftp works without having an Internet connection available. You can specify thehostname of your computer, which you can get with the hostname command or by usingyour computer’s Internet Protocol address, for example:# hostnamepresario.localhost.localdomain# ftp presarioConnected to presario.localhost.localdomain.220 presario.localhost.localdomain FTP server (Version wu-2.4.2-academ➥[BETA-17](1) Wed Aug 19 02:55:52 MST 1998) ready.13


296 Hour 13Name (presario:bball): anonymous331 Guest login ok, send your complete e-mail address as password.Password:230-Welcome the OpenLinux 1.3 from Caldera Systems, Inc.!230-230-230 Guest login ok, access restrictions apply.Remote system type is UNIX.Using binary mode to transfer files.ftp> ls200 PORT command successful.150 Opening ASCII mode data connection for /bin/ls.total 6drwxr-xr-x 5 root root 1024 Jan 11 16:11 .drwxr-xr-x 5 root root 1024 Jan 11 16:11 ..d--x--x--x 2 root root 1024 Oct 18 14:09 bind--x--x--x 2 root root 1024 Oct 18 14:09 etcdrwxr-sr-x 2 root ftp 1024 Jan 11 16:11 pub-rw-r--r-- 1 root ftp 55 Jan 11 16:10 welcome.msg226 Transfer complete.ftp> bye221 Goodbye.#Note that if you perform an ftp login without an existing username or password, youend up in an ftp directory. You can also log in to other computers using an assignedusername and password, but for this example, I use my own system and the computer’shost IP address:# ftp 127.0.0.1Connected to 127.0.0.1.220 presario.localhost.localdomain FTP server (Version wu-2.4.2-academ➥ [BETA-17](1) Wed Aug 19 02:55:52 MST 1998) ready.Name (127.0.0.1:bball): bball331 Password required for bball.Password:230 User bball logged in.Remote system type is UNIX.Using binary mode to transfer files.ftp> ls dos/mp3music200 PORT command successful.150 Opening ASCII mode data connection for /bin/ls.total 40616drwxr-xr-x 2 bball users 4096 Jan 24 23:25 .drwxr-xr-x 8 bball users 4096 Jan 24 22:27 ..-rwxr-xr-x 1 bball users 5041544 Jan 25 00:24➥Rippingtons-A Place for Lovers.mp3-rwxr-xr-x 1 bball users 4341612 Jan 25 00:48➥Rippingtons-Carnival!.mp3


Internet Downloading and Browsing 297-rwxr-xr-x 1 bball users 5704848 Jan 25 01:15➥Rippingtons-Highroller.mp3-rwxr-xr-x 1 bball users 5480811 Jan 25 00:14➥Rippingtons-Indian Summer.mp3-rwxr-xr-x 1 bball users 5538079 Jan 25 01:02➥Rippingtons-Moka Java.mp3-rwxr-xr-x 1 bball users 5704686 Jan 25 09:55➥Rippingtons-St. Tropez.mp3-rwxr-xr-x 1 bball users 4606027 Jan 25 00:01➥Rippingtons-Vienna.mp3-rwxr-xr-x 1 bball users 5150057 Jan 25 00:48➥Rippingtons-Weekend in Monaco.mp3226 Transfer complete.ftp> bye221 Goodbye.#In this example, after logging in with my system username and password, I ended up inmy home directory instead of the default ftp directory. I then listed the contents of afolder on another mounted file system (you can’t tell from the pathname or the files). Ifyou have an open PPP connection with your ISP and other users know your computer’sIP address, you and other users can access your system’s files and upload and downloadfiles.Downloading with the ncFTP ProgramThe ncftp command, found under the /usr/bin directory, is much like the original ftpcommand but features some unique improvements, such as the following:●●●●A visual mode with colorsA status bar with a separate command line and scrolling windowVisual status of downloading—a progress meter to show elapsed and remainingtime for file downloadsBookmarks and a bookmark editor, so you can use abbreviated hostnames of computersLike the ftp command, ncftp also has built-in help. The ncftp command, by MikeGleason of NCEMRSoft, also sports a number of interesting command-line options. Ifyou know the hostname of the computer and the complete path to a desired file, you canretrieve the file with a single command line, for example:13# ncftp -a ftp://ftp.metalab.unc.edu/pub/Linux/apps/appliance/➥netlitng.tgz# nctp -a ftp.metalab.unc.edu/pub/Linux/apps/appliance/netlitng.tgz


298 Hour 13Both command lines connect to the ftp.metalab.unc.edu host, log in anonymously, andthen retrieve the file. This is a handy way to retrieve known files from remote computers.These command lines can also be used in shell scripts or combined with pipes to othercommands to process the incoming files. You can, for example, automatically translateincoming graphics files and save them in a specified directory:# ncftp -c rsd.gsfc.nasa.gov/pub/Weather/GOES-8/gif/mapped/color/➥conus/latest.gif | giftopnm | ppmtopcx >/home/ftp/weather.pcxThis example downloads a .GIF format weather satellite image, translates the graphicinto .pnm format and then .pcx format, and saves it in your system’s ftp area. You canuse this approach to download and update files automatically, especially when used in acrontab file. (For details about using crontab, see Hour 24, “Using Scheduling toAutomate System Management,” or Hour 18, “Personal Productivity Tools”).The ncftp status bar is helpful when interactively downloading files. Although I can’tshow you the animation of the progress meter, when you use ncftp to download files,you get information on how the downloading is going, for example:wustl> get app-defaults.colorReceiving file: app-defaults.color100% 0 ==================================> 6583 bytes. ETA: 0:00app-defaults.color: 6583 bytes received in 5.77 seconds, 1.11 kB/s.ftp.wustl.edu /packages/NCSA/Web/Mosaic/Unix/binaries/app-defaultswustl>This shows a completed download of the X11 application defaults file for the MosaicWeb browser.If you do a lot of downloading via FTP using anonymous log in, create a filenamed .netrc in your home directory. Enter a single line like this:default login anonymous password yourusername@yourISP.comUse your email address for yourusername@yourISP.com. The next time youuse the ftp or ncftp command, you’re automatically logged in!Browsing the World Wide Web with LinuxBrowsersThis section introduces you to several Web browsers for Linux. You can find thesebrowsers on your OpenLinux CD-ROM included with this book.


Internet Downloading and Browsing 299You can find other browsers, such as Chimera, Mosaic, and qweb athttp://metalab.unc.edu/pub/Linux/apps/www/browsers.This book doesn’t have enough room to cover these browsers in detail. If you’re interestedin learning about Web browsers or writing your own Web pages, I suggest you lookat the following books:HTML by Example, by Todd Staufer; QueUsing HTML, by Mark Brown, John Jung, and Tom Savola; QueFast Browsing with the lynx CommandThe Lynx browser, originally sponsored by the University of Kansas, does not supportgraphics, sound, or any of the other plug-in features of today’s modern Web browsers.You can really like Lynx anyway because it’s fast, efficient, and does not take up a lot ofdisk space.Lynx was designed to run on regular displays, or terminals, so you don’t need to run theX Window System in order to use it. This program is ideal for quickly browsing Webpages to get the information you need without the “World Wide Wait” of too-largegraphics or animations that just waste bandwidth.The Lynx browser has 66 different command-line options, but it’s easy to use. Ifyou properly set up your system and start your PPP connection, you can startbrowsing by specifying a Uniform Resource Locator (URL), or Web address, on thecommand line, for example:NEW TERM# lynx http://www.mcp.comFigure 13.1 shows the Lynx browser.If you need to fine-tune some of the ways the lynx command works, you can edit itsconfiguration file, lynx.cfg, in the /usr/lib directory. I suggest that you make a copyof this file and copy it to your home directory with .lynxrc as the filename. In this file,you can set a number of Lynx features. For example, if you specify the name of yourISP’s news server, you can read news:13NNTPSERVER:your.ISPnewserver.comAfter you make this change, you can try to browse news with this:# lynx news://your.ISPnewserver.com


300 Hour 13FIGURE 13.1The Lynx text-onlyWeb browser is a compact,efficient programyou can use to quicklybrowse Web pageswithout waiting forgraphics to load.You can also use the Lynx browser to retrieve files without browsing. By using thisapproach, you can automatically research or get information on a regular basis:# lynx http://www.yahoo.com/headlines/news -dump >news.rawIn this example, the content of the Web page is downloaded by the lynx command andthen redirected to the file news.raw. Lynx also downloads files just like other browsers ifyou press the Enter key while your cursor has a file or link highlighted. The basic navigationkeys for this browser are the cursors (to scroll up and down the current page, to goback to a previous page, or forward to the next), the Enter key (to load a link), and theTab key (to go to the next link). To get help while using lynx, type the question mark (?)key.Exploring Netscape CommunicatorThe Netscape Communicator Web browser, by Netscape Communications (soon tomerge with America Online), is one of the most popular browsers for all computer systems.You can find a copy installed on your system that is specifically configured forOpenLinux (see Figure 13.4).Netscape, like most well-behaved X11 clients, uses several X11 Toolkit options. Forexample, if you don’t like the large initial window, you can specify a smaller startingwindow using geometric settings.See Hour 7, “Using the X Window System,” for a discussion of X11 toolkitoptions, such as geometry settings.


Internet Downloading and Browsing 301You can get a list of Netscape’s initial command-line options with the -help option.Some common options are listed in Table 13.1.TABLE 13.1DescriptionDisplay versionCOMMON NETSCAPE COMMUNICATOR COMMAND-LINE OPTIONSDon’t remember session settingsDon’t remember window settingsDon’t show license pageIgnore saved window settingsLaunch to ComposerLaunch to Discussions (newsreader)Launch to MessengerLimit colorsSet X11 resource (from the file Netscape.adunder the /opt/netscape/communicatordirectory)Show GUI helpShow helpStart, and then iconifyStart as a floating toolbarUse black and whiteUse server svrUse window of WxH at X,YUse X colorsOption-version-no-session-management-dont-save-geometry-prefs-no-about-splash-ignore-geometry-prefs-composer or -edit-discussions or -news-messenger or -mail-install-xrm resource-nethelp-help-iconic-component-bar-mono-display svr-geometry=WxH+X+Y-ncols XSeveral of these options are useful if you start Netscape from the command line of a terminalwindow. For example, as I pointed out earlier in this hour, the geometry settingscan help reduce the initial window size of your browser. A much better option, especiallyfor laptop users with little screen real estate, is the -component-bar option, for example:13# netscape -component-bar &This command runs Netscape, but the application and its additional components, whichinclude Mailbox, Discussions, and Composer, appear in a short vertical floating window(shown in Figure 13.2) you can put off to one side of the screen. You can then run thedesired component by clicking one of the icons in the small window.


302 Hour 13FIGURE 13.2NetscapeCommunicator offers aconvenient and compactcomponent barfor small desktops thatcan be used to launchNavigator and othercomponents.If you need help using Netscape, use Netscape’s Help menu information system. To gethelp, open the Help menu, and click the Help Contents menu item. A help dialog boxappears, as shown in Figure 13.3. Unlike some browsers, Netscape comes with all thehelp files you need to get started. You can find information about each component andhow to set up and use them, along with a full discussion of HTML page composition.FIGURE 13.3NetscapeCommunicator comeswith a complete helpand learning system.You can launch Netscape from the command line by clicking its icon in your LookingGlass desktop or by clicking its icon on your desktop’s panel in KDE. After Netscapestarts, the Navigator main window appears. If you click in Netscape’s Location field oron the Home button in Netscape’s button bar, Netscape loads an introductory help pageon your system, using the address file:/usr/doc/html/Caldera_Info as shown inFigure 13.4.


Internet Downloading and Browsing 303FIGURE 13.4NetscapeCommunicator automaticallydisplayslocal links toOpenLinux and Linuxdocumentationinstalled on yourcomputer.This is a handy and convenient way to read much of the documentation included withOpenLinux and is a good place to start reading or searching if you want to learn moreabout your system.To browse to an Internet address, make sure you have an active Internet connection, thenclick the Location field, and type a URL. Netscape accepts several types of URLs:● about:mozilla The Mozilla Easter egg● file:// To read a local file or display a local graphic● ftp:// To log in to and display a remote FTP server● http:// To load and display a remote Web page● news:your.favorite.newsgroup To read Usenet articlesThe Linux version of Netscape Communicator also supports many differentplug-ins, or additional programs that add features to the browser. Some of theseplug-ins enable you to listen to live radio or watch recorded or live video. For moreinformation about using plug-ins with Netscape, browse to the following:NEW TERM13http://home.netscape.com/plugins/index.htmlAn interesting plug-in is the RealPlayer application. This plug-in plays stereo music fromlive Internet radio stations around the world and can display video clips or live TV in aNetscape Web page or separate window. See Figure 13.5.


304 Hour 13FIGURE 13.5The RealPlayer pluginfrom RealNetworksdisplays live video andaudio over your PPPconnection.Netscape Communicator automatically displays local links to OpenLinux and Linux documentationinstalled on your computer.To see a current list of live TV and radio stations, browse to the following:http://www.timecast.com/stations/realvideo.htmlFor more information about getting the latest RealPlayer plug-in, browse to the following:http://www.real.com/products/player/50player/downloadrealplayer.htmlChatting with Internet Relay ChatThe irc (Internet relay chat) command, found under the /usr/bin directory, is a programyou can use to converse with other people on the Internet. When you run irc, youcan use the built-in irc commands to connect to chat servers, see who is chatting, andset many other options.The irc command has built-in help on more than 110 different commands and topics,many of which have further subtopic help. In order to use this program, you need anactive Internet connection. By default, the irc program tries to connect to a default chatserver (another computer supporting IRC).After you connect, the screen splits into two parts. Ongoing discussions and responsesare in the majority of the upper portion of the screen. You can use the lower portion ofthe screen to enter commands to the irc program or send keyboard sentences as messagesto different active discussions.Using irc is much different from reading and responding to USENET newsgroups (seeHour 11, “Configuring Internet Email,” and Hour 12, “Configuring Internet News”).Discussions and comments are read and sent as you type. You should first browse


Internet Downloading and Browsing 305through the irc command’s help facility, and read all the available introductory informationabout the following topics: basics, commands, etiquette, expressions, intro, ircII,menus, news, newuser, and rules.To start irc, type the command on the command line of your console or an X11 terminalwindow, like this:# irc*** Connecting to port 6667 of server irc-2.mit.edu*** Welcome to the Internet Relay Network bball*** If you have not already done so, please read the new userinformation with/HELP NEWUSER...After you press Enter, a lot of information scrolls by on the screen. Next, get a list of thehelp topics by using the irc /HELP command, for example:> /HELP newuser> /HELP etiquetteThe next step is to see what chat groups are active. Use the /LIST command. You see alist of groups with different names. To join a chat group, use the /JOIN command,followed by the name of the chat group (which is preceded by a pound sign), like this:> /JOIN #linuxAfter you press Enter, you join the group and might see a message such as:*** bball (~bball@207-132-114-136.s196.tnt2.brd.erols.com) has joinedchannel #linux*** Users on #linux: bball whizzo KerNElDudE cathyt ScrottyMessages and chat sentences scroll by on your screen. If you type a sentence and pressEnter, your message is sent to all the users in the chat area. To quit the chat session, usethe /LEAVE command, like this:> /LEAVEAfter you press Enter, you can /LIST other groups or use the /QUIT command to exitIRC.To find out more about participating in irc chat sessions, read the built-in help files, theircII man page, and the documentation for irc under the /usr/doc/irc directory.Another place to learn more about chatting on the Internet is http://www.irchelp.org.13


306 Hour 13Installing and Configuring AOL InstantMessengerAOL’s Instant Messenger, or IM, is a fun and easy-to-use X11 client for chatting withfriends over the Internet. The service is free, and you don’t have to pay for the software.This client constantly checks and then instantly notifies you when a friend logs in theservice. You can then send an instant message!You have to first register at AOL’s Web site and then download and install IM. Navigateto http://www.aol.com/aim/home.html. and sign up for the service by selecting ascreen name and a password and entering your email address (you receive a confirmationmessage by email from AOL). Next, go to the download section, and select the Java version.It takes you about 20 minutes to download the five-megabyte file calledaim_linux.sh (a self-extracting shell script).After downloading, start the installation like this:# sh aim_linux.shAOL Instant Messenger(TM) Registration AgreementYour use of AOL Instant Messenger(TM) service (“Service”) constitutesyour acceptance, and agreement with America Online, Inc. (“AOL”), asfollows: You represent and warrant that you are eighteen years or older.You understand and agree that your use of the Service does not constitutemembership in the AOL service. You agree that you will not use theService to publish, post, distribute or disseminate any defamatory,obscene, or other unlawful material or information. You further agreethat you will not use the Service to transmit unsolicited commercialmessages or use the Buddy Info screens to collect or harvest personalinformation about users of the Service to transmit unsolicited commercialmessages. You will not decompile, reengineer or otherwise copy theService....After several screens of information, you’re asked this question:Do you accept the license? (y/n)Type a y. The script then reports the following:Uncompressing and Installing AOL Instant Messenger.IM is installed in your home directory in a directory named aim. Start your PPP connectionto your ISP, and then launch aim like this:# aim/aim&


Internet Downloading and Browsing 307After you press Enter, you see the main IM dialog box, as shown in Figure 13.6.FIGURE 13.6AOL’s InstantMessenger for Linux isan Internet notificationand chat tool.Enter your username in the Screen Name field, press the Tab key, and then enter yourpassword. After you press Enter and your username and password are verified, the IMmain dialog box appears. To configure IM, select the File menu, and then click Optionsand the Edit Preferences menu item. A dialog box, shown in Figure 13.7, appears next toIM’s main window.FIGURE 13.7The main IM windowshows you whenfriends log on to theInternet, AOL, orInstant Messenger,whereas the Setupdialog box is used toconfigure IM.13You can now add an IM Buddy and set other options. When a buddy logs on, his or hername appears in your IM’s buddy list. To send an instant message, click your buddy’sname, and then click the IM button in the main dialog box. Enter your message, and thenclick the Send button to chat.


308 Hour 13Connecting with Other Computers with thetelnet CommandYou can use the telnet command to log in to remote computers to run programs, viewfiles, or download data. The telnet command has a number of options but is generallyused with a hostname or remote computer system’s name on the command line to start atelnet session, for example:# telnet computer.somewhere.comThis command connects you to the remote computer, and you receive a login prompt.You generally need to have a username and password in order to enter the remote system.For security reasons, few computer systems enable unknown users anonymousaccess. You might be able to find a list of computer systems providing access by usingyour favorite search engines, such as through a Web search site.If you “telnet” to a remote computer system through an active Internetconnection or through a shell account through a direct dial-in to thecomputer, you can easily transfer programs using the sz and rz (send andreceive) files (if those programs are resident on the remote computer). Afteryou dial in to a remote computer directly through the phone line, you cantransfer files to your computer with sz -w 2048 filename.tgz. This commandsends the file filename.tgz using the ZMODEM communicationsprotocol. Your communications program automatically starts receiving thefile using this protocol (most communications programs, anyway). If you’reconnected through an Internet connection, the companion program, rz,automatically starts to receive the file. If not, you can start the rz programmanually. See the sz and rz manual pages for more information.You can also run the telnet command in an interactive mode, opening and closing sessionsto different remote computers. Like the ftp command, the telnet command hasbuilt-in help. If you want to get a list of available help topics, you can use the questionmark (?), for example:# telnettelnet> ?Commands may be abbreviated. Commands are:closelogoutdisplaymodeclose current connectionforcibly logout remote user and close the connectiondisplay operating parameterstry to enter line or character mode (‘mode ?’ for more)


Internet Downloading and Browsing 309openconnect to a sitequitexit telnetsendtransmit special characters (‘send ?’ for more)setset operating parameters (‘set ?’ for more)unsetunset operating parameters (‘unset ?’ for more)statusprint status informationtoggletoggle operating parameters (‘toggle ?’ for more)slcchange state of special charaters (‘slc ?’ for more)authturn on (off) authentication (‘auth ?’ for more)zsuspend telnetenvironchange environment variables (‘environ ?’ for more)? print help informationtelnet>If you want to experiment with this command without an active Internet connection, youcan telnet to your own computer from a terminal window under X11 or through the console.As with the ftp command, first determine the hostname of your computer with thehostname command, and then either specify the hostname on the telnet command lineor run telnet and use its open command to start the session, for example:# hostnamepresario.localhost.localdomain# telnet presarioTrying 127.0.0.1...Connected to presario.localhost.localdomain.Escape character is ‘^]’.Caldera OpenLinux(TM)Version 1.3Copyright 1996-1998 Caldera Systems, Inc.login: bballPassword:You have old mail in /var/spool/mail/bballLast login: Mon Jan 25 15:28:01 1999 on tty2You have mail.#As you can see, after entering the username and password at the login prompt, you’represented with the shell prompt command line.13SummaryThis hour introduced you to downloading and browsing on the Internet. You learned howto use the ftp command to connect to a remote computer and download files. You alsolearned about several Internet browsers included with OpenLinux. Finally, you learnedabout Internet Relay Chat and the telnet command.


310 Hour 13Q&AQ I clicked a link to download a file while using Netscape, but all I got was abunch of garbage characters in a new window. What happened?A The version of Netscape included with OpenLinux is configured to recognize severalfile types automatically and act accordingly. However, if you click a link todownload an unrecognized file type, Netscape attempts to download the file into awindow. The safest approach to downloading a file is to first hold down the Shiftkey and then click the link to download a file. Netscape then shows a file save dialogbox, so that you can confirm the file save and start downloading.Q I started downloading a file with Netscape. Can I go back to browsing andstart downloading other files?A Yes. You can run multiple downloads at the same time.Q Are any other Web browsers included with OpenLinux?A Yes. You can try the amaya Web browser for X11. This browser, according to itsdevelopers, is “a work in progress.”Q If I’m downloading files with Netscape, is it safe to send or retrieve mail?A Yes, because you’re using a network connection. However, you might find thingsslowing down a bit (depending on the type of Internet connection you use.Q I tried irc, but there were some people using foul language and who werereally nasty!A Unfortunately, chat discussions are generally not moderated, so there’s no one incharge. In general, members of Linux chat groups tend to be a bit more civilized.Q I tried running Instant Messenger, but the program complained about notbeing able to find “Oscar.main”?A This is a conflict with an installed Java Development Kit, JDK. Use glint, lisa,or rpm to remove the JDK package, and then restart IM.Exercises1. Download and install the RealPlayer for Netscape, and then connect to an Internetsite with a live TV broadcast. Relax.2. Connect to the Internet, and then start the irc command. Join a chat group, andwatch the conversations.3. Try using ncftp to download a known file from an FTP site. How can this programbe useful?4. Try the Netscape (Mozilla) Easter egg. What else do you see besides a quotation?


PART IVUsing Linux ProductivelyHour14 Text Processing15 Preparing Documents16 Graphics Tools17 Learning Math and Financial Tools18 Personal Productivity Tools19 Home Office Management withStarOffice20 Relaxation and Playing Linux Games


HOUR 14Text ProcessingThis hour provides an overview of some word processing, or text editing,tools for OpenLinux. There are more than 100 text editors available forOpenLinux and more than one dozen on this book’s CD-ROM. This hourshows you some of the highlights and features of using these editing tools.You’ll find tips on installing and using some of the latest exciting softwarereleases for OpenLinux, such as Corel’s WordPerfect 8 and Star Division’sStarOffice suite. Read on to learn the basics of using these tools and to seehow to write and edit with OpenLinux.Word Processors in the LinuxEnvironmentText editors are used by many different people in different vocations. Casualusers, writers, programmers, and system administrators all use a text editorat one time or another in OpenLinux. You definitely need to know how tochange your system’s text configuration files to make OpenLinux work theway you want. What follows is an introduction to different word processors,text editors, and text tools you can use during your OpenLinux sessions.


314 Hour 14Although how you use a computer dictates what type of software is important and shouldbe installed, most people agree that more than half their time using a computer is spentusing a text editor or word processor. This will change, of course, as computer softwareinterfaces evolve and network communication becomes more integrated into our workenvironment, but in general, if you’re using OpenLinux on your computer at home,you’re probably going to be word processing or editing files a lot of the time.The tools in this hour are interactive programs that enable you to enter text, move a cursor,or drop a menu. These programs and related files vary in size from more than 150megabytes (such as the StarOffice suite) to fewer than 200,000 characters (such as thepico editor). Table 14.1 lists editors included with OpenLinux on this book’s CD-ROM.You can also find more than two dozen text tools, such as line editors such as the ed orex commands, that although not interactive, enable you to change, manipulate, orrearrange text.TABLE 14.1 TEXT EDITORS FOR OPENLINUXNameaXeCRiSPliteededyee, easyeditelvis, xelvisjed, xjedjoe, jmacs, jpico, jstarkeditnexnvipicoredsedStarWritertextedituemacsvimxeditDescriptionX11 text editorThe CRiSP programmer’s editorLine editorText editor (German)emacs in easy modeClone of the vi text editorProgrammer’s editor for console and X11The Joe’s Own Editor and variantsText editor included with the K DesktopEnvironment distributionBerkeley line editor cloneBerkeley vi editor cloneText editor (part of the pine electronic mail program’sdistribution)Read-only line editorStream editorStarOffice word processorText editor for X11MicroEMACs text editorVi IMproved, a programmers text editorText editor for X11


Text Processing 315Features of the XEmacs EnvironmentWhat do you call a text editor that edits text, reads Usenet news, acts as a personal calendarand diary, sends electronic mail, is a programming language interpreter, plays games,is a Linux shell, and more? Why, emacs, of course!Emacs, which stands for Editor Macros, was originally developed by Richard Stallman,the founder of the Free Software Foundation (FSF). The original emacs editor is distributedby the FSF as part of the GNU, or GNU’s Not UNIX, project. XEmacs is a versionof the original editor included with OpenLinux with improvements by companies such asSun Microsystems and Lucid, Inc. and programmers, such as Ben Wing. Although thereare some subtle differences (purist emacs users might insist that the only real version isfrom the FSF) between these versions, XEmacs is just as useful and capable as the FSF’sGNU version.Without a doubt, emacs is the most widely available and fully featured free editor andruns on more computer systems than any other text editor. There isn’t enough time in thishour (or this book!) to cover all the features of this program.Look at Table 14.2 to find most of the keyboard commands you can use to get started.TABLE 14.2BASIC EMACS COMMANDS AND KEYSTROKE COMBINATIONSC-b=hold down Ctrl key, press b M-v=Press Esc key, press vActionKey CombinationAbort current operationC-gCursor backwardC-bCursor downC-nCursor forwardC-fCursor upC-pDelete characterC-dDelete lineC-kDelete wordM-dGo to beginning of fileM-Go to end of lineC-eHelpC-hOpen fileC-x C-f14continues


316 Hour 14TABLE 14.2 CONTINUEDActionPage downPage upQuitSave AsSave fileTutorialUndoKey CombinationC-vM-vC-x C-cC-x C-wC-x C-sC-h tC-_ or C-x, uEmacs has 22 different command-line options but is easy to start. To run emacs and opena text file for editing, specify the file’s name on the command line, like this:# emacs myfile.txtThis loads the editor and opens your file. If you specify emacs on the command line byitself, the program starts, displays an opening screen, and then clears when you touch thekeyboard. Starting the emacs tutorial is highly recommended if you’re a beginner. Holddown the Control key and press the H key. You see a prompt on the emacs command lineat the bottom of screen. Type the T key, and then press Enter to start the tutorial.If you enter this command at the shell prompt of an X11 terminal window, the X11 versionof emacs, xemacs, with mouse and menu support, automatically starts (see Figure14.1). But what if you want to run the console, or non-X11 version, of emacs instead? Inthis case, use emacs with the -nw, or no-window, command-line option, like so:# emacs -nw myfile.txtThis command runs emacs inside your X11 terminal window without a menu bar. xemacsalso obeys most X11 Toolkit options, such as geometry settings. Some of the X11options you might find helpful include the following:●●●●●-geometry 80x24+400+200—start in a window 80 characters wide by 24 lines, atscreen position X (400) Y (200)-fg color—set foreground to color-bg color—set background to color-cr color—set text cursor to color-mc color—set mouse cursor to color


Text Processing 317The colors you can use for the color settings are listed in the file rgb.txtunder the /usr/X11R6/lib/X11 directory.Use these options, and others (such as X11 resource settings, discussed in Hour 7,“Using the X Window System”) to customize how emacs looks when started in X11:# emacs -geometry 80x24 -fg black -bg white blue -cr redThis starts xemacs in a window 80 characters wide and 24 lines high. The text is blackwith a white background. The cursor is red, and the mouse cursor is blue. Emacs also has43 different X resource settings you can configure and enter into your .Xresources filein your home directory. You also can save editor defaults (such as word wrapping, or fillmodeon) in a file called .emacs in your home directory.For example, you can automatically put xemacs into a text- and word-wrapmode, enable daily diary service, and put the current time in the modeline, a statusbar in the main window. Create the .emacs file with xemacs, like this:NEW TERM# xemacs .emacsNext, type in the commands to customize xemacs:(setq default-major-mode ‘text-mode)(setq text-mode-hook ‘turn-on-auto-fill)(require ‘appt)(display-time)(appt-initialize)Press Ctrl+X and Ctrl+S to save the file, and then press Ctrl+X and Ctrl+C to exitxemacs. The next time you start the editor, you see the time displayed in the modeline.The xemacs program for OpenLinux comes in 14 different packages containing variousfiles and utilities. If you install everything, emacs requires more than 60 megabytes ofdisk space. You can, however, save 45 megabtyes if you install the xemacs package,which contains the editor, documentation, and support routines.You can find documentation for xemacs under the /usr/info/xemacs directory. You alsocan read the xemacs manual page for an overview.Variants of the VIsual iMproved Editor —vimThe vim editor, by Bram Moolenaar, is a text editor that is compatible with the originalBerkeley Software Distribution vi editor by Bill Joy. An X11 version is called gvim andsports multiple scrolling windows and menus.14


318 Hour 14FIGURE 14.1MenubarTutorial ModeButton ToolbarThe XEmacs editorfeatures split windows,built-in help, a tutorial,and other tools tohelp you be more productive.Split WindowCurrent TimeCommand LineCurrent DayCalendarDisplayModeModelineScrollbarsAlthough the vim :version command shows that the systemwide vimrc andgvimrc resource files are located under the /usr/share/vim directory, this isnot true: these files aren’t installed with the vim package. However, you cancreate your own resource file after making changes to vim while runningthe editor and then using the :mkvimrc command. A resource file called.vimrc (which you can copy to .gvimrc) is created in your home directoryand contains your changes. You can then edit and add your own commands,configurations, and menus to these files.Several files and symbolic links to the vim editor are created on your system when youinstall the vim package from your CD-ROM:●●●●●●/usr/bin/vi -> /bin/vi/bin/vi -> /bin/vim/bin/view -> /bin/vim/usr/bin/view -> /bin/vim/bin/vim/usr/X11R6/bin/gvim


Text Processing 319The vim editor, shown in Figure 14.2, is used as a replacement for the ex, vi, and vieweditors and is a visual editor supporting features such as cursor movement.FIGURE 14.2The vim editor featuressplit windows andbuilt-in help.The vim editor features a number of improvements over the traditional vi editor, and has23 different command-line options. In vim you can find built-in help, split-screen windows,block moves, command-line editing, horizontal scrolling, and word wrapping forword processing.The gvim version of vim, used under the X Window System, has custom colors, windowsizes, scrollbars, and menus. You can create your own set of menus containing specificvim commands and generate different versions of vim by saving your features in differentgvim resource files. You can then use the -u command-line option to load a custom version.Creating new menus for gvim is easy. You can, for example, group related macros or customcommands you create in a separate menu. For details about building custom menus,read the files vim_menu.txt and vim_gui.txt under the /usr/share/vim directory.Most of the documentation for vim is contained in its built-in help, and 21 text files inthe /usr/share/vim directory contain extensive instructions.Features of Pine’s pico EditorThe pico editor, included with the University of Washington’s pine electronic mail program,is a compact, efficient, and easy-to-use editor usually used to compose or replyto email messages. This editor is a nifty replacement for all your editing needs and is14


320 Hour 14especially handy if you need a reliable text editor but don’t have a lot of hard drive space(for example, on a laptop).Despite its relatively small size, the pico editor has most of the features you expect in aword processor, including:●●●●●●●●word wrapbuilt-in helpword searchparagraph justificationtext block move, copy, and deletedirectory mode for file and text insertionmouse supportspell checkingThe pico editor, shown in Figure 14.3, has 16 different command-line options and rudimentarybut secure crash protection. In the untimely event of a power outage (just aboutthe only way to crash Linux) pico attempts to save any work in progress before exiting,saving your file with a name ending in .save or if unsaved, in a file named pico.save.FIGURE 14.3The pico editor, partof the pine electronicmail program distribution,is a compact andeasy-to-use editor withnearly all the basicfeatures of a texteditor.This editor is an excellent choice for your $EDITOR environment variable, as it is muchfriendlier and easier to learn than the default $EDITOR variable, which points to the vi(vim) command. To use pico as your editor, open the file .profile in your home directory,and then add this line:EDITOR=/usr/bin/pico; export EDITORAs the root operator, set the $EDITOR variable for all users by editing the /etc/profilefile, and insert the same line.


Text Processing 321In both cases, save the file, and then use the following to use the new $EDITOR variable:# source /etc/profileAfter you do this, any Linux command requiring a default system editor uses pico.You can find documentation for pico in its manual page, or you can use the lynx Webbrowser to read the pine and pico technical documentation with the following:# lynx /usr/doc/pine-4.02/tech-notes/index.htmlFive Editors in One—joeThe joe editor, by Joseph H. Allen, comes in five different versions: jmacs, joe, jpico,jstar, and rjoe. The jmacs version emulates the emacs editor. The jpico version emulatesthe pine mailer’s pico text editor. The jstar version uses WordStar-compatiblekeyboard commands, whereas the rjoe program is a restricted editor.For those of you who don’t know about WordStar: this program was one ofthe first full-screen text editors with a spelling checker, originally developedand marketed for the CP/M operating system. In the early 1980s, WordStarwas the most popular word processor for the DOS operating system, and itslegacy is the Ctrl key “diamond.” This meant that the user pressed the Ctrlkey with the left pinky finger, and tapped the WER, ASDF, or XC keys to movewithin a document.The joe configuration files (for each text mode) are found under the /usr/lib/joe directory.To create your own custom configuration, copy the file called joerc to your homedirectory, save it with the .joerc filename, and then edit this file to change the joe helpmenus, display, and keyboard commands.You can find documentation for the joe editor, shown in Figure 14.4, in its manual page(which needs to be spell checked) and by using its built-in help (Ctrl+X, K).Configuring the jed EditorThe jed editor (shown in Figure 14.5), by John E. Davis, comes in two versions: one forthe console (jed) and the other tailored for the X Window System (xjed). This editor canalso emulate other editors, such as WordStar or Brief, using those programs’ keyboardcommands.14


322 Hour 14FIGURE 14.4The joe editor comesin five versions andcan emulate the keyboardcommands ofseveral different editors,such as pico andemacs.The jed main configuration files can be found under the /usr/lib/jed/lib directory,and you can customize how jed runs by placing preferences in a .jedrc file in yourhome directory. Copy the file jed.rc from the /usr/lib/jed/lib directory to yourhome directory as .jedrc, and then edit to your taste.FIGURE 14.5The jed editor hasbuilt-in help and textmenus you can use asa shortcut to keyboardcommands.The jed editor has built-in help, but you can find information about jed under the/usr/doc/jed directory, in its manual page, and in info files under the/usr/lib/jed/info directory.Using the kedit Editor ClientThe kedit editor (shown in Figure 14.6) is included with the K Desktop Environmentand has numerous features, including the following:●●A menu bar supporting file, editing, options and helpA toolbar containing buttons for the following:


Text Processing 323●●●●●●●●●●●●●●Creating a new documentEmailHelpPerforming copy, paste, and cut operationsPrintingOpening a fileSaving the current fileCustom colors and fontsInsertion of the current date and timeRetrieval of Internet documents via FTPSearch and replaceSending of documents by electronic mailText file insertionWord wrapFIGURE 14.6The kedit editorhas many differentfeatures, such assearch-and-replace,help, custom colors,and retrieval of textdocuments via theInternet.You can test kedit’s remote file retrieval by creating a file called welcome.msg withsome sample text. Copy this file to the /home/ftp directory (as the root operator). Next,start kedit by clicking the Application Starter button on your desktop’s panel, thenselecting the Applications menu, and clicking the editor menu item. When the keditwindow appears, select the File menu, and then click the Open URL... menu item. Aretrieval dialog box appears (as shown in Figure 14.6). Click the OK button and the textof the welcome.msg file is inserted into kedit’s editing window.To learn how to navigate the Internet and download files using the ftpcommand, see Hour 13, “Internet Downloading and Browsing.”14


324 Hour 14Using the CRiSPlite EditorThe CRiSPlite editor, included with OpenLinux, is a programmer’s editor used mainly tocreate and edit source code for programming. This editor (an extremely limited versionof the commercial editor) sports a graphical interface under the X Window system andfeatures buttons and menus you can use while you work.Start CRiSPlite by clicking the editor’s icon on your desktop’s panel if you’re using theK Desktop Environment. You can also find an icon in the initial Looking Glass desktopafter you start an X session with the fvwm2 window manager. Start the editor from thecommand line of a terminal window with the mcr command, like this:# mcrThe editor appears with its window, as shown in the Figure 14.7.FIGURE 14.7The CRiSPlite editorfor OpenLinux ismainly a programmingeditor.You can also use this editor from the command line of your console with the cr command,like this:# crgPress Enter to launch CRiSPlite without the X Window System.StarOffice’s StarWriterThe StarWriter component of the StarOffice suite of productivity programs (shown inFigure 14.8) for OpenLinux is a professional and capable word processor. This program(used, in part, to write this book) is installed along with StarOffice from this book’s CD-ROM. This editor supports nearly all the features found in more expensive word processorsfor other operating systems.


Text Processing 325FIGURE 14.8The StarWriter componentof the StarOfficesuite of tools forOpenLinux is a professionalword processor.To install StarOffice 4.0, insert your OpenLinux CD-ROM, and then mount the CD-ROM like so:# su -c “mount /mnt/cdrom”Navigate to the StarOffice installation directory on the CD-ROM, like so:# cd /mnt/cdrom/Star*/english/prod_lnxAt the command line, use the StarOffice setup command to start the installation, likethis:# setupPress Enter to start the installation.If you receive the newer StarOffice 5.0 suite, first browse tohttp://www.stardivision.com to obtain a customer number and registrationkey. You need to enter your customer name, customer number, and registrationkey exactly as shown on the StarDivision registration page in orderto install and enable StarOffice 5.0. See Hour 19, “Home OfficeManagement with StarOffice,” for more details about installing and usingStarOffice.14


326 Hour 14StarOffice installs in an OfficeXX directory in your home directory, where XX representsthe version of StarOffice installed (40 for 4.0 or 50 for 5.0). Start StarOffice by typingthe following:# Office50/bin/soffice &To create a new StarWriter document, click the StarOffice Start menu (at the bottom leftof the StarOffice desktop). StarWriter appears, as shown in Figure 14.8).Corel’s WordPerfect for LinuxOpenLinux is a great Linux distribution to use, and now there’s an even better reason touse Linux: In December 1998, Corel, Inc. released the WordPerfect version 8 wordprocessor for free for personal use with the Linux operating system. WordPerfect, one ofthe most mature and capable word processors on the market today (for any operating system)can be downloaded, installed, and used for free.You should definitely register your copy of WordPerfect, even if you onlyuse it occasionally. Corel, Inc. needs to have an accurate idea of the potentialof the Linux software market, and your registration helps encouragedevelopment of new commercial software for Linux. Corel, Inc. is to beapplauded for making this software available at little cost to the casualLinux user.To get your copy, browse to http://www.linux.corel.com/linux8/index.htm. Followthe links, read the installation instructions, and then download and install the file GUILG00(nearly 24 megabytes in size). You can then start WordPerfect by typing the completepath to the executable file (using the installation directory specified during yourWordPerfect installation), like so:# /opt/wp/wpbin/xwp &The WordPerfect splash screen appears, along with a control dialog box and the blankWordPerfect document window, as shown in Figure 14.9.


Text Processing 327FIGURE 14.9The distribution of theWordPerfect 8 wordprocessing system forOpenLinux representsCorel, Inc.’s concertedinvestment and confidencein the worldwideLinux user community.Applix WordsThere are many other Linux word processing programs besides the text editors installedon your system. These programs are in the public domain, distributed as shareware, orsold commercially. One word processor, Applix Words by Applix, Inc., has many differentfeatures:●●●●●●●●●It is an integrated part of the Applixware suite of office tools, including a spreadsheet,graphics, mail, and presentation program and supporting frames, linkedobjects, and pasted graphics.It provides a WYSIWYG view of your documents and comes with two dozenfonts.It imports and exports 20 different word processing file formats.It supports extensive editing macros.It includes a spelling dictionary and thesaurus.It includes extensive built-in and context-sensitive help.It creates and edits hypertext markup language, or HTML documents.It can be completely customized with new menus or keyboard commands.It builds indexes, tables, tables of contents, and glossaries.14


328 Hour 14Applix Words requires the X Window System. The Applixware suite needs about 135megabytes of your hard drive space and 16 megabytes of your computer’s memory to runcomfortably. After installing Applix Words from the Applixware CD-ROM, run it withthe following:# applix -wpThe latest version of Applixware (4.4.1 at the time of this writing) has aninstallation and execution problem related to OpenLinux 1.3. This probleminvolves Caldera’s use of older versions of shared software libraries.Fortunately, you can install Applixware and then configure its libraries towork with OpenLinux 1.3. First, log in as the root operator, and then navigateto the /opt/applix/jre115/lib/i386/green_threads directory. Use themv command to rename the library file libdl.so.1 to libdl.so.1.dontuse.Next, open your .bashrc file in your home directory, and enter this newenvironment variable definition: export LD_PRELOAD=/lib/libdl.so.1. Logout and log back in to OpenLinux to use the new definition. You can nowuse Applixware!This command line starts the word processor component as shown in Figure 14.10.Applix Words also has a tutorial, like emacs. To start learning, select the Help menu, andthen pull down the Tutorial menu item. (You also can hold down the Alt key, and thenpress H, followed by the T key.)FIGURE 14.10The Applix Words programis a WYSIWYGword processor includinga customizableinterface and professionalediting tools forwriters.


Text Processing 329Find out more about Applix Words and the Applixware productivity suite for Linux bybrowsing to the following site:http://www.applix.com.Changing Text with sed and Other FiltersUntil now, this hour has discussed interactive editors featuring cursor movement, menus,or other keyboard commands. There are several other programs, such as text filters, orstream editors, included with your system that can edit text.If you read the discussion in Hour 6, “Using the Shell,” you’ll recall that many Linuxprograms can use your shell’s standard input and standard output. By using shell operators,such as pipes or redirection operators, you can use Linux commands to filter textthrough pipelines to manipulate or change the text stream. There also are several otherprograms, such as ex and sed, that are specifically designed to edit filtered text and arecalled stream editors.Thanks to the FSF folks, the GNU text-utils package of two dozen text utilities is alsoinstalled on your system. This collection includes cat, cksum, comm, csplit, cut, expand,fmt, fold, head, join, md5sum, nl, od, paste, pr, sort, split, sum, tac, tail, tr, unexpand,uniq, and wc.Some of these formatting commands, such as fmt and pr, are discussed in the next hour,“Preparing Documents,” but this section shows you how you can use several others tomanipulate text. For example, the tr, or transliterate, command can be used to work onstreams of text to translate, squeeze, or delete characters.The tr command works by taking sets, or lists of characters on the command line, andusing them to translate input text. If you have a document containing uppercase and lowercasebut want to change the text to all uppercase, you can tell the tr command to dothis by specifying the two sets of characters. A public domain software license (found inthe /usr/doc/shadow-misc directory) is used in the following example:# cat LICENSE...1. You may make and give away verbatim copies of the source form of theStandard Version of this Package without restriction, provided that youduplicate all of the original copyright notices and associateddisclaimers.2. You may apply bug fixes, portability fixes and other modificationsderived from the Public Domain or from the Copyright Holder. A Packagemodified in such a way shall still be considered the Standard Version....14


330 Hour 14You can change this document to all uppercase with the following:# cat LICENSE | tr a-z A-Z...1. YOU MAY MAKE AND GIVE AWAY VERBATIM COPIES OF THE SOURCE FORM OF THESTANDARD VERSION OF THIS PACKAGE WITHOUT RESTRICTION, PROVIDED THAT YOUDUPLICATE ALL OF THE ORIGINAL COPYRIGHT NOTICES AND ASSOCIATEDDISCLAIMERS.2. YOU MAY APPLY BUG FIXES, PORTABILITY FIXES AND OTHER MODIFICATIONSDERIVED FROM THE PUBLIC DOMAIN OR FROM THE COPYRIGHT HOLDER. A PACKAGEMODIFIED IN SUCH A WAY SHALL STILL BE CONSIDERED THE STANDARD VERSION....The document has been piped, using the cat command, through the tr command, specifyingthat you want the set of lowercase letters, from a to z, to be translated to uppercase,or A to Z. The tr command can also be used to translate individual characters. Forexample, notice that two spaces are used following each number and a period in the sampletext. You can replace multiple occurrences of characters with a single character byusing the -s, or squeeze, command-line option:# cat LICENSE | tr -s “ “...1. You may make and give away verbatim copies of the source form of theStandard Version of this Package without restriction, provided that youduplicate all of the original copyright notices and associateddisclaimers....As you can see, the two spaces have been replaced with a single space. The tr commandalso filters input to other commands, such as cut, to quickly generate custom reports. Forexample, if you don’t need all the information from the ls command’s -l, or long, formatlisting and only want certain columns of the output, you can get any column youwant by filtering the listing through several pipes:# ls -l...-rw-r--r-- 1 root root 1898 Jan 29 1998 ANNOUNCE-rw-r--r-- 1 root root 28796 Jul 23 18:13 CHANGES-rw-r--r-- 1 root root 68500 Mar 16 1997 HOWTO-rw-r--r-- 1 root root 5040 May 1 1997 LICENSE-rw-r--r-- 1 root root 850 Dec 14 1997 LSM-rw-r--r-- 1 root root 11535 May 1 1997 README...This is a lot of information, but if you only want the permissions, size, and name of eachfile, you can quickly generate a custom listing with the following:


Text Processing 331# ls -l | tr -s “ “ | cut -d” “ -f1,8,9...-rw-r--r-- 1998 ANNOUNCE-rw-r--r-- 18:13 CHANGES-rw-r--r-- 1997 HOWTO-rw-r--r-- 1997 LICENSE-rw-r--r-- 1997 LSM-rw-r--r-- 1997 README...The listing now only shows the first, eighth, and ninth columns of the original listingbecause the tr command squeezed multiple spaces into a single space. The output ispiped through the cut command, specifying a field delimiter using the -d option (in thiscase, a space). Notice that although the first and second columns look okay, the third is alittle ragged. If this still isn’t what you want, cut different fields or clean it up by againusing the tr command to replace the space delimiter with a tab:# ls -l | tr -s “ “ | cut -d” “ -f1,5,9 | tr “ “ ‘\t’...-rw-r--r-- 1898 ANNOUNCE-rw-r--r-- 28796 CHANGES-rw-r--r-- 68500 HOWTO-rw-r--r-- 5040 LICENSE-rw-r--r-- 850 LSM-rw-r--r-- 11535 README...The listing now shows the permissions, file size, and name of each file. You can usethese filters to change text in your documents, but stream editors, such as the sed command,offer more capable approaches to editing text from the command line. For example,the sample license document uses the phrase this Package to describe a softwarepackage. If you are the software developer of a new game, Nano-Warrior, and need tosave time writing copyright licenses, you can change all occurrences of this Package toNano-Warrior easily and quickly without using a text editor:# cat LICENSE | sed ‘s/this Package/Nano-Warrior(TM)/g’...1. You may make and give away verbatim copies of the source form of theStandard Version of Nano-Warrior(TM) without restriction, provided thatyou duplicate all of the original copyright notices and associateddisclaimers....The sed s, or substitute, command is used to search for all instances of the first stringand replaces each instance with the second because of the g, or global, command. Theoriginal text file is not changed, and you can save a new version by redirecting the output.14


332 Hour 14The sed command also is designed to work using editing scripts. To make numerous,regular changes to files, create an editing script, and use your script to edit files. Use thesed command’s -f, or script file, command-line option to use the script:# sed -f myscipt.sed < form.ltr >output.ltrThere are too many text filters included with your OpenLinux distribution todiscuss in this hour; see the manual pages for the filter commands listednear the beginning of this section. You also might want to experiment withthe wc, or word count, program, which reports the number of characters,words, and lines in your text documents.Spell Checking Your DocumentsMisspelled words in your documents can be embarrassing, especially if other people readyour text. Correct spelling is an important part of writing and word processing. Just aserrors in syntax can cause programming errors, spelling errors can cause problems inmiscommunication, loss of a potential job or customer, or the respect of a supervisor.Fortunately, your Linux distribution comes with the ispell spelling checker, so youdon’t have to suffer the embarrassment of misspelling! This section shows you how tocorrect documents and fix your spelling errors.Correcting Documents with the ispell CommandThe ispell command, found under the /usr/bin directory, is an interactive spellingprogram you can use alone or with your text editor to correct spelling mistakes. Severaleditors included with your Linux distribution, such as emacs and pico, are set up to automaticallyuse this program for spell checking, but using ispell by itself is easy. Forexample, to check the spelling of the file myfile.txt, use the following:# ispell myfile.txtThe ispell program loads the text and then displays the first found error in context,along with a single or several suggested replacements, as in this example:MERCHANTIBILITYFile: LICENSEWARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OFMERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.0: MERCHANTABILITY[SP] R)epl A)ccept I)nsert L)ookup U)ncap Q)uit e(X)it or ?➥for help


Text Processing 333Correct the spelling by either typing 0, the number of the suggested replacement word, orR, which you can use to replace the word by retyping it.Look up other words with L, the lookup command, which searches the system dictionary,called words, located under the /usr/dict directory. If you use I, or the insert command,ispell creates a personal dictionary in your home directory, using .ispell_english as a filename.You also can specify multiple documents on the ispell command line:# ispell *.txtThis command line causes ispell to load each file ending in .txt for spell checking. Ifyou prefer to use ispell as the more traditional UNIX spell command, which reads adocument and then prints out a list of suspected words, use the -l, or list, option on thecommand line:# ispell -l < LICENSE...JulianneHaughuunetuuMERCHANTIBILITY...Note that the < redirection operator is used because in the -l mode, the ispell commandacts as a spelling filter, checking the input text stream against its dictionary (locatedunder the /usr/lib/ispell directory). You can redirect this list to a file or use the -fcommand-line option:# ispell -l -f errors -a


334 Hour 14Single Word Lookup and Other TricksWhen all you need is quick confirmation of the spelling of a single word, you don’t haveto run your word processor or text editor to get the answer because you can use the lookcommand, found under the /usr/bin directory.Although the look command is normally used to search files and print all lines matchinga given string pattern, the look command quickly looks up a word in the system dictionary.If you don’t specify a file to search on the look command line, look automaticallysearches the system dictionary, called words, which is located in the /usr/dict directory.See the following example:# look consciconscienceconsciencesconscientiousconscientiouslyconsciousconsciouslyconsciousnessThe system dictionary, words, is a symbolic link to the file called linux.words,also located in the /usr/dict directory. This dictionary, a 400,000 character,plain ASCII list of sorted words, contains 45,402 words. You can find an evenlarger dictionary, called web2, which is more than two megabtyes and containsmore than 234,000 words, by searching your favorite Linux Internetsites or browsing to ftp://ftp.digital.com/pub/BSD/net2/share/dict.All you have to do is type several characters of the beginning of a word, and the lookcommand prints any matches found in the system dictionary. You also can use the ispellcommand’s -a command-line option to check spelling interactively or quickly look up asingle word or several words at the keyboard. Lookups are performed on the ispell dictionary,not the system dictionary. See the following example:# ispell -a@(#) International Ispell Version 3.1.20 10/10/95seperate& seperate 1 0: separatemispell& mispell 2 0: ispell, misspell


Text Processing 335mississippi& mississippi 1 0: Mississippitruncate*[Ctrl-d]#Notice that ispell starts, prints a short version message, and then waits for your input.When you enter a misspelled word, ispell echoes the word back and if a suggestedreplacement is found, prints the replacement with a number. Also note that ispell evencorrects words spelled correctly but not properly capitalized. Finally, if you enter a correctword, ispell merely echoes back an asterisk. To quit, enter an end of text characterby pressing Ctrl+D.SummaryThis hour introduced you to a number of word processors, editors, and text utilities forOpenLinux. You now also know how to spellcheck text documents using the ispellcommand and how to quickly look up words from the command line.Q&AQ I found that I made a lot of incorrect changes to a document when usingxemacs. I know about the undo command, but is there are faster way to quicklyfix things?A The good news is the xemacs creates a backup file of your document. However,you can revert back to the original form of the document with the revert-buffercommand. Press the Esc key, and then type the X key. At the command prompt (atthe lower left of the xemacs window), type revert-buffer, and press Enter.Q Help! I can’t get printing to work with WordPerfect!A Don’t panic. See Hour 15, “Preparing Documents,” for step-by-step directions onhow to print with WordPerfect.Q I entered a misspelled word into my personal dictionary when using ispell.How can I fix this?A The personal dictionary is a simple text file. Open the file with your favorite texteditor and remove or correct the word.14


336 Hour 14Q I accepted an incorrect word when using ispell, and the file has been writtento disk! How can I fix this?A Fortunately, ispell saves a copy of your original document with the extension.bak appended. Use the mv command to replace the incorrect file or to rename thebackup file.Q StarOffice 5.0 won’t let me install or finish its installation after I enter myname, customer number, and personal key!A Make sure you enter your name, customer ID and registration number exactly asentered when you registered StarOffice. You can later change your personal informationthrough the Configuration menu.Q I want words to wrap around in the kedit editing window. How do I do this?A Select the Options menu, and then click the kedit Options menu item. Next, clickthe Set Fill-Column At button, and type in the number of characters you want touse for a line width.Q How do I print with the CRiSPlite editor?A Open the Setup Options dialog box and select Printer. In the Print to file field, type| lpr, and then click the Apply button.Exercises1. Experiment with the Search and Replace dialog box in the kedit editor. If you’renot the root operator, try opening a text file under the /usr/doc directory and thensaving the file with a different name. Why can’t this be done?2. Create a blank StarWriter document, and then in a separate terminal window, highlightthe output of a program, such as ls. How should you paste the highlightedtext in the StarWriter document? (Hint: You can’t use the middle mouse button!)3. Try using cut and paste operations in the pico editor to move different paragraphsinside a document. How do you move blocks of text with pico?


HOUR 15Preparing DocumentsHour 14, “Text Processing,” discussed text editing tools and programs usedto create, edit, and save documents. This hour introduces you to programsand utilities used to format and print your text documents. It starts off with adiscussion of different text formatting programs and shows you how to easilyformat your documents for printing without using complicated formattingcommands. It then shows you how to use more complex programs usingsimple command lines.The hour concludes with a discussion of the basics of document printingunder OpenLinux, as well as detailed information about how to configureyour printer to get the best possible output.Formatting TextAlthough you can do basic formatting of text documents using a text editor,most of these basic editing programs for OpenLinux lack the necessary featuresto add page numbering, boldfacing, font changes, indenting, or otherfancy text layout.


338 Hour 15The programs discussed in this hour are used to prepare, format, convert,and print text documents. To create professionally typeset documents with aword processor, try StarOffice’s StarWriter or Corel’s WordPerfect 8 forLinux. See Hour 14 to learn more about these programs.Producing nicely typeset documents using the text utility programs included withOpenLinux is usually a three step process. First, you create the document using a texteditor and intersperse your text with typesetting commands to create certain effects whenyou filter your document through a formatting program. The second step is to processyour document through a typesetting program and produce formatted output. The thirdstep is to either check your formatting by previewing the document or if you’re confidentabout your formatting, to print the document.This section shows you how to use formatting programs to produce nicely organizeddocuments. It also discusses the basic syntax, or commands, that these programs recognize.Formatting Text Using Text FiltersIn Hour 14, you were introduced to some text filters that change the output of differentprograms or the contents of a document. The text filters discussed here can help youquickly format your documents if you don’t want to learn a complex formatting programor use complicated typesetting commands. You can find these programs useful to quicklybuild formatted documents with headers, footers, margins, and page numbers.Sending directory listings or short text files directly to your printer without formattingmight be okay, but printing larger text files usually requires better formatting. One commandyou can use is the pr command, found under the /usr/bin directory. The pr commandhas 19 different command-line options to format documents, as shown in Table15.1.TABLE 15.1 COMMON pr COMMAND-LINE OPTIONSOptionAction+x Begin printing at page x-a Print columns across the page-b Balance columns (on last page)-c Use ˆc notation to make control characters visible-d Use double spacing


Preparing Documents 339-e[x[y]]-f, -FConvert tabs (or x) to spaces, use y tab characterwidthOutput form feed between pages-h str Use str as page header instead of filename-i[x[y]]-l xx Page length set to xxConvert spaces (or x) to tabs, use y spaces in tabs-m Print multiple files in parallel columns on page-n[x][y]]-o x Set left margin to xUse line numbers (with a following character x), andy digits for the numbers-r Turn off warning messages-s[x]Use character x to separate columns-t Turn off default headers and footers-v Show unprintable characters in base 8 (octal) notation-w xx Set page width to xx characters-x Format page into x columns15Look at the following example:# pr +4 -h “Draft Number 1” -o 8 output.txtThis command line formats the file pilotprimer.txt, starting at page 4, with a headercontaining the date, time, page number, and the words Draft Number 1; the left marginis 8 spaces. Using the > redirection operator, the formatted output is then saved to a filecalled output.txt, which you can print at a later time.Pipe the output through the less pager to preview your formatting beforeprinting.The pr program also formats selected streams of text. One handy use is to create formattedcolumns. For example, if you have a paragraph, you can quickly create columns oftext by combining several filter programs and then formatting the text with the -COLUMNcommand-line option (a hyphen, followed by the number of columns; -3 in the followingexample):


340 Hour 15# cat cities.txtCincinnati, San Francisco, Philadelphia, Chicago, Miami, Norfolk,Savannah, Seattle, Pittsburgh, St. Louis, Phoenix, Nashville, Las Vegas,Atlantic City, Raleigh# cat cities.txt | sed ‘s/, /#/g’ | tr ‘#’ ‘\n’ | sort | pr -l 1 -3Atlantic City Chicago CincinnatiLas Vegas, Miami NashvilleNorfolk, Philadelphia PhoenixPittsburgh Raleigh San FranciscoSavannah Seattle St. LouisThe preceding example uses a list of cities separated by commas. By using several filters,including the pr command, the text is formatted as a readable list, sorted alphabetically.The command line works by first using the sed stream editor (discussed in Hour 14) tochange each comma and space to a pound (#) sign. The pound sign is translated to a carriagereturn by the tr command (also discussed in Hour 14). The text, now a list ofwords, one per line, is fed into the sort command. The sorted text is fed into the prcommand to produce three columns of text (the -l (or page length) option, with a valueof 1, is used to inhibit the page header).You also can use the fmt command with the pr command to change the word wrap, orwidth, of your text documents. The following example is part of a public-domain softwarelicense (found under the /usr/doc/shadow-misc directory):# cat LICENSE...1. You may make and give away verbatim copies of the source form of theStandard Version of this Package without restriction, provided that youduplicate all of the original copyright notices and associateddisclaimers.2. You may apply bug fixes, portability fixes and other modificationsderived from the Public Domain or from the Copyright Holder. A Packagemodified in such a way shall still be considered the Standard Version....Although this text might be okay when printed on the screen or by using the default settingswith the pr command, the text overruns lines if you use a left margin of 10 spaces.Look at the following example:# pr -o 10


Preparing Documents 341cationsPackageersion....2. You may apply bug fixes, portability fixes and other modifiderived from the Public Domain or from the Copyright Holder. Amodified in such a way shall still be considered the Standard V15The preceding example certainly doesn’t look nice when printed! To fix this, use the fmtcommand to format the text with a smaller line width before formatting with the pr command:# cat LICENSE | fmt -w 60 | pr -o 10...1. You may make and give away verbatim copies of thesource form of the Standard Version of this Packagewithout restriction, provided that you duplicate all ofthe original copyright notices and associated disclaimers....2. You may apply bug fixes, portability fixes and othermodifications derived from the Public Domain or from theCopyright Holder. A Package modified in such a way shallstill be considered the Standard Version.As you can see, the text now fits nicely on your page when printed. You can also createmore sophisticated effects by combining the output of fmt with the multiple-columnoption of the pr command. For example, to format the previous example document,pilotprimer.txt, use the fmt command to reformat the text into a thin column of 26characters, and then send the text through the pr command to format the text into multiplecolumns, like this:# fmt -26


342 Hour 15Not all the output is shown, but as you can see, the fmt command is used to convert thetext stream into a 26-character wide column. This output is then fed to pr, which formatsthe text in two columns. The -s option is followed by a backslash (\) and a vertical bar(|) to specify the vertical bar as a column separator. The -o option sets the left margin totwo spaces, and the -t option turns off headers and footers. The -w 60 option sets apage width of 60 characters, which is certainly suitable for most printers.But what if you want to save paper and see at least two pages of output on a single page?In this case, use the mpage, or multiple page, command to print several sheets of paper ona single page. Look at the following example:# mpage -2 myfile.txt >myfile.psThis command line uses the mpage command, found under the /usr/bin directory, tocreate a PostScript file you can later print that contains the contents of the myfile.txtdocument as two side-by-side pages on each sheet of paper. To preview the PostScriptfile during an X11 session, use the gv previewer, like this:# gv myfile.psYou can use the mpage command’s -O, -E, or -R options to print full-duplex(back-to-back) documents. This can be handy for producing small bookletsusing letter-size paper with a printer that’s not capable of printing on bothsides of each sheet. You also can set different margins, fonts, and the orderof printed pages. See the mpage manual page for details.Using the fmt, pr, or mpage commands, along with other text filters, you can performquick and dirty rudimentary text formatting. If you want to try more complex formatting,use a text formatting program.Formatting Text with the groff FormatterIf you’ve used OpenLinux for the past several hours and have read some manual pages,you’re probably familiar with at least one complex formatting program: groff. Whenyou read a manual page with# man lsit is equivalent to the following:# nroff -man /usr/man/man1/ls.1 | less


Preparing Documents 343Notice that the nroff command is used on the command line instead of groff.This is because the nroff command installed on your system is a shell script,written to use the GNU groff formatting program to emulate the nroff command. AllOpenLinux man pages are written using a special set of nroff commands called manmacros. You can use the groff command to use man macros to format your own manualpages. For example, if you create a manual page for a new game called nw, the manualpage, called nw.6, might look like the following:NEW TERM15.TH Nano-Warrior 6 Games 1/1/98 Linux.SH NAMEnw - play Nano-Warrior.SH SYNOPSISnw.B -d.PP-d = play deathmatch mode.SH DESCRIPTION.PPThe nw command is used to play a game of Nano-Warrior on your Linuxconsole. Play continues until you are wiped out by hordes of alieninvaders swarming down the screen..PPDon’t give up the fight!.SH FILES/usr/games/nw.PP$HOME/.nw_scores.SH BUGSProbably too many.You can process this manual page and send it to your display with the following:# groff -Tascii -man nw.6Nano-Warrior(6) Linux Nano-Warrior(6)NAMEnw - play Nano-WarriorSYNOPSISnw -d-d = play deathmatch modeDESCRIPTIONThe nw command is used to play a game of Nano-Warrior onyour Linux console. Play continues until you are wiped outby hordes of alien invaders swarming down the screen.Don’t give up the fight!


344 Hour 15FILES/usr/games/nw$HOME/.nw_scoresBUGSProbably too many.Notice that the man page macros boldface the sections and format the following textautomatically. A list of these and other manual page macros are found in the man.7 manualpage under the /usr/man/man7 directory. You can read this manual page with the following:# man 7 manThe groff formatting program also comes with other sets of typesetting macros, such asthe me, mm, or ms manuscript macros used to format text files. You generally need to specifythe macro set on the groff command line if you use these commands:# groff -Tascii -mm myfile.txtDocumentation for several of these macros is on various manual pages related to groff.One of the best documented sets included with your OpenLinux distribution is the collectionof mm manuscript macros on the groff_mm manual page. Table 15.2 lists somecommon macros you can use to produce formatted documents.TABLE 15.2 COMMON groff mm MACROSActionMacro NameCenter justify.ds CEnd text box .b2Justification off .sa 0Justification on .sa 1Line fill off.ds NLine fill on.ds FNew paragraph with x indent.p xNo indents.ds LRight justify.ds RStart bold text .bStart text box .b1Use columns.mcUse one column .1cUse two columns .2c


Preparing Documents 345Some of the more common commands that don’t require a macro set are listed in Table15.3. Experiment with them to see their effect on your documents before printing.15TABLE 15.3 COMMON groff TYPESETTING COMMANDSActionCommand NameBegin new page.bpBegin new paragraph.ppCenter next x lines.ce xCenter text x.ce xInsert (space) x inches down.sp xiInsert x inches down.sv xiSet font bold.ft BSet font roman.ft RSet line spacing to x.ls xTemporary indent x inches.ti xiTurn off line fill.nfTurn on centering.ceTurn on indenting x inches.in xiTurn on line fill.fiUnderline next x lines.ul xWhen you’re ready to produce a formatted document, use the groff command’s -T command-lineoption to produce a document in several different document formats. Thegroff formatter produces PostScript, TeX dvi (discussed next), text, HP printer-controllanguage, or PCL formats. Look at the following example:# groff -Tascii -mm myfile.txt >myfile.txt# groff -Tps -mm myfile.txt >myfile.ps# groff -Tdvi -mm myfile.txt >myfile.dviYou can preview these documents before printing by using several different programs,such as gv for PostScript (.ps) or xdvi for dvi files (.dvi).The gv program is discussed in Hour 16, “Graphics Tools.”


346 Hour 15Formatting Text with TeXThe TeX typesetting system, originally by Donald E. Knuth, is a collection of programsand other utilities used to produce professionally formatted documents. It is a much moresophisticated system than the groff distribution and includes more than 65 programs,along with such related support files as libraries, macros, fonts, and documentation.If you install TeX on your system with the lisa or rpm commands, you need at least 30megabytes for the main distribution, 10 megabytes for a series of related macros calledLaTeX, and eight megabytes for 50 different fonts. Obviously, describing the entire systemand how to use each different program in the TeX system is beyond this hour. Butthis section shows you how to get started with a sample document.Previewing TeX dvi documents requires a preprocessing step that can takeseveral minutes before the pages are even displayed. Files must first beprocessed by the MakeTeXPK program, and related processes can eat up yoursystem resources. A much better approach is to convert the file to PostScriptwith the dvips command, found under the /usr/bin directory with the following:dvips -f < texdoc.dvi >tex.psNow use the gv program with gv tex.ps to read the file.You can find documentation for TeX in a variety of places. You can read the manualpages for related files, check the /usr/info directory for TeX information files, andbrowse to the /usr/TeX/texmf/doc directory. There are 10 different directories of documentationfiles, but the easiest way to read about your TeX distribution is to use the lynxWeb browser with the following:# lynx ls /usr/TeX/texmf/doc/index.htmlThe TeX distribution files are displayed in an organized list that you can browse throughto download sample files and guides directly to your home directory. Beginning usersshould definitely read the TeX Frequently Asked Questions (FAQ) document.Like the groff program, TeX uses formatting commands inserted in your text files tomanipulate how your file looks when printed. You create your file, insert appropriatecommands or macros to format text, and then process your document through TeX to createan output file, usually in dvi format, that you can preview or print.To see a sample of TeX using the LaTeX macros, try processing a sample file in the TeXdirectories:


Preparing Documents 347# latex /usr/TeX/texmf/doc/generic/pstricks/samples.texThis creates a file called samples.dvi. First, convert the file to PostScript with the dvipscommand, like this:15# dvips -f samples.psYou see quite a bit of output from this command. When the command finishes, use thegv client to preview the sample.ps document, like so:# gv samples.psYou can use TeX to produce complex diagrams and text, but you have to make the effortto learn TeX first!There are many different macros and macro sets included with the TeX formattingsystem. Covering the details of complex formatting is beyond thescope of this book, but you’re encouraged to experiment, starting with simplecommands, to get a feel for typesetting documents. There are nearly 100books about using TeX on the market. If you’re serious about learning howto use TeX, a good book is indispensable.Printing Text DocumentsAfter you finish formatting your text files, using either a series of filters or inserted typesettingcommands, you can print your file to produce a typeset hard copy. To control the printingof your documents, you need to understand how OpenLinux handles printing and howto start, stop, cancel, and control the printing process.There are several printing commands you can use to control the printing process on yoursystem. This section first shows you how your printer is described under OpenLinux andwhere the important printer files are located. Because most OpenLinux users at home have aparallel printer attached to their computers, this hour’s discussion is limited to parallel printers.Printers are known as character mode devices and are listed under the /dev directory. Lookat the following example:# ls /dev/lp*/dev/lp0 /dev/lp1 /dev/lp2This shows the three parallel printer devices that are installed on your system by default.


348 Hour 15Serial printers are serial devices and have names such as /dev/ttySX, whereX is a number from 0 to 3 (similar to your modem ports). Read the setserialcommand’s manual page to learn how to set your serial port to the fastestbaud rate your printer supports. Read Grant Taylor’s Printing-HOWTO underthe /usr/doc/HOWTO directory for additional pointers on using serial printers.To determine if your printer is working, first make sure your printer is plugged in,attached to your computer’s parallel port, and turned on. Next, boot OpenLinux, and login. For a clue about which printer parallel port and printer device are used, pipe the outputof the dmesg command through the less pager, and look for output similar to the following:lp1 at 0x0378, (polling)Then, using the specified device (in this case, lp1) try sending a directory listing to yourprinter with the following:# ls >/dev/lp1You might also hear your printer activate or reset as OpenLinux boots andloads the lp.o parallel printer kernel module.If you specified the right printer device, your printer activates and prints the currentdirectory list. If nothing happens, try looking at any listed devices in the OpenLinuxprocess directory, like so:# cat /proc/devicesSee if the printer device driver was loaded or compiled in your kernel. You see somethinglike the following:Character devices:...6 lp...If you don’t see an lp device listed, make sure that the parallel printing lp.o module islisted in the OpenLinux module file (with the pathname returned by uname -r and uname-v commands) under the /etc/modules directory.


Preparing Documents 349Printing Documents with the LPRng Printing SystemIf you installed a printer during the initial Linux installation process, you can find yourprinter defined in the /etc/printcap file. This file is an ASCII database of your system’slocal and network printers and describes the capabilities of each printer.15OpenLinux uses Patrick Powell’s line printer spooling system, named LPRng, which is anupdated and improved version of the lpr spooling system used by other Linux distributions.It features networking and security enhancements. When you first boot, OpenLinuxstarts lpd, the line printer daemon. The lpd program runs in the background, waiting forprinting requests. You start a printing request with the lpr command:# lpr mydocument.txt# lpr myfile.psThis command line spools, or sends, your documents to a file in the /var/spool/lpddirectory. You also can use the lpr command as a printing filter to print outgoing streamsof formatted text:In general, files sent to your printer are converted to PostScript according toa set of configuration rules in files called print filters under the/var/spool/lpd/lp directory. Under OpenLinux, your printer is designated asa PostScript printer (with the name ps), which enables a wide variety ofUNIX and Linux programs to work transparently to print your documents.# groff -Tascii -mm myfile.txt | lprThis command line sends the output of the groff formatting program through the lineprinter spooler. You also can spool multiple files and then track your print jobs, or printingrequests, by using the lpq command. See the following example:# lpr mes.txt# lpr test.txt# lpqPrinter: ps@presarioQueue: 2 printable jobsServer: pid 797 activeUnspooler: pid 798 activeStatus: printed all 16543 bytes at 14:30:05Rank Owner/ID Class Job Files Size Timeactive bball@presario+796 A 796 (stdin) 16543 14:30:052 bball@presario+804 A 804 kdmfix.txt 1500 14:30:10


350 Hour 15The output of the lpq command in the preceding example shows that there are two jobscreated by the user bball for the printer ps@presario. If you don’t want to print variousspooled files, use the lprm command to remove a waiting print job. For example, todelete the print job for the kdmfix.txt document in the preceding example, use the following:# lprm 804You also can (as the root operator) disable or enable printers or reorder jobs with the lpccommand. When you start lpc by itself on the command line, you see a prompt like this:# lpc>This command has built-in help. To see a list of commands, use a question mark (?), likethis:# lpc> ?usage: %s [-A] [-Ddebuglevel] [-Pprinter] [-V] [command]with no commands, reads from stdin-A - use authentication-Pprinter - specify printer-V - increase information verbosity-Ddebuglevel - debug levelcommands:abort (printer[@host] | all) - stop serverdisable (printer[@host] | all) - disable queueingdebug (printer[@host] | all) debugparms - set debug level for printerenable (printer[@host] | all) - enable queueinghold (printer[@host] | all) (name[@host] | job | all)* - hold jobholdall (printer[@host] | all) - hold all jobs onkill (printer[@host] | all) - stop and restart serverlpd [HUP] - get LPD PID, signal it to reread printcap and configurationlpq (printer[@host] | all) (name[@host] | job | all)* - invoke LPQlprm (printer[@host] | all) (name[@host]|host|job| all)* - invoke LPRMmove printer (user|jobid)* target - move jobs to new queuenoholdall (printer[@host] | all) - hold all jobs offprintcap (printer[@host] | all) - report printcap valuesquit- exit LPCredirect (printer[@host] | all) (printer@host | off )* - redirect jobsrelease (printer[@host] | all) (name[@host] | job | all)* - release jobreread- LPD reread database informationstart (printer[@host] | all) - start printingstatus (printer[@host] | all) - status of printersstop (printer[@host] | all) - stop printingtopq (printer[@host] | all) (name[@host] | job | all)* - reorder joblpc>


Preparing Documents 351Documentation for your OpenLinux printing system can be found in various man pagesof the LPRng software distribution and under the /usr/doc/LPRng directory. Table 15.4lists the major components and programs used.15TABLE 15.4 PRINT SPOOLING SYSTEM UTILITIESNamelpclpdlpd.conflpd.permslpflpqlprlpraccntlprmmonitorDescriptionThe line printer control programThe line printer daemonDescription of the LPRng configuration fileDescription of the LPRng permissions control fileA printer filter (used in printer definition files)Show the printer spool queueStart print jobsPrinter accounting information utilityDelete print jobs from the spool queueLog information from the lpd daemonConfiguring Your Printer with the lisa CommandInstalling, changing, or deleting local printers with your OpenLinux system is a snapthanks to the Linux Installation and System Adminisration utility called lisa. This programis located under the /bin directory. This program can be used with or without theX Window System to set up your printer so you can print from the command line orthrough various X11 clients.Because lisa is a system administration tool, you have to make sure you’re the rootoperator and then type the following at your console or terminal command-line to configureyour printer:# lisa --printerThe screen clears, and you see a dialog box, as shown in Figure 15.1.This dialog box lists nearly 40 different printers. Scroll through the list, and then pick aprinter that matches your printer (or has the same capabilities).


352 Hour 15FIGURE 15.1The lisa program providesan easy-to-useinterface when youneed to configure aprinter for OpenLinux.If you have a printer that appears to be unsupported, check Caldera System’sWeb site at http://www.calderasystems.com/support/techguide.html to seeif additional support has been created for your printer. Users of Epson Styluscolor printers definitely need to read about support for these printers. If youwant to print over a network or install a network printer, definitely read the“Local Filter for Remote Printer” document. If you have a PostScript printer,see the document “Setting Up a Real PostScript Printer.”When you finish, press Enter. You see a dialog box (in Figure 15.2) that lists several parallel-printerports. Scroll through the list, pick your computer’s parallel port, and pressEnter.FIGURE 15.2After you select yourprinter, lisa asks youto select the appropriateparallel-printerport for your computer’sprinter.


Preparing Documents 353Your next step is to select the default resolution supported by your printer. This value isin horizontal and vertical dots per inch. If you’re not sure about your printer, check themanufacturer’s manual included with your printer. Scroll through the list of resolutions(shown in Figure 15.3), and pick one that matches your printer’s capabilities.15FIGURE 15.3Select the proper resolutionwhen configuringa printer forOpenLinux.When you finish, press Enter. As the last step, you now see a dialog box asking for thedefault paper size used with your printer. These capabilities are all used to build andconfigure a proper print filter for your printer. Scroll through the list of paper sizes(shown in Figure 15.4), select the right size, and press Enter to finish configuring yourprinter.FIGURE 15.4You must also select adefault paper sizewhen you configure aprinter for OpenLinux.


354 Hour 15Configuring WordPerfect for PrintingIf you downloaded and installed the free-for-personal-use edition of Corel’s WordPerfect8 for Linux from http://www.linux.corel.com/linux8/index.htm, you need to followseveral steps to print. This involves adding and selecting a printer driver as the defaultprinter.1. Start WordPerfect, and then press the F5 key. In the WordPerfect Print dialog box,click the Select button.2. A Select Printer dialog box appears, as shown in Figure 15.5. Click the PrinterCreate/Edit button.FIGURE 15.5The WordPerfect SelectPrinter dialog box isused to create or editprinters.3. A Printer Create/Edit dialog box appears. Click the Add button.4. An Add Printer Driver dialog box (shown in Figure 15.6) with a scrolling list ofprinter drivers appears. Scroll through the list, click the Passthru PostScript driver(wp60ps02.us.all), and click the OK button.5. A tiny Create Printer dialog box appears, using the name passpost.prs. Click theOK button.6. The Printer Create/Edit dialog box reappears with the Passthru PostScript printerhighlighted. Click the Setup button.7. A Printer Setup dialog box appears, as shown in Figure 15.7. Near the bottom ofthe dialog box, click the Destination button.


Preparing Documents 355FIGURE 15.6Select the PassthruPostScript WordPerfectprinter driver to createa printer forOpenLinux.15FIGURE 15.7In the Printer Setupdialog box, click theDestination button inthe CurrentDestination section toselect a document destination.8. A Select Destination dialog box appears (as shown in Figure 15.8), listing$PRINTER, Disk, lp, and ps. Click ps, and then click the OK button.9. In the Printer Setup dialog box, click the OK button. In the Printer Create/Edit dialogbox, click the OK button. In the Select Printer dialog box, click the OK button.You’re now at the main Print dialog box. Click OK to print the current documentor Cancel to cancel the printing operation. (You won’t lose the new printer you created.)If you set up printing to work correctly under OpenLinux before starting these steps, youcan now print WordPerfect documents to your printer!


356 Hour 15FIGURE 15.8In the SelectDestination dialogbox, you complete yourprinter setup.SummaryThis hour details some of the programs you can use to format and prepare text documentsfor printing. You also learned a little about some of the more complex typesettingsystems included with OpenLinux. Finally, you learned how to start, list, and controlprint jobs from the command line. You also learned how to create and configure a printerto use with OpenLinux.Q&AQ What other formatting utilities are included with OpenLinux?A There are quite a few, especially for converting text file documents to PostScript.Try using the enscript command to convert text documents, and then read aboutthe eqn utility for formatting equations for typesetting, the pic command for typesettingpictures from text, and the makeindex command for creating documentindexes.Q What other typesetting systems are included with OpenLinux?A Read the man pages for the amstex system, which uses macros to extend the powerof the TeX system. Another system, named latex, is included with OpenLinux.Q Typesetting using these macro languages seems tedious! Is there an easier wayto create these documents?A Try using the Lynx editor. This is a quasi-What-You-See-Is-What-You-Get editorthat creates documents styled similarly to latex.


Preparing Documents 357Q I try printing, and the lpr command responds with an error like “connectionto ps@localhost.localdomain failed—Network is unreachable”! What’s goingon?A Make sure that your /etc/hosts file contains a definition for the loopback deviceand local host. Also, make sure that you do not have any incorrect hostname definitionsin the file.15Exercises1. Try printing several files and then removing remaining jobs from the print queue.2. Use lisa to try to reconfigure your printer to use a higher resolution. What happens?3. Create your own man page using several of the man macros. Try using the nroffscript and the groff program. Which works better?


HOUR 16Graphics ToolsThis hour introduces a variety of graphics programs and utilities forOpenLinux. I’ll start with a short discussion of different graphics formatsused with OpenLinux and then show how you can convert graphics using filterprograms and other graphics utilities. These programs are useful for creating,editing, and translating graphics imported from other computerprograms or operating systems.You can find a treasure trove of great graphics programs on this book’s CD-ROM, and you’re likely to be impressed with their usefulness and versatility.At the end of this hour, you’ll be able to translate nearly any type of graphicsfile and perform sophisticated operations to transform your graphic files.


360 Hour 16Understand Linux Graphics File FormatsThere are many different types of graphics file formats, and examples of several typesare installed in your system. You might already be familiar with several different formats,especially if you’ve used other computer operating systems. However, if OpenLinux isnew to you, expect to run into graphics files in formats you’ve never seen before.Many graphics file formats can be recognized by the file name’s extension, or letters followinga period in the file name. For example, you might recognize .GIF, .PCX, .TIF, or.JPG as common extensions. More than 5,000 graphics are installed on your computer ifyou do a full installation of OpenLinux!Table 16.1 lists numerous graphics formats, along with relevant conversion programsincluded on your system. Read on to learn how to convert a graphics image from oneformat to another.TABLE 16.1 LINUX GRAPHICS FORMATS AND CONVERSION PROGRAMSFormat Type Conversion Program.10x Gemini 10X pbmto10x.3d Red/Blue 3D pixmap ppm3d.asc ASCII text pbmtoascii.atk Andrew Tookit raster atktopbmpbmtoatk.avs AVS X image convert.bie Bi-level image expert convert.bg BBN BitGraph graphics pbmtobbnbg.bmp Windows, OS/2 bitmap bmptoppmcjpegconvertgimpppmtobmpxv.bmp24 Windows 24-bit bitmap convertxv.brush Xerox doodle brush brushtopbm.cgm Computer graphics metafile convert.cmu CMU window manager bitmap cmuwmtopbm


Graphic Tools 361Format Type Conversion Programpbmtocmuwm.dcx ZSoft Paintbrush convert.ddif DDIF image pnmtoddif.dib Windows bitmap image convert.dxb AutoCAD database file ppmtoacadsldtoppm.dvi TeX printer file dvipsdvilj4dvilj4ldvilj2pdvilj.eps2 Encapsulated PostScript convertLevel II.epsf Encapsulated PostScript convert.epsi PostScript preview bitmap pbmtoepsiconvert.epson Epson printer graphics pbmtoepson.fax Group 3 fax convert.fig TransFig image convert.fits Flexible Image Transport fitstopnmpnmtofitsconvertgimpxv.fpx FlashPix convert.g3 Group 3 fax file g3topbmg32pbmg3catpbm2g3pbmtog3.gif Graphics Interchange cjpeg16continues


362 Hour 16TABLE 16.1 CONTINUEDFormat Type Conversion Programgiftopnmgif2tiffgimpppmtogifconvertxv.gif87 Graphic Interchange convertxv.go Compressed GraphOn pbmtogo.gould Gould scanner file gouldtoppm.icn Sun icon icontopbmpbmtoicon.ico Microsoft icon convert.ilbm IFF ILBM file ilbmtoppmppmtoilbm.img GEM image file gemtopbmpbmtogemimgtoppm.icr NCSA ICR raster ppmtoicr.jbig Joint Bi-level Image Group convert.jpeg Joint Photographic Experts cjpegGroupdjpegjpegtranconvertgimpxv.lj HP LaserJet data pbmtolj.ln03 DEC LN03+ Sixel output pbmtoln03.mgr MGR bitmap mgrtopbmpbmtomgr.miff MNG multiple-image network convert.mitsu Mitsubishi S340-10 file ppmtomitsu


Graphic Tools 363Format Type Conversion Program.mpeg Motion Picture Group convert.mtv MTV ray tracer mtvtoppmconvert.pbm Portable bitmap pbm*convertxv.pcd Photo CD convert.pcl HP PaintJet PCL ppmtopjxlconvert.pcx PCX graphics pcxtoppmppmtopcxconvertgimpxv.pdf Portable Document Format convertxpdf.pgm Portable graymap pbmtopgmpgmtoppmppmtopgmconvertcjpegxv.pi1 Atari Degas file pi1toppmppmtopi1.pi3 Atari Degas file pbmtopi3pi3topbm.pict Macintosh PICT file picttoppmppmtopictconvert.pj HP PaintJet file pjtoppmppmtopj16continues


364 Hour 16TABLE 16.1 CONTINUEDFormat Type Conversion Program.pk PK format font pbmtopkpktopbm.plasma Plasma fractal convert.plot UNIX plot file pbmtoplot.png Portable Network Graphic pngtopnmpnmtopngconvertgimpxv.pnm Portable anymap pnm*convertgimp.pnt MacPaint file macptopbmpbmtomacp.ppm Portable pixmap ppm*cjpegconvertxv.ps PostScript (lines) pbmtolpspnmtopsconvertxvgimpgv.psd Abode PhotoShop bitmap convert.ptx Printronix printer graphics pbmtoptx.qrt QRT ray tracer qrttoppm.rad Radiance image convert.ras Sun rasterfile pnmtorastrasttopnmgimp


Graphic Tools 365Format Type Conversion Programxv.rla Alias/Wavefront image convert (read-only).rle Utah run-length encoded convert (read-only)xv.sgi Silicon Graphics image pnmtosgisgitopnmconvert.sir Solitaire graphics pnmtosirsirtopnm.sixel DEC sixel format ppmtosixel.spc Atari Spectrum file spctoppm.spu Atari Spectrum file sputoppm.sun Sun rasterfile convertgimp.tga TrueVision Targa file ppmtotgatgatoppmconvertgimpxv.tiff Tagged File Format pnmtotifftifftopnmppmtotifftiff2psconvertgimpxv.tiff24 Tagged file Format (24-bit) convertxv.tim PSX TIM convert.ttf TrueType font file convert.txt text file bitmap pbmtextconvert (read-only)16continues


366 Hour 16TABLE 16.1 CONTINUEDFormat Type Conversion Program.uil Motif UIL icon ppmtouilconvert.upc Universal Product Code pbmupc.uyvy 16-bit YUV format convert.vicarconvert (read-only)xv.viff Khoros Visualization image convert.x10bm X10 bitmap pbmtox10bm.xbm X11 bitmap pbmtoxbmxbmtopbmconvertxv.xim Xim file ximtoppm.xpm X11 pixmap ppmtoxpmxpmtoppmconvertgimpxv.xv xv thumbnail xvminitoppm.xvpic xv thumbnail file xvpictoppm.xwd X11 Window Dump pnmtoxwdxwdtopnmconvertgimpxv.ybm Bennet Yee face file pbmtoybmybmtopbm.yuv Abekas YUV file ppmtoyuvyuvtoppmconvert.zeiss Zeiss confocal file zeisstopnm.zinc Zinc bitmap pbmtozinc


Graphic Tools 367Converting and Viewing GraphicsThere are a number of ways to convert graphic files to different formats using the programsinstalled on your system. Several of the painting or drawing programs discussed inthis hour translate graphics, and many programs in Table 16.1 also work as filters inpiped commands (see Hour 6, “Using the Shell,” for details) to translate graphics.You can use different combinations of these commands to convert files. OpenLinuxusers, such as graphics artists or system administrators, convert files for different reasons.Artists or casual users might want to import or export graphics for use by differentdrawing programs. System administrators might look for a side benefit of convertinggraphics to save disk space. In some instances, the savings can be considerable. Look atthe following example:# xwd >graphic.xwd# xwdtopnm


368 Hour 16but want to quickly flip it upside down and save it in .gif format, apply a filter programsuch as the pnmflip command:# xpmtoppm penguin.xpm | pnmflip -topbottom | convert - penguin.gifHere the file penguin.xpm is converted from .xpm format to .ppm format. The output ofthe xpmtoppm command is fed to the pnmflip command, which flips the graphics fileupside down with the -topbottom option. The output of the pnmflip command is fed tothe convert command, which reads the standard input and saves the graphics stream in.gif format.Combinations of different filters achieve different effects. For other effects, see suchcommands as pnmcrop, pnminvert, pnmrotate, pnmscale, pnnsmooth, or pnmtile.Not all graphics conversion programs included with your Linux distributionread the standard input and write to the standard output. Read the manualpages for any desired conversion programs before experimenting with pipeson the command line.Preview or print the results of your conversions before discarding originalfiles to make sure you achieve the effect you want and that the resultinggraphics file does not suffer loss of image quality.If you experiment with complex pipes, use the convert command, one of seven programsin the ImageMagick package (discussed later in the section “Graphics Editingwith ImageMagick”) for easier file conversions. This command, found under the/usr/bin directory, translates more than 75 different graphics file formats (even somenot listed in Table 16.1).The convert program normally works by recognizing different file extensions on thecommand line, as shown in the following example:# xwd >graphic.xwd# convert graphic.xwd graphic.tiffHere, the xwd client is used to create an X11 window dump graphics file. The convertcommand then creates a .tiff file by specifying the .tiff extension on the second, oroutput, file on the command line. For details about using the convert command, see theImageMagick and convert command man pages.


Graphic Tools 369Graphics Editing with GIMPYou can change or manipulate graphics from the command line, but if you use X11, it’s alot more fun to interactively work with files using an image-processing program. One ofthe best and newest graphics tools for Linux is the GNU Image Manipulation Program,or the GIMP, by Spencer Kimball and Peter Mattis.This capable and complex program, shown in Figure 16.1, has many features. If you’veworked with commercial software image-editing programs on other operating systems(such as Adobe PhotoShop), you’ll appreciate the GIMP’s tools and filters. The GIMPfeatures the following:16●●●●●●●●●●9 program operation menus21 different editing tools81 brushes168 patterns123 different plug-in filters and tools to create image effects or perform operationsImport and export of 24 different graphics formatsMultiple image windows, handy for cutting and pasting or multiple views of a fileMultiple layers for each image, so that effects can be superimposedMultiple undo levels, handy if you make mistakesSix floating windows and dialog boxes for selecting tools, brushes, colors, or patternsYou need nearly 23 megabytes of hard drive space to install GIMP and its softwarelibraries, support files, and related directories. The main GIMP files areinstalled under the /usr/X11R6/share/gimp and /usr/X11R6/lib/gimp/X.X directories,where X.X is the current version (1.0 at the time of this writing). The library directorycontains GIMP’s plug-ins, which are compiled modules run by GIMP from differentmenus that create effects or alter an image or image selection.NEW TERMThis program has 11 different command-line options (such as -help to show the list ofoptions) but does not support X11 Toolkit options, such as geometry settings. When youspecify a graphics file on the command line, GIMP attempts to load and interpret the fileaccording to the file’s extension. Starting GIMP is easy; simply type the following:# gimp &Unless you use the --nosplash option, you see a small window that provides detailsabout various GIMP resource files while loading.


370 Hour 16FIGURE 16.1The GIMP image editoris an impressiveX11 client with manyprofessional features,including nearly 100different filters formanipulatinggraphics.The file gimprc under your .gimp directory can contain settings for default brushes, patterns,palettes, and temporary directories. This file is initially empty, but you can copythe default systemwide gimprc file and then edit the various settings according to yourneeds. Table 16.2 lists some common settings you can change. For example, to createyour own copy in your home directory, use the following:# cp /usr/X11R6/share/gimp/gimprc $HOME/.gimp/gimprccp: overwrite `.gimp/gimprc’? yIf you edit large image files, you can quickly run out of disk space becauseGIMP initially uses 10 megabytes of system memory and creates large temporaryfiles during editing sessions (this is not unusual, as even commercialimage editing applications typically require swap storage three times largerthan system memory). If you have a separate hard drive with a lot of room,change the swap path (which is not the same as your Linux swap partition!)setting in the gimprc file to point to a directory on that drive. If you’re reallytight on memory and hard drive space, you can uncomment the stingymemory-useoption in your gimprc file. Open gimprc with your favorite texteditor, delete the pound sign (#) in front of stingy-memory-use, and thensave the file. On the other hand, if you have a lot of system memory, changethe tile-cache size to force GIMP to use less swap space and run faster.


Graphic Tools 371Your .gimp directory is searched first for available default brushes, tools, patterns, andother settings. Customize how GIMP runs by copying the defaults from the various/usr/X11R6/share/gimp directories into your home directory.TABLE 16.2COMMON GIMP RESOURCES SETTINGS AND DEFAULTSName Value Descriptionallow-resize-windows off Automatic resizing of window during image resizedefault-brush 19fcircle.gbr Default brushdefault-gradient German_flag_ Default gradientsmoothdefault-palette Default Default palettedefault-pattern wood2.pat Default patterndont-auto-save off Autosaving is not functional in GIMP 1.0dont-confirm-on-close off Disable image close without savingdont-show-rulers off No initial display of rulersdont-show-tool-tips off Disable help textinstall-colormap off Color setting for 8-bit displaysruler-units pixels Measurement in inches, centimeters, or pixelsstingy-memory-use off Setting for small memory systemsswap-path ~/.gimp Swap file locationtemp-path ~/.gimp/tmp Temporary file locationtile-cache-size 10m Default cache (in megabytes)undo-levels 5 Number of available Undo steps16When GIMP is running, you can tear off different dialog boxes and windows by usingthe dialog menu item under the GIMP File menu. If you have an active image window,access the complete GIMP menu system by pressing your right mouse button while thecursor is over your image. The various menus cascade, and you can select the file, edit,or other menu operations by dragging your cursor through the menus. Common editingkeys are listed in Table 16.3.


372 Hour 16TABLE 16.3 COMMON GIMP KEYBOARD COMMANDSActionKeyClear selectionCtrl+KClose fileCtrl+WCopy selectionCtrl+CCut selectionCtrl+XFill selectionCtrl+.Lower layerCtrl+BMerge layerCtrl+MOpen fileCtrl+OPaste clipboardCtrl+VQuitCtrl+QRaise layerCtrl+FRedoCtrl+RSave fileCtrl+SSelect airbrushASelect allCtrl+ASelect BezierBSelect blur/sharpen toolVSelect clone toolCSelect elliptical toolESelect eraserShift+ESelect eyedropperOSelect fill toolLSelect lassoFSelect magic wandZSelect move toolMSelect next toolTabSelect paintbrushPSelect pencilShift+PSelect rectangular select tool RSelect text toolT


Graphic Tools 373ActionKeyShow brushes dialog box Ctrl+Shift+BShow palette dialog boxCtrl+PShow patterns dialog box Ctrl+Shift+PShow rulersCtrl+Shift+RUndoCtrl+ZZoom in =Zoom out -16You can’t find much information about the GIMP included with OpenLinux with theexception of a manual page. For the latest news and details about this program, browse tothe following site:http://www.gimp.orgThis is the best place to find copies of the latest version of GIMP, links to GIMPFrequently Asked Questions lists, a GIMP tutorial, and new plug-ins.Graphics Editing with ImageMagickThe ImageMagick package, by John Cristy, is a collection of seven programs you canfind installed on your system. Some of these commands require the X Window System,whereas others can be used from the command line. The convert command has alreadybeen discussed in this hour, but you might find some of the other utilities useful whenyou want to manipulate graphics:●●●●●●●animate—Displays a series of graphics; requires X11combine—Combines and overlays multiple images into a single imageconvert—Converts or changes graphics filesdisplay—Displays program with menus for manipulating images; requires X11import—Window capture utility; requires X11mogrify—Converts or changes and then overwrites multiple graphics filesmontage—Combines several graphics into a larger imageImageMagick’s display command has more than 75 different features and effects youcan use to edit or change graphics. One interesting feature is the capability to loadimages into a visual directory so you can see thumbnails of all images in a directory.


374 Hour 16Although most applications and the X11 desktop (such as the background,window frames, and program borders) look colorful, if you load and try todisplay a color image with lots of colors, the displaying client (such as thedisplay command) reduces the number of colors used for the image if notenough colors are found in X’s colormap table. This is a technical problemand limitation in X11. There are two things you can try to do: first, try to useat least 16-bit color for your X sessions (with the -- -bpp 16 startx option);next, see a client’s man page to see if there is a private colormap option.Using a private colormap when you launch an application causes the clientto display better color for its windows. The downside (which you can readilysee when you use a client such as quake.x11 or xboing) is that when yourmouse pointer moves in the client’s windows, the surrounding desktop’s colorsare thrown out of whack.Using the display command is easy, but you must be running the X Window System. Toload a graphics file from a terminal command line, type the following:# display nat.jpg &This loads the file and starts the program. When the graphics file loads, it is displayed ina window. Click the graphics window to see the display command’s menu, as shown inFigure 16.2. To see a visual directory of your graphics, type the following:# display ‘vid:*.gif’ &This command line loads all .gif graphics in the current directory. After the programstarts, access its menus by pressing the left mouse button when your cursor is over theimages window. The display command imports and exports 58 different graphics formats.The program features built-in help and can also create slide shows of graphics.For more information about ImageMagick, see its manual page and the manual pages forthe other programs in the distribution. Comprehensive documentation is available athttp://www.wizards.dupont.com/cristy/ImageMagick.html.Using the xv Command to View GraphicsThe xv command, shown in Figure 16.3, is a handy previewer used to review, crop, scale,edit, or convert graphics. This command offers many sophisticated sizing and color controlsand more than 100 command-line options. You also can use xv, found under the/usr/X11R6/bin directory, to capture windows of your X11 session.


Graphic Tools 375FIGURE 16.2The display X11client, part of theImageMagick softwarepackage, can be usedto make changes tomany different types ofgraphics.16The xv client is not free software. If you use this program for commercialpurposes or institutional or government use, you should send a registrationfee to the author, John Bradley. Press Ctrl+A in the xv controls dialog box tosee how to register.The xv command loads a single file or series of graphics if you use a wildcard on thecommand line, as in the following example:# xv *.jpgThis command line loads all files ending in .jpg in the current directory. After the filesare loaded, scroll through a list of files to make your changes, or use a graphics directoryto select your files.The xv client does not function well on 24-bit displays. If you need to use alot of colors during your X sessions, start X11 with 16- or 24-bit color.


376 Hour 16FIGURE 16.3The xv command is anX11 client that loads,edits, captures, saves,or prints images andfeatures sophisticatedcolor controls.The xv command can import and export 18 different graphics file formats and also canprint graphics. For more information about using xv, see its man page and read its definitivedocumentation. This file is 128 pages in PostScript format. See the next section tolearn how to easily read this documentation.Using the gv Command to View PostScript FilesThe gv command is a PostScript previewer used to examine or read PostScript graphicsor documents before printing. You must run the X Window System to use this program.This command, found under the /usr/X11R6/bin directory, is a much-improved previewerby Johannes Plass and is based on the older ghostview program by Tim Theilson(installed under the /usr/X11R6/bin directory).The gv command (shown in Figure 16.4) has more than 36 different command-lineoptions and uses a number of X11 Toolkit options, such as geometry settings. You canstart gv by itself or specify a file on the command line, along with its options:# gv -geometry 640x480 myfile.psThis command line starts the gv command in a 640∞480 pixel window displaying thefile myfile.ps.Use the gv command to read X11 client or program documentation inPostScript format. For example, to quickly browse and read the xv documentation,use gv like this:# gv -geometry 640x480 /usr/doc/xv-3.10a/xv.docs.ps.gzThe gv client reads compressed PostScript documents!


Graphic Tools 377Another great feature of the gv command is that it reads portable document format, or.pdf, files. This is a handy way to read .pdf documents without installing an additional.pdf reader, such as Adobe Acrobat or xpdf.FIGURE 16.4The gv X11 client displaysPostScript orPDF documents andgraphics and providesan easy-to-use interfaceto previewing filesbefore printing.16The gv command also uses a unique scrolling mechanism; instead of scrollbars alongsideor below the document window, a rectangular button controls the document viewing area.You also can print whole documents or selected pages by using different commands.You can find a comprehensive manual page, along with a hypertext series of .html files,under the /usr/doc/gv directory.An easy way to read gv’s documentation is with the lynx or netscape Webbrowsers as in the following example:# lynx /usr/doc/gv-doc-html-3.5.8/gv.htmlA Word About Digital Cameras and ScannersAlthough Linux runs on many different computers and supports many different hardwaredevices, the state of digital camera and scanner support is still in its infancy. Before youbuy a digital camera or scanner with the express purpose of using it with OpenLinux,carefully check all Linux Internet sites for different scanning software, and then read asmuch documentation as possible.


378 Hour 16You can find scanner support for many models from Nikon, Epson, Genius, Hewlett-Packard, and Mustek. Although most scanners for Linux require a Small ComputerSystem Interface, or SCSI interface, you can find support for the Connectix series ofQuickCams using your computer’s parallel port or the Kodak DC20 and DC25, whichuse a serial-port interface. Beware: there are variations between models of scanners evenfrom the same manufacturer, and not all models in a particular series of scanners mightbe supported.The best place to check for support before buying is the SANE, or Scanner Access NowEasy Web pages. You can browse to http://www.mostang.com/sane/ and find a tutorialon how to install the sane scanner drivers for OpenLinux. To help you in making a decision,Table 16.4 lists manufacturers and the number (not models) of scanners from themanufacturer that are supported.TABLE 16.4 MANUFACTURERS AND NUMBER OF CAMERAS OR SCANNERS FOR SANEManufacturerNumber of Cameras or ScannersAbaton 2Agfa 8Apple 3Artec 4Canon 3Epson 1Hewlett-Packard 11Kodak 2Linotype 1Microtek 17Mustek 7Nikon 3Plustek 3Polaroid 1Tamarack 3Umax 19Vobis 2


Graphic Tools 379Another place to look for scanner software, documentation, and support is in the smallcollection of graphics application capture software packages at the following site:http://metalab.unc.edu/pub/Linux/apps/graphic/captureFor QuickCam support, try the following site:http://www.quickcam.com/developer.htmlIf you want to scan documents using the xv X11 client, look for the xvscan software atthe following site:16http://www.tummy.comSummaryThis hour introduced you to graphics conversion programs for use with OpenLinux. Youalso learned about several X11 clients you can use to create and edit graphic files. Thereare many additional graphics programs included with OpenLinux, but support for scannersis still somewhat limited.Q&AQ What other drawing and graphics editing programs come with OpenLinux?A The classic graphics editor included with X11 is the bitmap client. For editingmore complex bitmaps, try the xpaint client. For technical drawing, such as blueprints,try the object-oriented editors tgif and xfig. However, you need a displaywith a resolution of at least 1024∞768 in order to use these clients.Exercises1. Look under the /usr/X11R6/include/X11 directory, and then load some imagesfrom the bitmap and pixmap directories. What clients did you use?2. Try converting a favorite graphics file into another graphics format. What programsdid you use?3. If you have a dual-boot computer running another operating system, mount theother file system and search for graphic images. What file extensions did you useas a search criteria, and how many images did you find?


380 Hour 16


HOUR 17Learning Math andFinancial ToolsThis lesson is an introduction to some of the mathematical and financialtools available for Linux. This hour shows you calculators, spreadsheets, andgraphic modeling programs and points you to sources where you can findeven more programs. Whether you’re only interested in setting up simplesingle-screen spreadsheets or would rather plot detailed maps using 200megabytes of cartographic data from the U.S. Geologic Survey, you’ll findLinux tools to help you get started.The hour begins with a discussion of some calculators and calculating languages,introduces you to some of the Linux spreadsheet programs, and finisheswith a discussion of modeling programs, such as gnuplot. This hourcan’t cover all the more than 1,500 scientific applications for Linux, but ifyou have an interest in other fields, such as artificial intelligence, astronomy,biology, chemistry, database systems, electronics, linear algebra, physics, orraytracing, you can find tools for Linux to help you.


382 Hour 17CalculatorsThis section introduces you to several Linux calculators. You’ll find some of these handywhen you pay bills, cook, or even travel. Some of these calculators work from the commandline, and others run under the X Window System.Doing Desk Calculations with the dc CommandThe dc (desk calculator) command is a command-line calculator that uses reverse Polishnotation, or RPN, to perform calculations and has more than 30 different operators andinternal commands. The dc command, found under the /usr/bin directory, is easy touse:# dc44 55 + p99qThe example shows that to add two numbers, you first enter the numbers, then enter theoperator, and then use the p command to print the value placed on the stack by the additionoperator. The q command quits the dc program. This method of performing calculationsis not as inconvenient as you might think. For example, suppose that you’re goingthrough the checks you’ve written during the month and that you want to check yourwritten calculations. Using the dc command, you can enter the following:# dc2500.0049.95-p2450.0532.18-p2417.87qYou start by entering a $2500.00 balance, and then enter $49.95 as the first check, followedby the subtraction operator (–). The p command prints the result, and the next currentbalance of $2450.05 is maintained on the stack (a temporary storage area inmemory). You can also use the dc command to read files of calculations instead of typingcommands at your terminal, and it has 256 different registers, or temporary storage areas,for your calculations. See the dc command’s manual page for more information andother features.


Learning Math and Financial Tools 383Calculating with the X11 xcalc ClientThe xcalc client is one of the more familiar graphic calculators (see Figure 17.1) andcomes with the XFree86 X Window System. The xcalc command, found under the/usr/X11R6/bin directory, has only two command-line options, -stipple and -rpn. The-stipple option merely colors the background of xcalc’s face, whereas the -rpn optiontells the xcalc command to use rpn for doing calculations and changes its appearance.You must be running X11 to use the xcalc command. You can use your mouse or thekeyboard to enter numbers and perform calculations. To use it in its normal mode withthe -stipple option, type the following:# xcalc -stipple &FIGURE 17.1The xcalc calculatorhas two options that canalso be used together:-stipple (for a mottledbackground) and –rpn(to emulate a TexasInstrument’s calculator).17To use the xcalc command as an rpn calculator, type the following:# xcalc -rpn -stipple &You can customize nearly any aspect of xcalc by editing its defaults file, Xcalc, which isfound under the /usr/X11R6/lib/X11/app-defaults directory. See the xcalc manualpage for more information.Calculating with the kcalc ClientThe kcalc client, included with the K Desktop Environment, or KDE, is availablethrough the Utilities menu on your desktop’s control panel or can be started from thecommand line of an X11 terminal window, like this:# kcalc &


384 Hour 17After you press Enter, the kcalc dialog box appears as shown in Figure 17.2. To customizethe kcalc display, click the kCalc button. A dialog box appears, as shown inFigure 17.3. To change the background and foreground colors, click the Change buttons.To change a font, click the Display Font tab.If you need quick access to the command line but find the process of openinga terminal window tedious, use KDE’s minicli client: press Alt+F2, and asmall command-line window appears. Type in your command, such as xcalc,and press Enter. The command-line window disappears, and the X11 clientruns.FIGURE 17.2The kcalc calculatorperforms calculationsin several numericalbases.This calculator, created by Bernd Johannes Wuebben, sports a trigonometric and statisticalmode and can perform calculations in base 16, 10, 8, and 2. You can use your numberkeys, numerical keypad, or Num Lock key to enter calculations.The precision for base 16, 8, and 2 might be limited. Click the About tabafter pressing the kCalc button for more details. You might be able toincrease kcalc’s precision by rebuilding the program. If the source code isnot included on your OpenLinux CD-ROM, you can download the source toKDE’s utilities distribution through http://www.kde.org or one of this site’smirrors.


Learning Math and Financial Tools 385FIGURE 17.3The kcalc calculator’sfont and display canbe customized.This calculator is also handy for performing quick conversions of numbers in differentbase values. To convert a number, click a base to use, enter the number, and click a differentbase. The number is converted automatically.17Performing Unit Conversions with the unitsCommandIf you’ve ever had trouble remembering the formulas to convert miles to meters or cupsto gallons, you’ll really like Adrian Mariano’s units command, which you can findunder the /usr/bin directory. Want to know how many furlongs per mile? How abouthow many acres are in a square mile?One way to use the units command is from the command line, for example:# units floz gallon* 0.0078125/ 128This simple example shows how to find out how many fluid ounces are in a gallon. Yousee that there are 128 and that a fluid ounce is less than one hundredth of a gallon.Although using the command line is handy for quick conversions, you can also run aseries of queries, as follows:# units501 units, 41 prefixesYou have: mile*mileYou want: acre* 640/ 0.0015625You have: mile2You want: acre* 640


386 Hour 17/ 0.0015625You have: mile^2You want: acre* 640/ 0.0015625You have: mileYou want: furlong* 8/ 0.125You have: 100 fathomsYou want: feet* 600/ 0.0016666667...In the interactive mode, you can ask units for any number of conversions. The unitscommand works by reading its database of conversions from the file/usr/share/units.dat. You can also copy this file to your home directory and add yourown custom conversions to it. As you can see, you can use different notations to indicateamounts to be converted. Another interesting feature is that units can also perform currencyconversions, for example:# units dollar yen* 107.52688/ 0.0093Note that this might not be entirely true, as currency values change daily. You can editthe units.dat file and insert not only current currency values, but also prices for gold,silver, platinum, or pork bellies. See the units manual page for more information.Programming Calculators with the bc LanguageInterpreterThe bc command is an interpreter for a calculator language. You can use this command,by Philip Nelson, to write calculator programs while bc is running or have bc run theprogram after it starts. The bc language has nearly 40 operators, functions, and programminglogic keywords. Although this section doesn’t go into how to program in bc, ifyou’re interested in the bc language, try the simple checkbook balancing program frombc’s manual page. The program can work like the previous example for the dc command.Read the bc manual page, and then type the program into a file using your favorite texteditor. You can run it with the following:# bc nameofyourfile


Learning Math and Financial Tools 387The bc command starts by reading in the program in the file nameofyourfile andpresents the following:...Initial balance? 2500.00current balance = 2500.00transaction? 49.95current balance = 2450.05transaction? 32.18current balance = 2417.87transaction?...This is only one way to use the bc command’s language. With a little effort, you canwrite your own programs. If you need to perform more complex calculations, use aspreadsheet application. The next section discusses the variety of spreadsheets for Linux.17SpreadsheetsSpreadsheet programs offer a convenient way to store and manipulate financial or scientificdata. You can use these programs to help manage your home or business. Typicaluses involve personal finance, such as tracking loans and investments, or running businessinventory control, personnel worksheets, or accounting tasks.You can also use these programs to do forecasting, or “what if” calculations. This canhelp you create estimates you can use for home mortgages, auto loans, and even homeconstruction. You’re limited only to your imagination with most of these programs, andmany not only offer the capability to work as a whiz-bang calculator, but also creategraphic charts so you can visually see your data.Several of these programs are on your CD-ROM. After you connect to your ISP (seeHour 10, “Connecting to the Internet”), you can use the Lynx Web browser or NetscapeNavigator to search for other spreadsheet or financial programs. If you need to have aspreadsheet program to use with OpenLinux, you’re in luck because at least a dozen areavailable. Nearly half come with source code, so you can make changes, add features, orfix problems. Recent releases of free-for-personal-use spreadsheets are as feature rich asmany commercial programs costing lots of money.Using the Public Domain sc SpreadsheetThe sc (spreadsheet calculator) command (see Figure 17.4) is a freely available, publicdomain spreadsheet program. This program is a collective work of nearly 60 programmers,and runs on many different UNIX systems. With a little effort in learning its commands,you can build very capable spreadsheets. The sc program is free, and it comeswith source code. A short tutorial and manual page documenting its features is included.


388 Hour 17This program is especially handy if you’re running OpenLinux on a small hard drive anddisk space is at a premium. The sc program requires only about 120 kilobytes of diskspace but provides a lot of features.Using the sc program is easy. You can load programs from the command line when youstart it, or you can load and save programs while it’s running. You can run this programas follows:# scFIGURE 17.4The sc spreadsheetcalculator works withor without the XWindow System, and itcomes with a shorttutorial.If you want a quick reference to the sc commands, use the scqref command (foundunder the /usr/bin directory) and pipe the output through the nroff and lesscommands. Then either read at your leisure or redirect to a file you can edit and print, forexample:# scqref | nroff -man | less > scref.txtTo learn how to use the sc spreadsheet program, load the sc program’s tutorial, whichyou can find under the /usr/doc/sc directory:# sc /usr/doc/sc*/tutorial.scThis runs sc and loads the tutorial. An included program, called psc, can help youimport text-only data files by converting word processor or other spreadsheet programfiles. For example, to prepare exported spreadsheet text for input to sc, use the psccommand like this:# psc mysheet.pscThe sc program has more than 60 built-in functions, and because you get the sourcecode, you can add your own.


Learning Math and Financial Tools 389Using the slsc SpreadsheetThe slsc spreadsheet calculator command (see Figure 17.5) is an improved version ofsc. This program sports many new features such as improved menus, the use of color(with the -C command-line option), a resource file for customizing colors and keys,improved printing support, and information hiding.Like sc, the slsc program is free and comes with source code. A short tutorial and manualpage documenting its features is included. You can use this program with or withoutthe X Window System.You can load programs from the command line when you start slsc, or you can load andsave programs while it’s running. To start this program with color, type the command asfollows:# slsc -C17For color support in X11, you must start slsc in a color-capable terminalwindow. You can also customize the default, systemwide settings by copyingthe file slsc.rc to your home directory with the name .slscrc. Then editthis file in your favorite text editor to change the settings.FIGURE 17.5The slsc spreadsheetcalculator is animproved version of scand also works with orwithout the X WindowSystem.


390 Hour 17To learn how to use the slsc spreadsheet program, load the slsc program’s tutorial,which you can find under the /usr/lib/slsc directory:# slsc /usr/lib/slsc/tutorial.scThis runs slsc and loads the tutorial. An included program, called vprint (includedunder the /usr/lib/slsc directory) can be used to print spreadsheet files. For moreinformation, see the slsc man page, various files in the /usr/lib/slsc directory, anddocumentation under the /usr/doc/slsc directory.If you like sc or slsc but want to try other spreadsheet programs forOpenLinux, look for the oleo spreadsheet, which is included on this book’sCD-ROM. You might also want to try the X11 xspread program created bysoftware engineering teams at the University of Wisconsin-Milwaukee. Thisprogram requires that you’re running X11, but offers mouse support, thecapability to import Lotus 1-2-3 format files, and can generate and displayline, bar, stacked-bar, and pie chart graphics from spreadsheet data. Look forthis program at ftp.cdrom.com in the/pub/linux/slackware_source/xap/xspread directory.Another alternative spreadsheet is the teapot (table editor and planner)spreadsheet program by Michael Haardt. This spreadsheet works under X11or your console, and features import of sc and .WK1 (one of the old Lotusformats) spreadsheet files, export of CSV, HTML, LaTeX, or ASCII file formats,three-dimensional spreadsheets, support of custom keyboard function keys,great documentation, and availability in German, English, or Dutch languageversions. You can get a copy at: ftp://cantor.informatik.rwth-aachen.de/pub/unix/teapot-1.0.3.tar.gz.Finding the Free Wingz SpreadsheetThe Wingz spreadsheet, from Investment Intelligence Systems Corporation, is a freewarespreadsheet program for OpenLinux. This program, which comes in two versions,requires more than six megabytes of hard drive space when installed. Wingz has nearlyany feature you could need in a spreadsheet program, including a built-in scripting languagecalled HyperScript. You can use HyperScript to build custom interfaces and programsto present your spreadsheet data. There isn’t much documentation, but there aresome impressive example sheets you can load and examine, and Wingz has built-in,context-sensitive help.


Learning Math and Financial Tools 391You can generate many different types of 3D graphics, and spreadsheets can be linkedor previewed before printing. To read more about Wingz, browse to http://www.wingz-us.com. To get a free copy, go to http://metalab.unc.edu/pub/Linux/apps/financial/spreadsheet.Features of the StarCalc Spreadsheet ProgramThe StarCalc spreadsheet program (see Figure 17.6) is part of the free-for-personal-useStarOffice suite of programs for OpenLinux. This spreadsheet program is integrated withthe other StarCalc applications. You can copy, paste, or use spreadsheet data and graphicsas linked objects, like those for Applixware.This is a capable program with all the features of a commercial title. Like all other programsin the StarOffice suite, StarCalc has print previews, 3D graphics, and drag-anddropcell movement.17If you’re using StarOffice 4.0, press Ctrl+N to open the StarOffice Templatesdialog box, and then scroll down the list of Categories and click on theSpreadsheets item. There are seven ready-made spreadsheet documents youcan use. If you’re using StarOffice 5.0, press Ctrl+N to open the Templatesdialog box, and then scroll down and select the Financial Documents item.There are six different specialized spreadsheets, such as a Household Budget,a Stock Portfolio, and a Car Financing document.FIGURE 17.6The StarCalc spreadsheet,like ApplixSpreadsheets, has stylesheets and mousedriventoolbars andsupports multiple waysof viewing spreadsheetdata graphically.


392 Hour 17You can import and export many different types of spreadsheet formats, as shown inTable 17.1.TABLE 17.1 StarCalc SPREADSHEET IMPORT AND EXPORT FORMATSImportExportMS Excel 4, 5, 95, 97 MS Excel 5, 95, 97Lotus 123 DOS/WINDIFDIFCSVCSVSYLKSYLKdBasedBasetexttextTo import a spreadsheet document into StarCalc, use the Open menu item from theStarCalc File menu. To export a spreadsheet document, use the Save As menu item fromthe File menu. A dialog box appears as shown in Figure 17.7. Click the drop-down menunext to the File type field, and a scrolling list of file types appears. Scroll through the list,and click the desired format. To save the file, click the Save button.FIGURE 17.7The StarCalc spreadsheetcan export documentsin 13 differentformats.Find out more about the StarCalc spreadsheet program by browsing tohttp://www.stardivision.com. Also see Hour 19, “Home Office Management withStarOffice” for more detailed information about how to use StarOffice and StarCalc.


Learning Math and Financial Tools 393Commercial Features of the Applixware SpreadsheetProgramThe Applixware spreadsheet program (see Figure 17.8) is part of the commercialApplixware suite of 10 programs for Linux (see Hour 14, “Text Processing,” for moreinformation). This spreadsheet program is integrated with the other Applixware programsusing linked objects. This means that if you change the data in your spreadsheet file, thedata or chart used in a word processing document also changes.As you might expect with a commercial program, this spreadsheet offers all the featuresof competing titles. Besides such features as integration with the other programs in itssuite, print previews, or 3D graphics, this spreadsheet program has drag-and-drop cellmovement, multiple views, and numerous database functions.FIGURE 17.8The Applixwarespreadsheet has stylesheets and mousedriventoolbars andsupports multiplegraphics.17You can import and export many different types of spreadsheet formats, as shown inTable 17.2.


394 Hour 17TABLE 17.2 APPLIXWARE SPREADSHEET IMPORT AND EXPORT FORMATSImportExportXLSXLS3, XLS4, XLS5WKS, WK1, WK3, WK4WK1, WK3DIF, XDIFDIFCSVCSVSYLKSYLKTextTextYou can find out more about the Applix spreadsheet program by browsing tohttp://www.applix.com.Using gnuplot to Graph MathematicalFormulasThis section shows you how to use gnuplot, an interactive plotting program by ThomasWilliams and Colin Kelley. This program supports nearly 40 different printers and outputdevices, although you’ll probably want to experiment with gnuplot using the X WindowSystem and print your graphics using PostScript (see Hour 15, “Preparing Documents,”for more information on how to do this).Although gnuplot (no relation to GNU software, but supported and distributed by theFree Software Foundation under the GNU General Public License) is not the only mathematicalmodeling and plotting program available for Linux, it is included on your CD-ROM. You can find the gnuplot program under the /usr/bin/X11R6 directory.The gnuplot program (see Figure 17.9) is a complete, interactive plotting program andwas originally designed to graph math functions and data. In this regard it is somewhatsimilar to other commercial formula-interpretation and plotting programs. It can read andsave files and has built-in help, so you can query the program while you use it.Using gnuplot is simple. The program has five different command-line options (such as-mono or -gray to force monochrome or grayscale plots, and -clear and -tvtwm to clearthe window first or place the window relative to the desktop), but many aspects of theprogram can be controlled interactively or as commands in a loaded gnuplot data file.One common use of the command line option is to control the point size (in pixels) ofdrawing lines using the -pointsize option, as in the following example:# gnuplot -pointsize 2


Learning Math and Financial Tools 395You can use and plot many types of mathematical expressions, and according to thegnuplot documentation, any C, Pascal, Fortran, or BASIC language mathematical statementcan be used. For example, start the program at the command line of an X11 terminalwindow like this:# gnuplotAfter you press Enter, type in some variable values, such as the following:gnuplot> y = -5gnuplot> x = 8FIGURE 17.9The gnuplot programcan help you visualizemathematical formulas,spreadsheet data,and yes, even whales.17To plot an expression, such as (x*y)-(x+y), use the plot command, followed by theexpression, like so:gnuplot> plot (x*y)-(x+y)After you press Enter, a new gnuplot window appears with a graphic of your expression.When you finish, type quit at the gnuplot prompt to exit the program. To load and plotsample datafiles, change directory to /usr/X11R6/lib/gnuplot/demo. Then, to displaythe data (as shown in Figure 17.9), use gnuplot followed by the name of a demo file,like this:# gnuplot animate.demAfter you press Enter, you see a picture of the digitized whale, which starts swimmingaround the plot area of the gnuplot window. You can find more documentation, thegnuplot FAQ, and updates to the gnuplot program at http://www.cs.dartmouth.edu/gnuplot_info.html.


396 Hour 17Many, many different financial and math applications are available forLinux. This hour barely scratches the surface. You can find financial applicationsthat can help you manage investment portfolios, track stock prices, oraid in developing cost estimates for construction projects. You can also findhundreds of specialized programs you can use in solving special computingneeds for other sciences. One of the best sites for perusing some of the bestof these applications is http://SAL.KachinaTech.COM. You can also find anumber of financial tools for Linux, along with source code, at http://metalab.unc.edu/pub/Linux/apps/financial.SummaryThis hour introduced you to a number of calculators and financial tools available forOpenLinux. Most of these programs are included on this book’s CD-ROM.Q&AQ I tried running the bc and dc calculators, but the shell returns “bash: dc:command not found”.A Use lisa, glint, or kpackage to install the programs. Look under theScientific/Math package folders.Q What other calculators, scientific programs, or math utilities are includedwith OpenLinux?A If you’re interested in other advanced programmable calculators with a built-in programminglanguage, try the gp command. Another language-type calculator is theyorick interpreter, which features syntax similar to BASIC or Lisp and includesan interactive graphics package for plotting results. Other programs include thefollowing:● rasmol This program is for viewing molecular graphics● felt This program is for finite element analysis, which includes a CADlikecompanion X11 client named velvet● xmgr This X11 client can generate high-quality visualizations of complexdata.● mxp and xfractint These clients for X11 compute and display fractalimages.


Learning Math and Financial Tools 397Q I tried using StarOffice 5.0’s File menu to create a new spreadsheet document,but can’t find these types of files listed!A This used to be possible with StarOffice 4.0. If you’re using StarOffice 5.0, clickthe Start menu button in the lower left corner of StarOffice’s desktop, and thenscroll up and click Spreadsheet to create a new spreadsheet document.Q I tried running the gnuplot demo, but it stopped with an error after showingseveral plots. What happened?A There’s an error in the one of the plot files. Try running the demo plots separately.Exercises1. Start gnuplot and try plotting your own math expressions.2. Copy a spreadsheet file from another operating system or application, and tryimporting the data into StarCalc. Experiment with importing and exporting differentformats. What formats work best?3. Start the dc calculator. Enter two 10-digit numbers, then an asterisk, and then the Pkey. What happens?4. Compare the sc and slsc spreadsheet calculators. How are these programs similar?In what ways are they different?17


HOUR 18Personal ProductivityToolsIn this hour I’ll show you some calendars, commands, and X11 clients youcan use to help your personal productivity. Whether it’s keeping a diary orcreating reminders, you’ll learn how to use these tools under OpenLinux tokeep you on track and on schedule with your life.Each program or technique discussed in this hour can be accomplished withsoftware you’ll find on the CD-ROM that comes with your book. After readingthis discussion, you’ll find additional ways to use these programs to craftyour own set of tools and techniques for personal productivity.


400 Hour 18Scheduling Personal Reminders and Taskswith the at CommandIf you need to keep track of important schedules, set reminders, or run programs unattended,you can use the at command. This command, found under the /usr/bin directory,schedules commands, or jobs, to be run at a time you specify. For example, if youare working on a project but need to remember to catch your car pool, you can enter aquick at job from the command line.Your system should enable you to use the at commands by default. If it doesnot, see Hour 24, “Using Scheduling to Automate System Management,” onhow to enable at command facilities for your system.For example, to send a pop-up reminder to your screen at the appropriate time, use thefollowing:$ at 16:15at> xmessage -display :0.0 “The car pool is leaving in 15 minutes.”at> warning: commands will be executed using /bin/shjob 12 at 1998-12-18 16:15This tells the at command to run the xmessage program to display the text of your messageabout your car pool on the specified X11 display, as shown in Figure 18.1. The endof-text(EOT) in the listing means you should press Ctrl+D to close the command toenter the job. If you make a mistake in the syntax of the command, you receive a mailmessage at the scheduled time. The -display command-line option tells the xmessagecommand which screen to show the message on, usually 0.0, which you can find with thefollowing:# printenv | fgrep DISPLAYThis command line pipes the output of the printenv command through fgrep to searchyour environment variables (discussed in Hour 6, “Using the Shell”) for the value ofyour $DISPLAY environment variable.You can also use the at command to provide a visual reminder, if you’re using X11, bycontrolling the color of your desktop, for example:# at 16:15at> xsetroot -display :0.0 -solid Redat> xmessage -display :0.0 “The car pool is leaving in 15 minutes.”at> warning: commands will be executed using /bin/shjob 14 at 1998-12-18 16:15


Personal Productivity Tools 401FIGURE 18.1The at command canbe used to run anyOpenLinux program orX11 client, such asxmessage, as areminder.This turns your desktop, or root display, a solid red color at the appointed time and thendisplays your message. As you can see, you can combine multiple commands to do anumber of things simultaneously. If you find this approach convenient, you can also typethese commands into a text file called carpool and run the commands by using the -foption, followed by the name of the file, with the following:# at 16:15 -f carpoolwarning: commands will be executed using /bin/shjob 13 at 1998-12-18 10:19The at command reads the commands from your text file and responds with a confirmation.As a further convenience, you can place this command line in your .xintrc scriptin your home directory to schedule the job after you start X11 at the beginning of theday.18See Hour 7, “Using the X Window System,” for more information about configuringyour .xinitrc file.Use the atq command to see a list of all your scheduled jobs, like this:# atq14 1998-12-18 12:00 a15 1998-12-18 13:00 a16 1998-12-18 14:00 a17 1998-12-18 15:00 a18 1998-12-25 16:15 aThis shows that four jobs are scheduled for December 18 with another scheduled forDecember 25. When you schedule jobs with the at command, a shell script containingeach command is created in the /var/spool/atjobs directory. The atq command looksin this directory for your jobs and then prints them to your display.


402 Hour 18You can use the at command to schedule a job minutes, hours, days, weeks, or evenyears in advance. If you want to run your car pool reminder file in three hours, you canuse the at command’s plus sign (+) command-line option, for example:# at +3 hours -f carpoolThis runs your job three hours from the current system time. You can also use the timeand date (in the form of mm/dd/yy) to schedule jobs, like so:# at 16:15 12/25/00at> xmessage -display :0.0 “The car pool is leaving in 15 minutes.”at> warning: commands will be executed using /bin/shjob 21 at 2000-12-31 16:15As you can see, the at command is Y2K-compliant! Use the atrm command to controlyour at jobs. You can selectively delete specific jobs by number. For example, using yourjob queue from the earlier example, you can type the following:# atrm 16 18This removes jobs 16 and 18 but leaves the other two intact. Using the at command is ahandy way to program one-time reminders for specific times. In the next section, I’llshow you how to schedule other jobs to run at regular intervals.You can also use Rob Nation’s X11 clock client, rclock, to schedulereminders or run programs at a selected day or time. To build a reminder,create a file called .rclock in your home directory, and enter reminder commandlines. For example:11:30 mtwtf Time for lunch!This displays a reminder for lunch during the week. The rclock client isusually distributed with the X11 rxvt terminal, but does not come withOpenLinux. You can get the latest version from http://babyaga.math.fu-berlin.de/~rxvt/, or you can also get both rxvt and rclock in an .rpmfile from http://metalab.unc.edu/pub/Linux/X11/terms/. For a diverse listingof different clocks (many with alarms) for OpenLinux and X11, browse tohttp://metalab.unc.edu/pub/Linux/X11/clocks.


Personal Productivity Tools 403Scheduling Regular Reminders with thecrontab CommandAlthough the at command is helpful for scheduling one-time jobs, you can use PaulVixie’s crontab command if you need regular tasks completed at regular intervals. Thecrontab command, found under the /usr/bin directory, is used to enter your desiredtimes and commands into a personal file.The crontab command works by looking for crontab schedules by username in the/var/spool/cron directory. The crontab file for your Linux system is called crontaband is located in the /etc directory. The program that runs the system and the user cronschedules is the cron daemon, which is started when you boot Linux and wakes up eachminute to check the system and user files.To create your own crontab file, you must use the command’s -e option, for example:# crontab -eMake sure you enable crontab use for your system. See Hour 24,“Scheduling” for details on how to do this. You can also define the default$EDITOR environment variable to your favorite text editor when you createor edit your crontab files. See Hour 6, “Using the Shell,” on how to set environmentvariables, and Hour 14, “Text Processing,” for information aboutusing various text editors.18This command launches the default text editor defined in your shell’s $EDITOR environmentvariable, so you can create or edit your personal crontab file. But before you getinto the format of your crontab entries, think about configuring your default editor.If your default editor is vi and you want to use a different editor, you can temporarilychange the $EDITOR variable using your shell. For example, if you’re using the bash shelland want to use the pico text editor, you can use the following:# EDITOR=/usr/bin/pico; export EDITORThis sets the default editor to the pico editor. You can confirm this by searching yourenvironment variables, for example:# printenv | fgrep EDITOREDITOR=/usr/bin/pico


404 Hour 18If you’ve never created a crontab file, you’re initially presented anempty file where you can enter crontab settings, regardless of whicheditor you use. Before you can enter your own schedule, you need to knowhow to format a crontab request.The format of a crontab entry looks like that in Table 18.1. Step values can be used indifferent fields, such as */3 for every three minutes or hours. Ranges can also be used,such as 7-10 for 7, 8, 9, and 10 a.m. Note that numbers (0 or 7 for Sunday) or names(the first three letters) can be used for month and day of the week fields.TABLE 18.1 FORMAT OF A crontab ENTRYMinute Hour Day Month Day of Week0-59 0-23 0-31 0-12 (or names) 0-7 (or names)You can find the format of crontab requests and some sample entries in the crontabmanual page under the /usr/man/man5 directory. You can read this manual page asfollows:# man 5 crontabYour crontab file can contain settings to start programs you want to run at regular andeven not so regular times, for example:* * * * * somecommand0,15,30,45 * * * * somecommand0 * * * * somecommandThe first example shows you want to run a program every minute. The second crontabentry runs a program every 15 minutes. The third example runs a program once an hour,on the hour.To run a program once a day at an appointed time, you can use the following:30 7 * * * somecommand30 0 * * * somecommand15 16 * * * somecommandThe first example runs at 7:30 a.m. The second example runs at 30 minutes past midnight.The third example runs at 4:15 p.m. each day. You can also run a program on aspecific day of the month or the week, for example:30 16 1 * * somecommand30 15 * * mon somecommand


Personal Productivity Tools 405The first example runs at 4:30 p.m. on the first day of each month, and the second runs at3:30 p.m. each Monday. To round out these examples, you can also specify a particularmonth, for example:30 7 25 12 * somecommandThis example runs the command at 7:30 a.m. on each Dec. 25. The commands you specifycan be system utilities or even your own shell scripts. You can use the crontab command’s-l (list) option to print your cron settings, for example:# crontab -l# DO NOT EDIT THIS FILE - edit the master and reinstall.# (/tmp/crontab.XXXXa02274 installed on Fri Dec 18 13:20:49 1998)# (Cron version -- $Id: crontab.c,v 2.13 1994/01/17 03:20:37➥vixie Exp $)0,30 * * * * /usr/local/bin/saytime0 8 * * * * /usr/local/bin/ppp on3 8 * * * * /usr/bin/fetchmail -u bball -p mypasswd staffnet.comThis shows a crontab file that speaks the time every half hour, starts a PPP connection at8 a.m. every day, and downloads the day’s mail three minutes after the PPP connectionstarts. You can remove your crontab file with the crontab command’s -r (remove)option, for example:# crontab -r18Using the crontab command is an easy way to create, run, and manage regular tasks.Even though you can create your own reminders, you might want to use a calendar forshort- or long-range planning.Creating Appointment Reminders with theX11 ical ClientYou can use Sanjay Ghemawat’s ical calendar to store appointments and reminders in apersonal calendar. The ical client, found under the /usr/X11R6/bin directory, has anumber of unique features and improvements over the cal or gcal calendar printing programs:●●●●●Custom graphical X11 interface with menus, dialogs, sliding controls, and buttonsCopy and paste, drag-and-drop notes, and appointmentsAlarms for upcoming eventsMultiple calendar viewsImport, export, and autosaving of calendar files


406 Hour 18●●●●●Group sharing of calendar filesPrinting of different calendarscron-type scheduling of appointments, notes, or remindersTo-do checklistsBuilt-in helpWhen you first run ical, the program shows the current month, set to the current day,along with a note, or appointment entry list, on the right. Start ical by using its-calendar option, followed by the name of a calendar file you want the program tocreate, like this:# ical –calendar $HOME/.calendar &This starts ical, which then creates a calendar file named .calendar in your homedirectory.Unless you define an environment variable named CALENDAR that points toan ical-calendar file, you need to specify what calendar file to use everytime you start ical (it periodically complains with an error message if it cannotopen a calendar file). To define your CALENDAR environment variable,open your .bashrc file with a text editor and add the following:export CALENDAR=$HOME/.calendarNow save the file. To use this value right away, use the bash shell’s sourcecommand, like so:source .bashrc and press Enter.The ical client also uses many of the standard X Toolkit command-line options, so youcan start the ical client as an icon, for example:# ical -iconicYou can also change geometry settings to set the initial calendar size, as follows:# ical -geometry 800x600Figure 18.2 shows the ical client.


Personal Productivity Tools 407FIGURE 18.2The ical X11 clientfeatures notices,appointments, to-dolists, and reminderalarms.Notices are created by selecting a day and then clicking on and typing in the box belowthe calendar. Appointments for the day are created by clicking on a specific time and typingin the name of the appointment. You can drag appointments anywhere during the dayto rearrange your schedule by holding down the middle mouse button (or both left andright mouse buttons if you’re using a two-button mouse).18After you have set your notice or appointment, you can also set an alarm to have theical client warn you of the upcoming event. To set a reminder alarm, first click theappointment, and then select the Item menu’s Properties item to set an alarm for anappointment. You can also just double-click the appointment to bring up the alarm dialog.You can tell ical to remind you from 1 to 15 days in advance, with up to 60 warningsthe hour before an appointment. The ical alarm notice window pops up at the previouslyselected times as a reminder.The ical client must be running in order to receive alarms. You can, however,use the ical command and its -popup command-line option in acrontab entry. If you use -popup, ical lists all the day’s appointments in awindow and then exits after you press the Okay button.


408 Hour 18Figure 18.3 shows the ical client’s alarm dialog.FIGURE 18.3The ical client’salarm dialog featuresmultiple, cascadingalarms with drag-anddropcontrols.If you select an appointment or notice, you can also make it repeat daily, weekly,monthly, or annually by selecting the pertinent Repeat menu item. When you cause anitem to repeat, it is automatically duplicated in your calendar.Appointments can also be made to-do items by clicking on the appointment and selectingthe Todo Item from ical’s Item menu. A box appears at the beginning of the text. Untilyou complete the item by clicking in the box with your left mouse button to place acheck mark, the to-do item will reappear on the next day’s list of appointments.You can list your appointments and notices by using ical’s List menu. If you want ahard copy of your calendar, you can print six different built-in calendar formats or specifya range of days. Before you print, you can also preview your calendar.The ical client is a convenient way to organize personal or group tasks. You can take alook at some of ical’s companion shell scripts and programs under the/usr/lib/ical/contrib directory to find tips and hints on how to customize ical tosuit your needs.You can find the latest version (v2.2) of ical at http://www.research.digital.com/SRC/personal/Sanjay_Ghemawat/ical/home.html.


Personal Productivity Tools 409Checking the Calendar and KeepingAppointments with emacsThe emacs text editor, more fully discussed in Hour 14, “Text Processing,” has a numberof features that can help your personal productivity or even keep you amused. You cancheck the current calendar, see a list of holidays (and more), and keep a diary withappointment reminders.If you’re using X11, you automatically run the X11 version of emacs unless you use the-nw command-line option on the command line to run emacs in your terminal window,for example:# emacs -nwAfter you start the X11 version of emacs, you can view a calendar of the previous, current,and next months by clicking Apps, then Calendar, and then 3-Month Calendar on the mainmenu. The emacs editor also offers you a Diary, Holidays, Phases of the Moon, andSunrise/Sunset times. You can also use the non-X11 emacs command, ESC-x-calendar.Press the Escape key, type an x, then type the word calendar, and press Enter. emacsdisplays a three-month calendar as shown in Figure 18.4.18FIGURE 18.4The emacs editor featuresa built-in calendarwith an assortmentof calendar tools,including a diary andappointment reminder.


410 Hour 18You can get help on using emacs’ calendar tools by typing the question mark after clickingin the calendar window. A help menu of calendar items appears. After you start thecalendar mode in emacs, a Calendar menu item will appear on the emacs menu bar.Use the Calendar menu item’s Goto sub-menu to advance the calendar forward or backward,or jump to nearly 20 different types of dates, such as Julian, Islamic, and evenMayan! The Holidays sub-menu either lists all the holidays for a range of days or monthsdisplayed by the calendar listing at the bottom of the screen or marks the holidays byhighlighting days of the calendar listing. The Moon menu lists the different phases of themoon.More than 100 different calendar commands (other than obvious menuitems) are available in emacs. In order to receive appointment reminders,emacs must be running. For more information, first try calendar’s help, andthen use the apropos command from emacs’ Help menu to get more detailedinformation.You can also use emacs to remind you of important events by using Neil Mager’s emacsappointment commands. To set appointment reminders, you must first create a .emacsfile in your home directory containing the following:(require ‘appt)(display-time)(appt-initialize)Use the File menu to save this file. Quit, and restart emacs. To create an emacs diary,start the calendar mode. Click the Apps menu, then click the Calendar item, and finallyclick the 3-Month Calendar item. After you enable the emacs calendar mode, click in thecalendar window on a specific day. Then go to the Calendar menu, click the Diary submenu,and select Insert Daily. Your scratch buffer changes to “diary,” and you find yourcursor following text containing the selected date. Make some diary entries, then save thebuffer (through the File menu), and exit and restart emacs.The emacs appointment function is written in the LISP programming language(much of emacs and many of its functions are in LISP). You can learnmore about the specifics of setting appointments by reading the sourcecode to the emacs appointment functions, like so:less /usr/lib/xemacs-19.16/lisp/calendar/appt.el


Personal Productivity Tools 411Entering AppointmentsAfter you restart emacs, you can enter appointment reminders in your diary with theemacs appt-add command. First, enter the calendar mode, and click your left mousebutton on a specific day. Next, press and release the Escape key, type an x, then typeappt-add, and press Enter. You’re asked, at the command line at the bottom of the emacswindow, for an appointment time in hours and minutes, like so:Time (hh:mm[am/pm]):Enter the time in the form of a 24-hour clock (such as 15:00) or a 12-hour clock (such as3:00 pm). After you press Enter, you’re prompted for a message, like so:Message:Type in a reminder message (such as “Wake up!”), and press Enter again.Five minutes before the appointment time, emacs beeps and then displays a new modeline, informing you of the appointment. Two minutes later, the same thing happens. Youcan also manually add reminders to your diary file, for example:8:00am Jogging with dog12:00am Lunch with Cathy15:00pm Check with car repair shop18You can save these reminders following each date in your diary files to set futureappointments. If you want to delete appointments, use the appt-delete command afterselecting a specific day. You’re asked interactively to delete various appointments fromyour diary.By using the emacs calendar mode and appointment functions, you can build a history ofyour appointments in your personal diary. Experiment with different modes, and read theemacs info files for more information.Setting Alarms with the knotes ClientYou don’t need to run large programs or word processors in order to set alarms when youuse the K Desktop Environment, or KDE. If you want to try an easy-to-use utility to setreminders or alarms during your X sessions, try the knotes client, included with theKDE utilities distribution.Click the Utilities menu on your KDE desktop’s panel and select knotes. A small Post-It-like window will appear on your desktop. Type in some text, and then right-click inthe knotes window. From the pop-up menu, scroll down, select the Operations menu, andthen click the Alarm menu item, as shown in Figure 18.5.


412 Hour 18FIGURE 18.5The knotes client,besides sportingeasy-to-usesnote-taking features,also includes alarmsand reminders.An alarm dialog box, as shown in Figure 18.6, appears. Click the up and down arrowsfor the day, month, and year to set the alarm dates. Click AM or PM, and then choose thehour and minute to set the alarm time. When finished, click Set to set the alarm.FIGURE 18.6Setting knotes alarmsis an easy task with itsalarm dialog box.SummaryThis hour introduced you to a number of personal productivity programs and X11 clientsyou can use to track your time, set appointments, and document your day.


Personal Productivity Tools 413Q&AQ My cursor was on a date in the 3-month calendar, but when I tried to insert adiary entry, emacs reported not on a date.A Try double-clicking the date in the calendar view. When a date is correctlyselected, you should see a full list of diary items in the Diary submenu.Q I tried running crontab with its –e option, but the screen cleared and thenlisted a bunch of apostrophes down the left side of the screen. What’s goingon?A By default, crontab uses the vi editor. See the vim man page for more informationon using this editor. Better yet, create and use your own EDITOR environment variableto point to the pico editor (included with the pine email program).Q I defined the EDITOR environment variable, but when I use crontab –e, theprogram exits with an error. What’s going on?A Make sure you install the pine email program from your OpenLinux CD-ROM orthat you include the full pathname to pico in your EDITOR definition. The shellreports an error and crontab also exits with an error.Exercises1. Examine this crontab entry:15 0 4 * * echo “What day is it?”When and how often will this entry run?2. Try setting several appointments in emacs. What does emacs do as the time for anappointment draws near? What happens if you set an appointment and then quitemacs?3. Try setting an alarm or appointment with the crontab command. Then try settingan alarm or appointment with the at command. Which command is better to useand why?18


HOUR 19Home OfficeManagement withStarOfficeNEW TERMThis hour shows you how to get started with StarOffice from StarDivision GmbH. This is an office-automation productivity suite, oroffice suite, available for download from http://www.stardivision.com.An office suite is a collection of integrated programs, such as a word processor,spreadsheet, and presentation graphics client that can easily share datasuch as blocks of text, tables of figures, or graphic images.A good office suite uses many of the same menu commands and has an integrated“look and feel” to help you more easily learn its componentprograms. A great office suite makes your computing experience more efficientand productive. I think you’ll like StarOffice, which is one of the latestand best office suites for OpenLinux. It is free for personal use, but if youuse the program for commercial purposes, you must pay a registration fee(see the following note).


416 Hour 19This program, combined with the power of your OpenLinux system, provides a greathome office productivity solution. You can use StarOffice to produce professionally typesetcolor documents with very little effort.In this hour, you’ll learn how to install and use StarOffice to create word processing andspreadsheet documents.This hour describes using StarOffice 5.0. You can download its 50-megabytecompressed archive for free from http://www.stardivision.com. You mustobtain a customer number and personal key by registering before you caneven begin installation of the software.Installing and Configuring StarOfficeStarOffice is not installed when you install OpenLinux. Unlike other Linux programs,you must install StarOffice through a separate procedure. This involves running an installationscript to copy the software to your OpenLinux file system.The installation is pretty painless, but you need to run X11. You do not have to be loggedin as the root operator. When you install StarOffice on a standalone OpenLinux workstation,the installation process installs StarOffice in a directory named Office50 in yourhome directory.You can also perform a network installation or an installation to supportmultiple users from the same StarOffice install. Read the 36-page StarOfficeinstallation guide. The documentation manual, install_guide.pdf, is inPortable Document Format, but you can use the xpdf client (which reads.pdf files) to read it like this (substituting path_to_the_guide with the directorypath either on CD-ROM or on your hard drive):# xpdf /path_to_the_guide/install_guide.pdfTo start the installation, use the cd command to navigate to the StarOffice setupdirectory, and use StarOffice’s setup command by typing ./setup and pressing theEnter key. The StarOffice 5.0 Installation dialog box appears. Click the Next button tostart the install. You then see a Software License Agreement dialog box. Scroll through


Home Office Management with StarOffice 417the agreement, and then click the Accept button to continue. A dialog box appears, askingyou to enter your personal information. Type in your personal information, such asname, address, phone number, and email address, and then click the Next button. You’rethen asked to enter a Media Key (or registration information if you’re installing a downloadedcopy). Type in the key or registration, and click the Next button.You can change your personal information later. See this chapter’s section,“Customizing StarOffice”.You then see a dialog box (as shown in Figure 19.1), asking you to choose a type ofinstallation.FIGURE 19.1Choose a type ofinstallation when youinstall StarOffice 5.0.The Standard installation requires nearly 140 megabytes of hard drive space, along withan additional 20 megabytes for temporary files. If you do not have this much space,choose a Minimum installation, which only requires a maximum of little more than 100megabytes during the install.19You can also choose a Custom installation, but this is not recommended. Thebest approach is to perform a minimum install and then add any missingcomponents with the Custom installation later.Click the button next to a desired type of installation. You’re then asked where you wantStarOffice to be installed, as shown in Figure 19.2.


418 Hour 19FIGURE 19.2Choose a location forthe StarOffice 5.0installation.The default is the Office50 folder in your home directory. If you choose another location,make sure you have read and write permission (see Hour 22, “Handling Files andYour File System”). After you click the Next button and confirm creation of the directory,click the Complete button. You see the install window, as shown in Figure 19.3, displayingthe progress of the install. This installation typically takes less than five minuteswith a late-model computer.FIGURE 19.3StarOffice 5.0 tracksand displays theprogress and timeremaining of theinstallation process.


Home Office Management with StarOffice 419After the software is installed, click the Complete button to exit the ./setup script.Make sure to read the text file displayed in the final installation dialog box or the fileREADME under the Office50 directory after installing StarOffice. This text file containssome important hints about installing StarOffice over a network and configuring email,fonts, and printers; it also has a license and short FAQ section about OpenLinux andStarOffice.Starting StarOfficeStarOffice 5.0 is started by the soffice script in the $HOME/Office50/bin directory. Ifyou are in your home directory, start StarOffice by using the soffice command like this:# Office50/bin/soffice &After a minute or so, the StarOffice desktop appears, as shown in Figure 19.4.Don’t forget to register your copy of StarOffice athttp://www.stardivision.com!FIGURE 19.4The StarOffice 5.0desktop featuresmenus, several toolbars,and a Work areawith icons for creatingnew documents or gettinghelp.19


420 Hour 19StarOffice performs best on an OpenLinux system with at least 32 megabytesof RAM, or system memory. However, even having twice that much memorycan’t make it start faster.Customizing StarOfficeIf you made a mistake or want to change the personal information you entered when youinstalled StarOffice, open the Tools menu, select the Options menu item, and then clickGeneral. A dialog box appears, as shown in Figure 19.5, offering you the capability tochange a number of default StarOffice features.FIGURE 19.5Set various StarOfficeoptions with theGeneral Optionsdialog box.Although not discussed in this hour, in order to use StarOffice Mail, youmust enter your name and email address in the personal information dialogbox.One of the first functions to change is to enable auto-saving of documents. Click theSave tab in the General Options dialog box. The defaults Save dialog box appears, asshown in Figure 19.6.Click the Automatic Save Every checkbox. The default time between saves is 15 minutes,but this value can be set from 1 to 60 minutes. If you want a backup copy made of aworking document, click the Always Create Backup Copy checkbox. Also, note that thedefault number of the Undo scroll box levels is 20. You can set StarOffice to use as manyas 100 levels of undo.


Home Office Management with StarOffice 421FIGURE 19.6Set automatic savingdefaults to ensure documentsare routinelysaved duringStarOffice sessions.If you select Automatic Save Every, uncheck the Prompt to Save checkbox(shown in Figure 19.6) to avoid having to respond to a dialog box each timeStarOffice tries to save your current document.Other tabs in the General Options dialog box offer settings for spell checking, colors,toolbar button sizes, printer warnings, and languages.Installing a Printer for StarOfficeFortunately, if you configured your printer to work with OpenLinux (using the lisacommand; see Hour 15, “Preparing Documents”), you don’t have to change printer settingsfor StarOffice. If you do need to make changes or want to set up StarOffice to use adifferent printer than the default generic PostScript printer, click the Printer-Setup icon inStarOffice’s work area.19Using StarOfficeThe StarOffice desktop, or main window, is your entry and launch pad to a number ofStarOffice programs. This office suite is a large, capable and complex program with a lotof interface elements. To enlarge the desktop window, double-click the desktop window’stitle bar (or click the maximize window button, if available).If you use KDE and need even more room for the StarOffice desktop, usethe KDE desktop panel’s minimize button, or configure the panel to hideautomatically (using the panel’s configuration dialog box). To get theabsolute most use of your screen real estate, press Shift+Ctrl+I to zoom thecurrent StarOffice work area to full screen. See Table 19.1 for other keyboardcommands.


422 Hour 19The StarOffice desktop (shown in Figure 19.4) consists of several elements, such as amenu bar with the File, Edit, View, Tools, and other menus. Below the menu bar is thefunction bar, a toolbar with buttons and other controls. If you click the right-pointing trianglein the upper-left corner of the Work area, an open area on the left side of the desktopappears (and the triangle now points to the left). This button controls the display ofthe Explorer, which provides quick access to different StarOffice folders (directories),such as the Gallery of artwork or sample documents folder.The Gallery is installed during a Standard installation, not a minimal installation.If you performed a minimum install, restart the setup script, and thenchoose a Custom installation to install the artwork.To see a list of installed artwork, open the Explorer, and then click on the small plus sign(+) in front of the Gallery icon in the Explorer. A list of graphics categories drops down.Double-click a category, such as Flags, and the first several files appear in the Beamer(as shown in Figure 19.7).FIGURE 19.7The Beamer in theStarOffice desktop displaysthe graphics orfiles in a directory.


Home Office Management with StarOffice 423The Beamer is used to view the contents of directories or graphics files listed in theExplorer window (and also for placing graphics into documents; see the following section“Creating Documents with StarWriter”). Note that the Beamer shows the currentlyselected file’s pathname. Click the minus sign(-) in front of the Gallery icon in theExplorer to close the Gallery and the Beamer.The work area is the largest part of the StarOffice desktop. It contains icons that representlinks to different documents or help files. Your first step is to create a project folderto organize your work.Right-click a blank area of the work area. A pop-up menu appears. Select the New menuitem, and then click Folder. The folder appears in the work area. Type a name for thefolder, such as MyProjects. Hold down your left mouse button on the folder, drag thefolder to the Explorer window, and drop it—the folder disappears from the work areaand is now in the Explorer.Creating Documents with StarWriterStarWriter is the word processor portion of the StarOffice office suite. This program isintegrated into the StarOffice desktop and can share information with other parts ofStarOffice, such as StarCalc (see the section “Calculating with StarCalc,” later in thishour). StarWriter has all the features of a modern word processor, which include the following:●●●●●●●●●●Automatic spelling checking and correctionBuilding of tables, footnotes, and indexesComplete search and replace capabilities, including stylesComplete style controlsComplex text and font control, including kerning and spacingCut, copy, paste, and draggable text selectionsDocument-creation wizards (AutoPilot)Drag-and-drop of StarOffice document items (such as data or graphics)Drawing tools, fields, and graphic insertionsHyphenation controls● Import and export of different file formats (see Table 19.2)19●●●Insertion of hyperlinksMacro supportMultiple views, including layout and outline


424 Hour 19●●●●Multiple zoom levels for enlargement/reductionRevision controlTemplates for documents and layoutsThesaurus supportStart by creating a StarWriter document in your new project folder. Double-click yourproject folder in the Explorer, and the work area clears.There are several ways to create a new document:●●●●Click the Start button in the lower left corner of the desktop, and then click theText Document menu item.Open the File menu, select the New item, and then click the Document submenuitem.Press Ctrl+N and select a document type from a list of 70 different template documents.Open the File menu, select AutoPilot, and then click Letter, Fax, Agenda, or MemoFor now, double-click your project folder in the Explorer, hide the Explorer, and thenright-click in your project’s work area. Select New from the pop-up menu, clickDocuments, and then click the Text Document menu item. A StarWriter text documentwindow appears in the work area, as shown in Figure 19.8.FIGURE 19.8The current StarWriterdocument appears inthe StarOffice workarea.


Home Office Management with StarOffice 425Note that StarOffice has a taskbar similar to KDE’s at the bottom of the desktop window.To quickly navigate back to the initial desktop, click its button (between the Start buttonand the MyProjects folder’s button) in the taskbar. For now, click in the blank page, andtype a paragraph or so.StarWriter’s document work area has a horizontal rule and formatting toolbarabove it and a vertical toolbar to the left of it. The ruler is used to setmargins and tab stops, whereas the formatting toolbar is used to set fontattributes and justification. The vertical toolbar can be used for a number ofactions, such as table, field, or graphics insertions, spell checking, or searchand replace procedures.Double-click to select a word, or triple-click to select a line. Press Shift+End to select tothe end of a line. To select multiple lines, click an insertion point, and then drag up ordown to highlight the desired amount of text. If you hold down your mouse button on aselected word, line, or block of text, you can drag the selection to another part of yourdocument.To format text, select the appropriate toolbar icon, or right-click the text and select attributesfrom a pop-up menu. Character formatting from the Format menu can be used toaccess more complex controls, such as font effects, style, size, or color.StarWriter has many different keyboard commands you can use while creating documents.See Table 19.1 for a list of common commands (also shared by StarCalc) andtheir actions.19TABLE 19.1 STARWRITER COMMON KEYBOARD COMMANDSActionKeyboard CommandAbort menu operationEscCheck spellingF7CopyCtrl+CCutCtrl+XEdit menuAlt+EFile menuAlt+FFormat menuAlt+OFunction NavigatorF5Help menuAlt+Hcontinues


426 Hour 19TABLE 19.1 CONTINUEDActionInsert menuNew fileOpen filePastePrintQuitSearch & ReplaceSelect AllThesaurusToggle full-screen modeTools menuUndoView menuWindow menuKeyboard CommandAlt+ICtrl+NCtrl+OCtrl+VCtrl+PCtrl+QCtrl+FCtrl+ACtrl+F7Ctrl+Shift+IAlt+TCtrl+ZAlt+VAlt+WSpellchecking and Saving StarWriter DocumentsChecking the spelling of documents is an important task. Misspelled words can have adetrimental effect on your professional image and even your career. Fortunately,StarOffice comes with a built-in spelling checker that not only works with StarWriterdocuments, but any StarOffice document, including graphic images with embedded text!Open the Tools menu, select Spelling, and then click the Check menu item to start thespelling checker. If you don’t want to use a menu or your mouse, press F7.The Spelling dialog box appears, as shown in Figure 19.9.The spelling checker highlights and displays the first misspelled word found after thecurrent insertion point in your document. Continue through the document, and click theappropriate button to ignore, replace, or globally ignore the word in your document.Correctly spelled but unrecognized words can be added to your personal dictionary byclicking the Add button. When you finish, click the Close button.


Home Office Management with StarOffice 427FIGURE 19.9StarOffice spell checksall document types andnot just StarWriterdocuments.You can also use automatic spell checking while you work. Enable Auto Spellcheck tohave StarWriter automatically underline any misspelled or suspect words. Open the Toolsmenu, select Spelling, and then click Auto Spellcheck. You can also click the small ABCicon underlined in red on the vertical toolbar to the left of the work area to enable automaticchecking.To set StarOffice and its components to always use automatic spell checking,open the Tools menu. Select Options, and then click the General menu item.In the General Options dialog box, click the Linguistic tab, and check theCheck Spelling as You Type check box. Press the OK button to save yourchanges.To save your document, press Ctrl+S, or open the File menu and click the Close menuitem. StarWriter can open (import) and save (export) a variety of file formats, as shownin Table 19.2.TABLE 19.2NameSTARWRITER 5.0 FILE FORMATSTypeMSWord 6.0/95, 97 Microsoft Word for Windows 6.0, 95, 97Rich Text FormatRTFStarWriter 1.0 (read-only), 2.0, 3.0, 4.0, 5.0 StarOfficeStarWriter HTMLHypertext Markup LanguageText (ANSI, DOS, Mac)Text format19


428 Hour 19FIGURE 19.10StarWriter can readand save documents ina number of formats.To save your document in a different format, click the drop-down File Type menu (asshown in Figure 19.10), and then click the OK button.Calculating with StarCalcStarCalc is the spreadsheet component of StarOffice. Like StarWriter, this program integrateswith the StarOffice desktop and can share information, such as tables of data orgraphics, with other StarOffice components. For example, you can create a spreadsheetand then paste the data in a StarWriter document.When you work with StarCalc, you quickly see that it’s easy to create even complexspreadsheets. As you probably know from Hour 17, “Learning Math and FinancialTools,” spreadsheets are handy for storing, tracking, visualizing, and forecasting data. Inthis section you learn the basics of creating and saving a StarCalc spreadsheet.There are several ways to create a StarCalc spreadsheet:●●●●Double-click the New Spreadsheet icon in the StarOffice desktop’s work area.Open the File menu, select New, and then click Spreadsheet.Click the Start menu, and then click the Spreadsheet menu item.Type Ctrl+N, and then select a spreadsheet type from a template dialog box.For now, double-click your project folder in the Explorer.You can also click the drop-down menu on the StarOffice toolbar (below themenu bar), and then click a previously visited document or folder.


Home Office Management with StarOffice 429Next, right-click your mouse in a blank spot in your work area. From the pop-up menu,select the New menu, select Documents, and then click the Spreadsheet menu item. Thework area clears, and you see a familiar blank spreadsheet grid with row and columnheaders (as shown in Figure 19.11).Note that the toolbar above the work area includes a cell selection and dataentry field.Enter some data into columns and rows by clicking an insertion point and typing a number.Press the Tab key to enter the data and move right. Press the Enter key to enter thedata and move down.FIGURE 19.11StarCalc is a comprehensiveand capablespreadsheet calculatorthat can share dataand graphics withother StarOfficecomponents.19Numbers and text can be formatted like those in a StarWriter document. SingleNEW TERMcells are selected by a mouse click. Multiple cells are selected by selecting a celland then dragging with the left mouse button held down. An ingenious feature is a discontiguousselection, where multiple selections are made without the selected regionsadjoining. You can use discontiguous selection to format two or more areas of yourspreadsheet at the same time. Click the first cell, and then drag to select the first area.Hold down the Ctrl key and click and drag to select another area (see Figure 19.12). Youcan now format the cells as needed.


430 Hour 19FIGURE 19.12StarCalc supportsadvanced formattingfeatures, such as discontiguousselection.To perform quick totals of your data, click in the bottom cell of a column of numbers,and then click the Sum button (the Σ) next to the equal(=) sign in the data entry fieldabove your work area. An X and a check mark appear next to the data entry field, whichhas the SUM formula inserted. Click the check mark to accept the entry, or click the Xbutton to cancel.When you finish, press Ctrl+S, or open the File menu and click Save to save your work.StarCalc can import and export a variety of spreadsheet document formats, as shown inTable 19.3.TABLE 19.3 STARCALC SUPPORTED SPREADSHEET FORMATSTypeNamedBaseDbase databaseDIFDocument Interchange FormatHTMLHypertext Markup LanguageMSExcel 5.0/95, 97 Microsoft Excel for Windows 5.0, 95, 97StarCalc 3.0, 4.0, 5.0StarCalcSYLKSymbolic Link formatText, CSVText, cell values


Home Office Management with StarOffice 431StarCalc supports all the keyboard commands listed in Table 19.1. You can also selectand move blocks of highlighted data around the sheet using the same drag-and-dropmechanism as with StarWriter text.Graphing with StarCalcStarCalc can easily create complex graphs of your spreadsheet’s data. The first step is toclick and drag to select the desired spreadsheet data.To start drawing a graph, click the Insert Object button (the third button down) on thevertical toolbar to the left of your chart’s work area. A small toolbar appears. Click thetiny chart icon, and your cursor turns into a plus sign (+) with a tiny chart. Click anddrag on a blank area of your spreadsheet to set the initial size of your graph. When yourelease your left mouse button, the AutoFormat Chart dialog box appears, as shown inFigure 19.13.You can also open the Insert menu and click the Chart menu item to startthe AutoFormat Chart dialog box.FIGURE 19.13StarCalc’s AutoFormatChart dialog box is aneasy way to start creatingchart graphics ofyour spreadsheet’sdata.19To build your chart, select any desired options and click the Next button. Continuethrough the AutoFormat dialog boxes until you arrive at a final dialog box with a buttonlabeled Create (as shown in Figure 19.14).


432 Hour 19FIGURE 19.14A single click of a buttoncreates a chartgraphic of yourspreadsheet’s data.Your chart appears in the previously selected area of your spreadsheet (as shown inFigure 19.15). You can then move, resize, or edit the chart. If you click the chart and thenpress Ctrl+C, you can paste the chart into another StarCalc or StarWriter document.FIGURE 19.15StarCalc can createprofessional chartgraphics of yourspreadsheet’s data.SummaryThis hour introduced you to StarOffice for OpenLinux. This office suite provides a professionalset of programs you can use to be more productive. You learned how to installStarOffice, and then start StarWriter and StarCalc to create great-looking documents.StarOffice comes with several other programs, such as a database, graphics, and presentationpackage. Read the StarOffice user’s guide to learn more about this great set of programsfrom Star Division.


Home Office Management with StarOffice 433Q&AQ I started installing StarOffice but got an error!A Carefully read any error messages, and then look at the StarOffice installationguide. The installation script requires X11! Upon a serious error, the StarOfficeinstallation aborts and returns you to your shell prompt. It is possible to get aninstallation error if you repeatedly choose an installation type, cancel, and thenreattempt an installation without quitting the installation script first. Try reinstallingagain.Q I’ve installed StarOffice from CD-ROM, but how do I eject my CD-ROM?A Use the umount command. See Hour 22, “Handling Files and Your File System.”Q Where are documents saved when I use StarOffice?A Look under the Office50/explorer directory for any folders you created.Q I want to learn more about using StarOffice. What other documentation isincluded?A Look for the file user_guide.pdf included with the StarOffice distribution. Then,use the xpdf client to read or print the document.Q Why doesn’t my Backspace key work?A Check to see if you disabled the XKEYBOARD extension in your XF86Config file (seeHour 3, “Post-Installation Issues”). You can also try the xmodmap command, likethis:# xmodmap -e “keycode 22 = BackSpace”Exercises1. Create a StarWriter document, and then type multiple paragraphs. Triple-click aline of text, hold your left mouse button down on the highlighted text, and dragdown to the end of your document. Release your mouse button. What happens?2. Leave your StarWriter document open. Click the Desktop button in the lower leftcorner of the StarOffice desktop. Double-click the New Spreadsheet icon in theStarOffice work area. Create a spreadsheet, enter some data, and create a graphic.When the graphic appears, click the graphic, and then press Ctrl+C. Select theWindow menu, and click your StarWriter document. Click an insertion point, andpress Ctrl+V. What happens?3. Highlight some data in your StarCalc spreadsheet. Press Ctrl+C. Navigate to yourStarWriter document, click an insertion point, and press Ctrl+V. What happens?19


HOUR 20Relaxation and PlayingLinux GamesNow it’s time to sit back, relax, and have some fun. Chances are that youskipped the rest of the book and are reading this chapter first. Well, that’sokay because we all know the real reason we bought our computers, right?To zap hordes of alien invaders streaming across the screen!In this hour you’ll learn how to play music CDs with the amazing kcsdclient. You’ll also learn about some of the more than 70 games included withOpenLinux.Playing Music CDs with the kscd andxplaycd ClientsUsing your computer as a stereo system might seem a bit extravagant, butit’s nice to be able to listen to music while you work. Besides, playing musicCDs with OpenLinux is not only easy; it’s convenient and fun!If your sound card works with Linux, great! You can start playing music


436 Hour 20CDs right away. You can find several music CD player clients installed with OpenLinuxthat you can use during your X sessions.One of the best CD players is the kscd client that comes with KDE. This program notonly plays CDs, but if you have an active Internet connection, kscd goes out in theInternet, queries a remote computer with your music CD’s serial number, and retrievesthe name of your music CD, the artist’s name, the number of tracks, and the name ofeach track. You can save this information in a database on your hard drive.Before you begin, use the chmod command to set the permissions of your CD-ROM sothat anyone can read your CD, like this:# su -c “chmod 664 /dev/cdrom”You don’t have to use KDE to use the kcsd player. However, you must haveKDE installed on your system.Start your Internet connection, and then start kcsd. If you’re using KDE, click theApplication Starter button on your desktop’s panel, scroll up to Multimedia, and click theCD Player menu item. If you’re using another window manager, type kcsd & at the commandline and press Enter. The kcsd dialog box appears as shown in Figure 20.1.The kscd player automatically goes out in the Internet and tries to locate your CD’s artistand title. If you need to configure kcsd, such as what Internet database to query or colorsand fonts to use in its display, click the Configure kscd button (the one with the hammerand screwdriver).FIGURE 20.1The kcsd audio CDplayer connects toInternet databases toshow you informationabout your audio CD.


Relaxation and Playing Linux Games 437The Configuration dialog box appears, as shown in Figure 20.2. Note that the EnableRemote CDDB (CD database) button is selected. If kscd has trouble connecting to a particularremote Internet database, click a different CDDB server in the CDDB server list.Deselect the Enable Remote CDDB button if you don’t want kscd to use the Internet.FIGURE 20.2The kscdConfiguration dialogbox is used for communicationsand displaysettings.Use the CDDB Base Directory field to specify the pathname to your system’s audio CDdatabase. As you use kscd, you can save each CD’s information in this database. Toaccess kscd’s database controls, click the CDDB dialog box button in kscd’s main window(immediately to the right of the player’s power button).The CD Database Editor dialog box appears, as shown in Figure 20.3. kscd fills outmost of the information about your CD from information retrieved by the remoteInternet server (this happens almost instantaneously, as only a small amount of informationis sent and received). Click the Save button, and you’re asked to pick one of 10 differentcategories of music.20


438 Hour 20FIGURE 20.3The kscd databasedialog box is usedto save informationabout your audio foruse the next time youplay the CD.Playing Music with the xplaycd ClientThe xplaycd client, by Olav Woelfelschneider, is another client you can use to playmusic CDs. The program appears in a small window with the standard music CD controls,along with horizontal stereo volume bars and a list of buttons representing thetracks on the CD. You can raise or lower your music’s volume by clicking your leftmouse button ahead of or behind the horizontal bars.Start this player from the command line of a terminal window, like this:# xplaycd&The player appears, as shown in Figure 20.4.One great feature of this program is the capability to reorder tracks and even play a trackmultiple times. By clicking a track number and dragging, you can rearrange the playsequence of the tracks on your CD. To play a track multiple times, click a track numberwith your mouse’s middle button and drag the track along the CD track sequence. Whenyou release your mouse button, the track number is duplicated.FIGURE 20.4The xplaycd playerfeatures draggabletrack numbers toreorder or repeat playingof music tracks.


Relaxation and Playing Linux Games 439Not using X? Don’t worry—you can play music CDs with Sariel Har-Peled’s cdp command,found under the /usr/bin directory. This command is a text mode program and isstarted from the command line of your console, like this:# cdpWhen cdp starts, you see a list of the tracks on your CD. Turn on the NumLock key ofyour keyboard to control how to play your CD. Table 20.1 lists the controls for playingCDs from your keyboard’s keypad.TABLE 20.1 THE cdp COMMAND KEYPAD CONTROLSActionKeypad KeySoft exit (music continues) 0Help .Back 15 seconds 1Hard abort (eject CD) 2Forward 15 seconds 3Previous track 4Replay CD 5Next track 6Stop 7Toggle pause/resume 8Play 9The cdp command has a number of command-line options. A symbolic link, calledcdplay, can be used to play music without cdp’s interactive screen. Tell cdplay to startplaying music at a certain track with the play option, followed by a track number, likethis:# cdplay play 320This command line starts the cdp program, and your music CD starts playing from thethird track.Games for the ConsoleIf you don’t use X11, you also can have fun at the console because you can find anassortment of nearly 60 classic games you can play. Look under the /usr/gamesdirectory.


440 Hour 20One of the classics is the adventure game. This features an interactive text screen whereyou enter simple commands to try to delve into a cave, retrieve treasures, and escape inone piece. Start the game by typing the full pathname to the program, like this:# /usr/games/adventureWelcome to Adventure!! Would you like instructions?yesSomewhere nearby is Colossal Cave, where others have found fortunes intreasure and gold, though it is rumored that some who enter are neverseen again. Magic is said to work in the cave. I will be your eyesand hands. Direct me with commands of 1 or 2 words. I should warnyou that I look at only the first five letters of each word, so you’llhave to enter “northeast” as “ne” to distinguish it from “north”.(Should you get stuck, type “help” for some general hints. Forinformation on how to end your adventure, etc., type “info”.)- - -This program was originally developed by Will Crowther. Most of thefeatures of the current program were added by Don Woods. Addresscomplaints about the UNIX version to Jim Gillogly (jim@rand.org).You are standing at the end of a road before a small brick building.Around you is a forest. A small stream flows out of the building anddown a gully.Enter commands such as inven, look, go west (or n, w, s, e, up, or down). Type quit toexit the game.Want the challenge of a good chess game? Try the gnuchess program, which plays anextremely strong game of chess. You can find several versions of this game installed onyour system. The gnuchess version uses cursor addressing to provide a basic graphic display.The gnuchessr version scrolls each board after successive moves and uses reversevideo and cursor addressing for a fancier display.


Relaxation and Playing Linux Games 441Moves are entered by specifying the column and row as a letter and number, as in thefollowing example:# gnuchessEnter [moves] minutes[:sec] [increment][+]:ComputerGNU Chess+——+——+——+——+——+——+——+——+8 | *R | *N | *B | *Q | *K | *B | *N | *R |+——+——+——+——+——+——+——+——+ Playing without hashfile7 | *P | *P | *P | *P | *P | *P | *P | *P |+——+——+——+——+——+——+——+——+6 | | | | | | | | |+——+——+——+——+——+——+——+——+5 | | | | | | | | |+——+——+——+——+——+——+——+——+4 | | | | | | | | |+——+——+——+——+——+——+——+——+ 1: White3 | | | | | | | | |+——+——+——+——+——+——+——+——+2 | P | P | P | P | P | P | P | P |+——+——+——+——+——+——+——+——+1 | R | N | B | Q | K | B | N | R | Your move is?+——+——+——+——+——+——+——+——+a b c d e f g hHumanIf you don’t want to specify a timer, just press Enter after starting the game. To move thepawn up two squares from the lower rank, enter e2e4, and press the Enter key. The computerthen makes its move, and new piece positions are updated on your display. Thegnuchess program has more than 23 command-line options and features display playmodes, hints, and timed games. For more information, see the gnuchess manual page.Playing emacs GamesThe venerable emacs editor (discussed in Hour 14, “Text Processing”) not only edits text,reads mail, and handles your appointments, but also comes with 18 wacky games andmodes that you can use to pass the time, such as doctor, dunnet, psychoanalyzepinhead,and yow.20To play dunnet, a text adventure, use emacs from the command line:# emacs -batch -l dunnetDead endYou are at a dead end of a dirt road. The road goes to the east.In the distance you can see that it will eventually fork off. Thetrees here are very tall royal palms, and they are spaced equidistantfrom each other.


442 Hour 20There is a shovel here.>This command line starts the game. At the > prompt, enter commands such asinventory, look, or go east. To end the adventure, enter the word quit.Games for the X Window SystemIn this section you’ll be introduced to several games for X11. There are more than twodozen you can play, but rather than discussing them all, the following pages highlightseveral of the best games for strategy and action.If you like playing board games, you’re in luck! There are several good board games forthe X Window System on this book’s CD-ROM. Want more action? Try some of thevideo arcade games—you’re sure to find some you like. The following is a list of just afew of those that are included:●●●●●●●●●●●abuse—futuristic combat game for Xacm—aerial combat simulator for Xkoules—smash balls into the wall game for Xparadise—a networked combat gamescavenger—Lode-runner for X11xchomp—classic Pac-Man-like gamexdemineuer—minesweep-type gamexjewel, xtrojka, xbl—Tetris-like gamesxlander—a lunar lander gamexpilot—networked combat gamexpuzzles—a series of puzzle games for X11Playing Chess with the xboard ClientChess is a classic game, and one of the major challenges you can face is playing chessagainst your computer. To play chess in X11, use the xboard client. This program usesthe GNU chess engine and can play chess over the Internet or through electronic mail.The xboard client (shown in Figure 20.5) recognizes many X11 Toolkit options, such asgeometry settings, and has 54 different command-line options. If you have a displaysmaller than 1024×768 pixels, use the -size or -boardSize small command-line optionto fit the board on your screen, like this:# xboard -size small &


Relaxation and Playing Linux Games 443FIGURE 20.5The xboard X11 clientplays chess on yourdisplay, over theInternet, or throughemail.This command line starts xboard using smaller chess pieces. For more details aboutusing xboard, see the xboard and gnuchess manual pages.Playing X11 SolitaireIf you enjoy playing card solitaire games, you’ll like the xpat2 X11 client. This program(shown in Figure 20.6) features 14 different solitaire games with scoring, hints, built-inhelp, and sound. Start the game from the command line of a terminal window, like this:# xpat2 &FIGURE 20.6The xpat2 solitairegame for X11 features14 different cardgames.20


444 Hour 20The xpat2 game, created by Heiko Eissfeldt and Michael Bischoff, is found under the/usr/X11R6/bin directory. For more details, read the xpat2 manual page.Playing Backgammon for X11For backgammon fanatics, the xgammon client (shown in Figure 20.7) produces hours offun and practice. This game, by Lambert Klasen and Detlef Steuer, requires the XWindow System and runs comfortably on an 800×600 pixel display.Start xgammon from the command line of a terminal window, like this:# xgammon&FIGURE 20.7The xgammon game forX11 features severaltypes of play, such ascomputer againsthuman, and provides achallenging game.The xgammon client has 21 different command-line options. For an interesting variation,try watching your computer play itself:# xgammon -g cvc &This starts the xgammon game so you can watch the action. You also can create your ownchallenging games by editing the board and placing backgammon stones in differentpositions before play. For details about xgammon, read its manual page.Playing Galaga for X11Video action arcade games can be a lot of fun, especially if they have great graphics andsound. If you like shoot-em-ups, you’ll love the xgal game by Joe Rumsey. This X11client features a simple keyboard interface.The xgal game (shown in Figure 20.8) has six different command-line options, but youcan start the program without any at a terminal window by typing the following:# xgal &


Relaxation and Playing Linux Games 445FIGURE 20.8The xgal game forX11 features spiffyarcade action andgood sound.To start playing, press your spacebar. Use the right and left cursor keys to move yourship across the screen, and use your Spacebar to fire.Breakout the Fun with the X11 Client xboingxboing, by Justin C. Kibell, is a fast-paced, arcade-quality paddle and ball game for theX Window System. This game sports great graphics and sound and provides hours offun. You can start the xboing program from the command line of a terminal window. Youneed a display of at least 1024×768 pixels to play.By default, xboing does not use sound, so if you want to hear sounds when you play,you must use the -sound command-line option. Set the speed of the ball’s action afterplaying a game to fine-tune the challenge by using the -speed option:# xboing -sound -speed 7This command line starts xboing with sound enabled and a very fast ball speed. Anothergood option to use is -grab, which keeps your cursor within the xboing X11 window,preventing you from accidentally activating other windows and missing any action. Formore details about playing this game, see the xboing manual page.20Playing Quake for X WindowsQuake, by id Software, is a follow-up game to Doom, one of the most popular arcadegames to hit the personal computer scene in recent years. You can’t find a copy on thisbook’s CD-ROM, but you can download Quake in a version for Linux and X11.


446 Hour 20You need to download the quake106.zip shareware resource file (unless youown a copy of Quake) fromftp://www.cdrom.com/pub/idgames/idstuff/quake/, and thequake.x11-1.0-i386-unknown-linux2.0.tar.gz file fromhttp://www.mikrus.pw.edu.pl/lds/quake/files.html.Follow the installation instructions to install this version of Quake forOpenLinux. Quake II fans and Linux users interested in setting up a Quakeserver for Internet or network games can check out the xqf Quake serverbrowser and launcher. Browse to http://www.linuxgames.com/xqf/.Navigate to the directory where you installed quake, and start Quake from the commandline, like this:# quake.x11The game starts playing in demo mode (Figure 20.9 shows some of the action). Thewindow can be resized with your mouse or dragged around the desktop.FIGURE 20.9Don’t lose your headwhile playing Quakefor Linux!


Relaxation and Playing Linux Games 447If you have the shareware or commercial Quake CD inserted in your computer,you get the Quake soundtrack. If you have any music CD inserted,different tracks play as you play the game.SummaryThis hour introduced you to just a fraction of the games available for OpenLinux and theX Window System. You’re sure to find some favorites installed on your system.Q&AQ How can I find out how many games are installed with OpenLinux?A Try using the apropos command, like this:man aproposQ I want to record sound from my audio CD to a disk file? How can I do this?A Try the cdda2wav command.Q I want to convert sounds from another operating system and use them withOpenLinux. What conversion tools are included?A Try the sox command.Q I want to play .mp3 files. What program should I use?A Try the mpg123 command.Q I like simulation games. Is one included with OpenLinux?A Yes. A very good city-building simulator is xlincity. You can also find the X11client Freeciv, a free Civilization clone (which uses the civserver, civclient,and civ commands for play).Q I know there are more games than that installed. Is there a better way?A Try using the kpackage client included with KDE, and then look under theRecreation folder.Q Speaking of KDE—how many games are included with KDE?A You can find nearly a dozen at the time of this writing. Of course, you can alwayscheck http://www.kde.org to find the latest selection.20


448 Hour 20Exercises1. Download and install the Quake for X11 programs for OpenLinux. Are there anyother Web sites supporting Quake and Linux? How do you find out?2. Use the xmixer command to experiment with the sound input and output controlsof your computer’s sound system. Try recording some sounds with the soundrecording script in Hour 3.3. From the command line of a terminal window, start the xteddy client. Whathappens?


PART VAdministering YourSystemHour21 Basic System Administration22 Handling Files and Your File System23 Backing Up and Restoring Your System24 Using Scheduling to Automate SystemManagement


HOUR 21Basic SystemAdministrationThis hour introduces you to the basics of system administration. You’ll learnhow to use the su command, how to get information about your system, howto manage other users, and how to use file tools to keep your OpenLinuxsystem running in top form. Although much of what’s discussed in this hourconsists of common-sense guidelines, you’ll also get some valuable tips onsqueezing the best performance out of Linux. You’ll use this knowledge inthe next three hours, which cover handling files, archiving, and scheduling.Even if you’re the only person who uses your computer, you should stilllearn basic system administration skills, for at least some of the followingreasons:●●●●●To back up or restore your system, or at the least, important filesTo conserve disk spaceTo install new software or upgrade your Linux systemTo teach someone else about OpenLinux, such as a coworker, friend,spouse, or childTo troubleshoot problems


452 Hour 21Although some of the tasks described in this chapter require root permission (you mustrun a command as the root operator), you should not always log in and use OpenLinuxas the root operator. Here’s a good reason: Always running as root can be dangerousbecause you have access to all files on the system and can delete, move, or copy any fileat will. You can wipe out your OpenLinux system (remember the warning in Hour 5,“Manipulation and Searching Commands,” about the rm command) and any othermounted filesystem with this command:# rm -fr /*If you run Linux from your own account, this problem won’t happen because rm willcomplain with “Permission denied” and quit. What if you’re logged in under youraccount but need to do things to your system as the root operator? This is where thesu command comes into play.Running as the root Operator with thesu CommandThe su command, or substitute user command, allows you to run a command as any useron your system. Found in the /bin directory, su has seven different command-lineoptions. Several of the most common are covered here. Although you’ll most likely usesu to become root, this command can be handy if you want to become another user andtroubleshoot problems with email or printing. Using the su command is easy; for example,to become the root operator, use su like so:# su -Password:su: incorrect passwordBy default, the su command will allow you to become the root operator if you call itwithout a username. (Use the hyphen command-line option to make sure you run as theroot operator with root’s environment variables.) You’ll be asked to enter a password, andsu will complain and quit if you enter the wrong one. If you enter the right password,you’ll be logged in as root. To return to your shell, use your shell’s exit command:$ su -Password:# whoamiroot# exitexit$ whoamibball


Basic System Administration 453This example, using the whoami command, shows that after you execute the exitcommand, you’re returned to your normal user status. Another handy feature of thesu command is the -s command-line option to run a different shell. If you want to try adifferent shell without using the chsh command to permanently change your shell, youcan use the following:$ printenv | fgrep SHELLSHELL=/bin/bash$ su -s /bin/kshPassword:# printenv | fgrep SHELLSHELL=/bin/ksh# exit$This example (showing the output of the printenv command piped through the fgrepcommand) shows that although the default shell is bash, the su command allows you totemporarily use the pdksh, or public domain Korn shell. Unless you specify your ownusername, you’ll run the new shell as the root operator. A better approach is$ su -s /bin/ksh yourusernameFinally, you can also use the su command to execute a single command when you usethe -c command-line option. This can be handy to perform tasks only permitted for theroot operator, such as mounting a flash memory card:# su -c “mount -t vfat /dev/hde1 /mnt/flash”Password:This command line mounts the /dev/hde1 device, a SunDisk flash card with a VFAT(long-filename) filesystem, at the /mnt/flash directory mount point. If you need to temporarilymount or unmount diskettes, CD-ROMs, Zip disks, or other devices, you’ll findthis a convenient approach. Hour 22, “Handling Files and Your File System,” coversmounting and unmounting other filesystems.If you’re using Linux in the console mode (not running X11), you can use the consolekeys (Alt+F1 and so on) to run a virtual console as the root operator to do root operatortasks. This is a bad convenience, however, because you might be tempted to run as rootall the time. At least using the su command makes you think about why you’re runningas root. Be careful!The next section introduces you to tools you can use to determine how your system isworking.21


454 Hour 21Getting Disk Space InformationWhen you installed Linux, you installed your system onto a partition, designated by aspecific device, such as /dev/hda1, /dev/sdb1, and so on. I hope you made the partitionlarge enough to accommodate your present and future needs. How do you check to seehow much room you have left on disk or for that matter, how many disks you have?Although Linux can support partition sizes up to 4 terabytes and maximum file sizes upto 2 gigabytes, not many of us are wealthy enough to own, or even need, that much storage.Even though disk storage is getting cheaper, it is still at a premium when you have alot of software installed or need the work space.Getting Filesystem Statistics with the df CommandThe df (free disk space) command, found in the /bin directory, will gather and summarizesome important statistics about all currently mounted filesystems. The df commandis easy to use:# dfFilesystem1024-blocks Used Available Capacity Mounted on/dev/hda3 497699 443871 28124 94% //dev/hda1 509856 469632 40224 92% /mnt/dos/dev/hdc1 3868 2596 1272 67% /mnt/flash/dev/hdb 644324 644324 0 100% /mnt/cdromThis output shows four different filesystems on three different devices mounted underLinux. The first is the root partition at the / directory on /dev/hda3; the second is a DOSpartition under /mnt/dos on /dev/hda1; the third is a flashcard under /mnt/flash on/dev/hdc1; and the fourth is a CD-ROM, mounted under /mnt/cdrom on /dev/hdb. Thedf command also lists the size of the storage device, how much has been used, howmuch is available, and the current capacity of the device. Notice that the CD-ROM hasno space left. This is because it is mounted read-only, meaning you can’t save or deletefiles on this device. The command shown in the next example will let you know.One handy way to find out about the different filesystems you have mounted is to use themount command. This command is usually used during startup by the root operator tomount and unmount filesystems, but any user can use mount to show what type offilesystems are in use and how the filesystems are mounted:# mount/dev/hda3 on / type ext2 (rw)/dev/hda1 on /mnt/dos type msdos (rw)none on /proc type proc (rw)/dev/hdc1 on /mnt/flash type msdos (rw)/dev/hdb on /mnt/cdrom type iso9660 (ro)


Basic System Administration 455This shows that your root partition, on the / directory, is a Linux ext2 filesystemmounted read-write, whereas /mnt/dos and /mnt/flash contain DOS partitions, alsoread-write. (The /proc filesystem is a special directory Linux uses for process reporting,such as running applications, system state, and so on.) Finally, mount reports that yourCD-ROM is mounted as a read-only iso9660 filesystem.You can use this information from mount to get specific information with the df command,by using the df command’s -t, or filesystem, option:# df -t ext2Filesystem1024-blocks Used Available Capacity Mounted on/dev/hda3 497699 443873 28122 94% /This tells df to only show information about any mounted ext2 filesystems. You can get alist of valid filesystems to specify with the df command by looking at the mount manualpage. The mount command is covered in more detail in Hour 22, “Handling Files andYour File System.” You can see that by using the df and mount command, you can getreports on the type of mounted devices, how the devices are mounted, and how muchroom you have left on each.Getting Filesystem Disk Usage with the du CommandThe du (disk usage) command, found in the /usr/bin directory, conveniently summarizeshow your disk is being used by reporting the amount of space required by eachdirectory or specified path. Although the du command has more than 20 command-lineoptions, this section presents some of the common ones and leaves it up to you to experiment.You can use the du command by itself, or specify a directory or path:# du904 ./book12080 ./mail1 ./.tin/.mailidx1 ./.tin/.index10 ./.tin...589 ./News9 ./.index7 ./.procmail5 ./.ncftp418 ./reading778 ./documents27199 .21


456 Hour 21This report (for brevity, not all the directories are listed) shows the contents of a homedirectory, with a total for 27199 1KB blocks. If you find this hard to understand, you canhave du report the size in bytes:# du -b897606 ./book12294410 ./mail1024 ./.tin/.mailidx1024 ./.tin/.index9382 ./.tin561715 ./News4033 ./.index4139 ./.procmail2791 ./.ncftp424037 ./reading784216 ./documents26785752 .If this is too much information for you, then you can use the --summarize option to getthe total in either kilobytes (with the --kilobytes or -k option) or bytes (with the -b or--bytes option:# du -b --summarize26786903 .The du command can also help you keep track of directories which, unattended, sometimesgrow out of control or use a lot of disk space. If you specify a path, du will reporton the different size of the directories underneath that path, which might help you pinpointthose containing too much information:# du --summarize -b /var/* | sort -nr6474535 /var/lib2336494 /var/log868163 /var/catman76362 /var/spool14591 /var/dt2385 /var/run2048 /var/lock2048 /var/local1024 /var/tmp1024 /var/preserve1024 /var/nisHere, I’ve combined the du command, which has been instructed to summarize the numberof bytes in each directory, with the sort command, which has been set to use anumerical sort in reverse order. This one-liner, which uses pipes (discussed in Hour 6,“Using the Shell”), will automatically print the largest directories at the top of the outputlist. You can see that the /var/log directory is getting pretty big. The /var/lib directorywill be large because it contains the rpm databases. (rpm is discussed in Hour 22.)


Basic System Administration 457Although the du command does not, like the df command, have a -t option to specifywhich filesystem to report on, you can use the -x option to exclude other filesystems.This is handy to avoid including other mounted filesystems such as DOS or Windows.You can have du report on other filesystems by specifying a usage report at the mountpoint. For example, du will merrily chug along and summarize how much room yourWindows directories take up:# du -b --summarize /mnt/dos/* | sort -nr129486405 /mnt/dos/windows23929345 /mnt/dos/msoffice20811654 /mnt/dos/photoenf7744046 /mnt/dos/tranxit6828902 /mnt/dos/org26647520 /mnt/dos/laplink5556496 /mnt/dos/acrobat34041127 /mnt/dos/pcdr3753962 /mnt/dos/psp3603469 /mnt/dos/insync3176769 /mnt/dos/antvirus2669335 /mnt/dos/airlite2408920 /mnt/dos/winfax...This (shortened) report shows that next to the Windows operating system, the largestspace is consumed by certain Windows applications. This information can be helpful inmaking a decision on what applications to uninstall if you need more disk space.Checking Symbolic Links with the symlinks CommandThe symlinks command checks symbolic links in designated directories. The symlinkscommand has several command-line options you might find useful, including the -r orrecursive option you can use to check whole directories. For example, to check yourentire file system, use the -r option:# symlinks -r /dangling: /etc/rc.d/rc0.d/K30diald -> ../init.d/dialddangling: /etc/rc.d/rc1.d/K30diald -> ../init.d/dialddangling: /etc/rc.d/rc2.d/K30diald -> ../init.d/dialddangling: /etc/rc.d/rc3.d/S70diald -> ../init.d/dialddangling: /etc/rc.d/rc4.d/S70diald -> ../init.d/dialddangling: /etc/rc.d/rc5.d/S70diald -> ../init.d/dialddangling: /etc/rc.d/rc6.d/K30diald -> ../init.d/dialdabsolute: /etc/mta/sendmail -> /usr/libexec/sendmail/sendmailabsolute: /etc/mta/rmail -> /usr/libexec/sendmail/rmaildangling: /boot/System.map-2.0.35 -> /usr/src/linux-2.0.35/System.mapabsolute: /usr/doc/html/lg -> /usr/doc/lg-doc-1.0absolute: /usr/doc/bool-1.1/COPYING -> /usr/doc/Copyrights/GPL...21


458 Hour 21You can see that this symlinks command output shows at least two types of diagnosticsfor dangling and absolute symbolic links. (There are six: absolute, dangling, lengthy,messy, other_fs, and relative.) Dangling links, or links that point to a non-existent file,might be a cause of concern because OpenLinux cannot determine whether the designatedfile exists.See the symlinks man page for definitions of the absolute, lengthy, messy,relative, and other_fs link diagnostics.As a beginning sysadmin, you can use symlinks to look at file directories recursivelyand then print reports about the status of your file system. Here’s one handy commandline you can use to check all the symbolic links in your Linux filesystem (excluding others,such as Windows):# symlinks -vr / | fgrep “dangling” >symlinkstatusreport.txtThis command line uses the symlinks command to recursively descend through yourOpenLinux file system and report on dangling links. The fgrep command then printsall matches when symlinks finds a dangling symbolic link and creates your report. Asyou become a more proficient sysadmin, you’ll devise your own bag of tricks to helpdiagnose your system.Saving Disk SpaceThis section gives you some tips on saving disk space. Part of being a sysadmin is maintainingthe health of your filesystem and performing cleanup operations occasionally tofree disk space. Once you’ve found some techniques or approaches that work for yoursystem and the way you work on your system, you’ll find that you can routinely trim andrecover many megabytes of disk space.One good way to save disk space is not to install a lot of software. For example, howmany different word processors do you really need? How many graphics programs do youneed? If you find a capable program, delete others that do the same thing. Make sure toread Hour 22 to see how the rpm command can help you free disk space and customizeyour Linux installation by deleting packages of programs and supporting software.You can often trim the size of your directories by looking for less frequently used programsor collections of graphics or text you don’t need. You’ve already seen one way tofind directories that may be candidates for cleanup. You should also consider some otherfile types that can be deleted.


Basic System Administration 459For example, some Linux programs create backup files with the tilde (~) prefix. You cansearch for these as follows:# find / -name ~* -xdevOnce you feel comfortable with the results, you can pipe the filenames into the rm command,using the xargs command to build a cleanup command line (although you canalso use the find command’s -exec command-line option):# find / -name ~* -xdev | xargs rm -fYou should also search for files named core. These are core dumps, or dumps of programmemory created if a program abnormally aborts. Some of these files can be huge!You can use the bash or pdksh shells’ ulimit command to limit the size of these corefiles. To see the current allowable size of core files, use the ulimit command’s -coption:# ulimit -c1000000Fortunately, the default bash shell ulimit setting for the size of core dumpsunder OpenLinux is 0. If you’re a Linux programmer and need core files (fordebugging), change this setting.This doesn’t mean that core dumps are limited to 1MB, but 1,000,000 512-byte blocks.You can limit the size of core files with the -c option, as in# ulimit -c 1000This sets the maximum size of core files to 512,000 bytes. If you’re using the csh shell,use# limit coredumpsize 1000Limiting the size of these files is one way to save disk space in the future. Other candidatesfor removal include*.bak, *.BAK—Backup files*.o—Object files created during compiling operations#*—Backup files*.1, *.2, *.3—File extensions for system log files under the /var/log directory.Some logs can grow quite large, and unless you really need them, they should bedeleted.21


460 Hour 21Be careful about deleting files with file-number extensions, such as .1,across your system: You will delete a lot of libraries and manual pages if youautomate a search-and-destroy mission starting at the root, or /, directory.If you feel uncomfortable with letting the find command run through your file systemand deleting files, have the command generate a report of candidate files as follows:# find / \( -name core -o -name *.o \) -xdev > deletelist.txtNote that you can also set this command to run unattended, at regular intervals, and havethe report emailed to you as an automatic reminder. See Hour 24, “Using Scheduling toAutomate System Management,” for details.If you experiment with your own combination of commands, you’ll soon design yourown customized reports and cleanup actions. You now know how to get informationabout your drive space. You’ll also learn about managing disk space, using quotas (softwarelimits on hard drive usage) in the section “Managing User Access” later in thischapter. For now, you’ll learn how to find out more about what’s going on in your computer’smemory when you run Linux.Compressing unused files or directories or archiving and then deleting thesedirectories is another way to conserve disk space. See Hour 5, “Manipulationand Searching Commands” for information about using compression utilities.Also, see Hour 23, “Backing Up and Restoring Your System” for detailsabout backing up or restoring OpenLinux files and directories.Getting Memory InformationAlthough the industry trend has been to offer more hard drive space and moreNEW TERMsystem memory, or RAM, for less money, many people don’t like to outlay morecash to expand their systems. The good news is that Linux is efficient at using memorybecause even a 16MB system provides enough room (with an equal amount of swapspace) to run X11 and most programs well. The bad news is that programs are gettinglarger all the time, especially with feature creep, in which more and more functions creepinto programs. (This is true of the Linux kernel, which has tripled in size over the pastfew years.) This section introduces you to some programs you might find helpful inunderstanding your system’s memory and gives you some tips on conserving memory.


Basic System Administration 461Memory Reporting with the free CommandThe free command shows breakdowns of the amounts and totals of free and used memory,including your swapfile usage. This command, in the /usr/bin directory, has severalcommand-line options, but is easy to run and understand:# freetotal used free shared buffers cachedMem: 63136 60064 3072 53664 11080 26992-/+ buffers/cache: 21992 41144Swap: 130748 2616 128132This shows a system with 64MB RAM and 131MB of swap space. Notice that nearly allthe system memory is being used (normal) and almost 3MB of swap space (great!) hasbeen used.By default, the free command displays memory in kilobytes, or 1024-byte notation. Youcan use the -b option to display your memory in bytes or the -m option to display memoryin megabytes. You can also use the free command to constantly monitor how muchmemory is being used through the -s command. This is handy as a real-time monitor ifyou specify a .01-second update and run the free command in a terminal window underX11. For example, to monitor your disk space in an X11 terminal window, use the freecommand like so:# /usr/bin/free -b -s1This will print a scrolling report, updated each second, in your terminal window.Virtual Memory Reporting with the vmstat CommandThe vmstat command, found under the /usr/bin directory, is a general-purpose monitoringprogram, which offers real-time display of not only memory usage and virtualmemory statistics, but also disk activity, system usage, and central processing unit (CPU)activity. If you call vmstat without any command-line options, you’ll get a one-timesnapshot:# vmstatprocs memory swap io system cpur b w swpd free buff cache si so bi bo in cs us sy id0 0 0 7468 1060 4288 10552 1 1 10 1 134 68 3 2 96The major types of activity reported by vmstat are processes (procs), memory (in kilobytes),swap space (in kilobytes), input/output from block devices (hard drives), systeminterrupts (number per second), and percentages of central processing unit (CPU) timespent on users, the system, and idling.21


462 Hour 21If you specify a time interval in seconds on the vmstat command line, you’ll get acontinuously scrolling report. Having a constant display of what is happening with yourcomputer can help you if you’re trying to find out why your computer suddenly slowsdown or why there’s a lot of disk activity.Viewing Your Shell’s “Ulimit”ationsYou’ve already seen how you can limit the size of core dump files in this hour. There areother settings you can set in your shell. If you’re using the bash or pdksh (ksh) shell, youcan use the ulimit command’s -a option to print your current settings:# ulimit -acore file size (blocks) 0data seg size (kbytes) unlimitedfile size (blocks) unlimitedmax memory size (kbytes) unlimitedstack size (kbytes) 8192cpu time (seconds) unlimitedmax user processes 256pipe size (512 bytes) 8open files 256virtual memory (kbytes) 2105343If you’re using the tcsh or csh shell, you can use the limit command to list the currentsettings:$ limitcputimeunlimitedfilesize unlimiteddatasize unlimitedstacksize 8192 kbytescoredumpsize 0 kbytesmemoryuse unlimiteddescriptors 256memorylocked unlimitedmaxproc 256These limits are different from limits for the root operator. The limits shown inthis example are known as soft limits (limits that may be changed by any user).To view the shell’s hard limits (limits that may only be raised by root), log in as the rootoperator, and use the -a limit option (use -Ha for bash or ksh’s ulimit command):NEW TERM$ suPassword:# limit -hcputimefilesizedatasizestacksizeunlimitedunlimitedunlimited8192 kbytes


Basic System Administration 463coredumpsize unlimitedmemoryuse unlimiteddescriptors 256memorylocked unlimitedmaxproc 256As you can see, viewing the limits as the root operator in the tcsh shell shows a muchdifferent situation. This is another good reason not to run as the root operator. As asysadmin, you can use these settings to limit the amount of memory or number ofprocesses available to each user. This is extremely handy if you have a number of peopleworking on your computer at the same time and you want to conserve system memory.For using Linux on a standalone computer under your normal login and working conditions,you’ll find the default limits quite reasonable.Reclaiming Memory with the kill CommandAs a desperate measure if you need to quickly reclaim memory, you can stop runningprograms using the kill command. To kill a specific program, you should use the pscommand to list current running processes and then stop any or all of them with the killcommand. By default, the ps command lists processes that you own and you can kill:# psPID TTY STAT TIME COMMAND367 p0 S 0:00 bash581 p0 S 0:01 rxvt582 p1 S 0:00 (bash)747 p0 S 0:00 (applix)809 p0 S 0:18 netscape index.html810 p0 S 0:00 (dns helper)945 p0 R 0:00 psThe ps command will list the currently running programs and the program’s processnumber, or PID. You can use this information to kill a process with the -9, or SIGKILLsignal:# kill -9 809However, if you need to reclaim memory efficiently, you should use the ps command’sm option, which also lists the memory usage of each process:# ps mPID TTY MAJFLT MINFLT TRS DRS SIZE SWAP RSS SHRD LIB DT➥COMMAND747 p0 0 3 16 208 364 140 224 224 0 0➥(applix)582 p1 151 274 124 184 436 128 308 268 0 10➥(bash)959 p0 89 20 28 376 404 0 404 320 0 21 ps m21


464 Hour 21367 p0 305 826 220 316 600 64 536 428 0 27 bash810 p0 313 38 164 696 968 108 860 596 0 47 (dns➥helpe581 p0 212 508 28 960 1280 292 988 304 0 171 rxvt809 p0 2615 1205 3900 3692 8684 1092 7592 4644 0 699➥netscapeUsing this information, you can see that if you want to reclaim the most memory, youshould stop the Netscape Web browser because it is using nearly 9MB of systemmemory. Although you wouldn’t normally use the kill command to stop programs, thekill command can be helpful to stop runaway or unresponsive programs. The kill commandworks by sending a signal to the Linux kernel, along with the PID, so the kernelcan act on the process. There are various signals you can use, although the -9, orSIGKILL option, is the most abrupt and drastic. You can see a list of different signals byusing the kill command’s -l option:# kill -l1) SIGHUP 2) SIGINT 3) SIGQUIT 4) SIGILL5) SIGTRAP 6) SIGIOT 7) SIGBUS 8) SIGFPE9) SIGKILL 10) SIGUSR1 11) SIGSEGV 12) SIGUSR213) SIGPIPE 14) SIGALRM 15) SIGTERM 17) SIGCHLD18) SIGCONT 19) SIGSTOP 20) SIGTSTP 21) SIGTTIN22) SIGTTOU 23) SIGURG 24) SIGXCPU 25) SIGXFSZ26) SIGVTALRM 27) SIGPROF 28) SIGWINCH 29) SIGIO30) SIGPWRFor more details on these signals and the kill command, see its manual page.The ps command has nearly two dozen command-line options, and you can also list allrunning processes. See the ps manual page for more information. You can also use thetop command, discussed next, to find and kill processes.Getting System Load Information with thetop and xload CommandsThe top command, in the /usr/bin directory, is a system monitor that displays statisticalinformation about how Linux is currently handling your memory, swap file, andprocesses. The top program also shows how long your system has been running, thestatus of your CPU, the size of each process, and more. You’ll typically use the topcommand by running it on a spare console or separate X11 terminal window (seeFigure 21.1).


Basic System Administration 465FIGURE 21.1The top commandprovides an ongoingdisplay of your system.The top command also has a number of interactive controls, including a help screen,accessed with the question mark or the H key. You can also toggle various modes of thedisplay, such as listing processes by memory usage or limiting the number of processesdisplayed. This can be helpful if you want to monitor only the top five processes thatrequire the greatest amount of your system’s memory, and it can help you diagnose problemsif your computer starts unusual disk or swap file activity.You can also use top to interactively kill processes, using the K key, or change aprocess’s priority (how much time the CPU devotes to a task) with the R key. The topprogram has 19 different interactive commands, and you can customize its display byadding or removing different information fields and lengthening or shortening the numberof processes. See Table 21.1 for more information.TABLE 21.1 SINGLE-KEY INTERACTIVE COMMANDS FOR topCommandDescriptioncDisplay command name or full command line.Ctrl+LRedraw the display.fAdd or remove display fields.HSort display by memory usage.h, ? Show help.iToggle display of idle or zombie processes.kKill a process by its process number (PID).lToggle load average and uptime display.mToggle memory information display.21continues


466 Hour 21TABLE 21.1 SINGLE-KEY INTERACTIVE COMMANDS FOR topCommandDescriptionn, x Set number of processes (n is interactive).PSort display by CPU usage.qQuit.rChange priority of a process.SChange CPU usage display.sSet update delay interval.SpacebarUpdate display.tToggle process and CPU state display.WSave current settings to $HOME/.toprc.The xload client, used under X11, provides a running graph of your system’s load,instead of the top command’s statistics. System loads vary from computer to computer,but you can generally tell when your system is overloaded by inordinate disk activitybecause processes are swapped back and forth from your swap file. The xload commandcan give you a visual warning if you’re running too many programs and might be especiallyhelpful if you’re running X11 on a 8MB or 16MB Linux system.The xload command has eight different command-line options, and you can customizethe color of the moving graphic, scale lines, or background.OpenLinux comes with a number of other helpful utilities you can use tographically monitor your system. Try the tload command if you’re using theconsole. If you use X11, try the xosview client, which can also display thestatus of your computer’s network and serial ports.Determining How Long Linux Has Been Running withthe uptime and w CommandsThe uptime command, in the /usr/bin directory, shows you how long Linux has beenrunning, how many users are on, and three system load averages:# uptime12:44am up 8:16, 3 users, load average: 0.11, 0.10, 0.04


Basic System Administration 467If this is too little information for you, try the w command, which first shows the sameinformation as the uptime command and then lists what currently logged-in users aredoing:# w12:48am up 8:20, 3 users, load average: 0.14, 0.09, 0.05USER TTY FROM LOGIN@ IDLE JCPU PCPU WHATbball ttyp0 localhost.locald 9:47pm 15.00s 0.38s 0.16s bashbball ttyp2 localhost.locald 12:48am 0.00s 0.16s 0.08s wThe w command gives a little more information, and it is especially helpful if you want tomonitor a busy system with a number of users.Getting Network and Mail Information with thepppstats and mailstats CommandsThe pppstats command, in the /usr/sbin directory, will give you a running statisticaldisplay on the status and activity of your PPP connection. The information is similar tothe output of the ifconfig command (discussed in Hour 10, “Connecting to theInternet”). To use the pppstats program, specify the PPP interface (usually 0) on thecommand after you have connected to your ISP:# /usr/sbin/pppstats 0in pack comp uncomp err | out pack comp uncomp ip24791 93 74 5 0 | 1922 72 54 4 1478 4 3 0 0 | 80 4 3 0 1129 2 0 0 0 | 160 3 0 1 21169 23 21 1 0 | 842 23 20 2 112748 28 27 1 0 | 730 27 18 9 09582 18 13 5 0 | 375 13 6 7 09399 18 16 2 0 | 268 12 8 4 071 3 2 0 0 | 80 4 3 0 1...This shows the pppstats command in action after displaying a line of statistics everyfive seconds during startup of a newsreading session.The mailstats program, part of the sendmail distribution, is in the /usr/sbin directory.You can use this program to generate reports about your system’s mail usage. This commandworks by reading a file called sendmail.st under the /var/log directory. To createand use this file, you must use the -O StatusFile=/var/log/sendmail.st optionwith the sendmail daemon or set the appropriate option in the /etc/sendmail.cf file.As a test, you can try this command on an empty sendmail log file in the /var/statedirectory:21


468 Hour 21# mailstats -f /var/state/sendmail.stStatistics from Wed Dec 23 20:48:29 1998M msgsfr bytes_from msgsto bytes_to Mailer========================================T 0 0K 0 0KMonitoring Your Serial Ports with the statserialCommandThe statserial program, originally by Jeff Tranter, can be used to show the status ofyour serial ports and can be a lifesaver if you need to troubleshoot modems or serialports. To use statserial (in the /usr/bin directory), you must specify the device on theprogram’s command line. You can, for example, tell statserial to monitor your modemby specifying its symbolic link:# ln -s /dev/ttyS1 /dev/modem# statserial /dev/modemDevice: /dev/modemSignal Pin Pin Direction Status FullName (25) (9) (computer) Name----- --- --- --------- ------ -----FG 1 - - - Frame GroundTxD 2 3 out - Transmit DataRxD 3 2 in - Receive DataRTS 4 7 out 1 Request To SendCTS 5 8 in 1 Clear To SendDSR 6 6 in 0 Data Set ReadyGND 7 5 - - Signal GroundDCD 8 1 in 0 Data Carrier DetectDTR 20 4 out 1 Data Terminal ReadyRI 22 9 in 0 Ring IndicatorYou must be the root operator to use the statserial program. Try usingstatserial like so:su -c “statserial /dev/modem”Managing User AccessOne of your main jobs as a sysadmin is to manage the users on your system. Thisinvolves creating accounts for new users, assigning home directories, specifying an initialshell for the user, and possibly restricting how much disk space, memory, or how manyprocesses each person can use. This section shows you how to use different commandlineprograms to manage users (such as lisa), although you can do these and other taskswith graphical utilities while running the X Window System.


Basic System Administration 469Creating Users with the adduser CommandOne of the first things you should do after installing OpenLinux is to create useraccounts for other family members. (You created a user account for yourself during yourOpenLinux installation.) You should do all your work in OpenLinux through your useraccount and do your system management using the su command. There are several waysto create new users in Linux, but this section shows you the easy way, using a trio ofcommands: adduser, passwd, and chfn.The first step in creating a new user is to use the adduser command, in the /usr/sbindirectory. You must be the root operator to run this program. If you try to run adduser asa regular user, the command will report an error:# adduserOnly root may add users to the system.The adduser program also requires you to specify a username on the command line:# adduser cloobieLooking for first available UID... 502Looking for first available GID... 502Adding login: cloobie...done.Creating home directory: /home/cloobie...done.Creating mailbox: /var/spool/mail/cloobie...done.Don’t forget to set the password.The command will create an account, assign a user identification (UID) and a groupidentification (GID), and then create a directory called cloobie under the /home directory.As a reminder, the adduser program tells you to set a password for your new user.Managing Users with the lisa CommandThe lisa command is an essential system administration tool for OpenLinux. You canuse lisa to create and manage users through its graphical interface. In fact, you canjump right into lisa’s user screen with the -useradm command-line option:# lisa --useradmAfter you press Enter, the lisa command will display as shown in Figure 21.2.21


470 Hour 21FIGURE 21.2The lisa commandprovides an easy-touseinterface toOpenLinux useradministration.Scroll through the lisa menu with the Up and Down cursor keys and then press Enter todisplay, add, or delete users.Changing Passwords with the passwd CommandAfter creating your new user, you must assign a password with the passwd command.This command will create a default entry of x in the passwd text databasein the /etc directory. The real passwords, in encrypted form, are in the /etc/shadow file,which has different read permissions than the /etc/passwd file. (Although anyone canread the /etc/passwd file, only the root operator has permission to view /etc/shadow.)To show you how this works, the following example first shows the passwd and shadowfile entry for the user, cloobie. Then, after creating a new password for the new user, theexample shows you the new user’s entry in the shadow password file:NEW TERM# fgrep cloobie /etc/passwdcloobie:x:503:504:Caldera OpenLinux User:/home/cloobie:/bin/bashYou can see that although an account has been created and contains a username, UID,PID, name, directory, and default shell, the password field is represented by an x. Theshadow password file shows# fgrep cloobie /etc/shadowcloobie:*notset*:9000:0:10000::::To add a password, type the passwd command, along with the new user’s name:# passwd cloobieNew UNIX password:Retype new UNIX password:passwd: all authentication tokens updated successfully


Basic System Administration 471You’ll be asked for a password and then asked to retype it to verify. If all goes well, thepassword will be recorded in /etc/shadow:# fgrep cloobie /etc/shadowcloobie:hQSxtwq7CvJ3.:10584:0:10000:-1:-1:-1:1073917872The /etc/shadow entry contains the user’s name, an encrypted password, and a series ofnumerical values that detail●●●●The minimum and maximum number of days before mandatory password changesWhen to warn of a required password changeHow long after a warning a user can change the passwordHow long before an account will expireLater, users can change their own passwords using the passwd command, and you shouldencourage frequent password changes.You should know that not all Linux distributions use the shadow passwordsystem. This system of protecting passwords provides a slight increase in systemsecurity by making the system’s passwords unreadable by all except theroot operator. As the sysadmin, you can change anyone’s password if theyforget it. Don’t forget yours!Finally, you’ll also want to use the chfn command to enter formal information aboutusers or have your users enter this information. The chfn command, in the /usr/bindirectory, is used with a username and will prompt you for four lines of information:# chfn cloobieChanging finger information for cloobie.Name [Caldera OpenLinux User]: Heronimous J. CloobieOffice []: Maritime Science HistorianOffice Phone []: 703 555-1234Home Phone []: 703 555-1235Finger information changed.If you now examine the /etc/passwd entry, you’ll see# fgrep cloobie /etc/passwdcloobie:x:503:504:Heronimous J. Cloobie,Maritime Science Historian,703 555-1234,703 555-1235:/home/cloobie:/bin/bash21


472 Hour 21This information is used by the finger command. The formal name may also be usedalong with the username in mail messages:# finger cloobieLogin: cloobieName: Heronimous J. CloobieDirectory: /home/cloobieShell: /bin/bashOffice: Maritime Science Historian Office Phone: 703 555-1234Home Phone: 703 555-1235Never logged in.No mail.No Plan.The finger command will extract the user’s information from the /etc/passwd file andprint it in a nice format. One of the other things you should note in a user’s /etc/passwdentry is the name of a shell at the end. This can be a unique way not only to specify thetype of shell used (your Linux system is set up to assign the bash shell by default), butalso to restrict the user to a particular program.Restricting LoginsYour users normally can change the shell used after login through the chsh command, inthe /usr/bin directory. You can list the currently available shells by using the chsh command’s-l (list shells) option:# chsh -l/bin/bash/bin/sh/bin/ash/bin/ksh/bin/csh/bin/tcsh/bin/zshThe chsh command looks in a file called shells under the /etc directory and prints alist. This does not mean that these shells are available (installed), just “acceptable.” Youcan edit this file, adding or removing shells that can be specified by your users. Youshould make sure that the shells listed in this file are available on your system. To changeshells, you can type# chsh -s /bin/kshChanging shell for root.Shell changed.You can also use the chsh command to specify a program, other than a shell, to use asthe program to run when the user logs in:# chsh -s /usr/bin/pico cloobieChanging shell for cloobie.Warning: “/usr/bin/pico” is not listed as a valid shell.Shell changed.


Basic System Administration 473The chsh program will complain if the program is not listed as a shell in the/etc/shells file. Then, you check whether the change was made:# fgrep cloobie /etc/passwdcloobie:x:503:504:Heronimous J. Cloobie,Maritime Science Historian,703 555-1234,703 555-1235:/home/cloobie:/bin/bin/picoThe preceding example specified the text editor pico, which allows a user to do wordprocessing, printing, or spell-checking, but that’s all! As soon as the user logs into Linux,the user is right in the text editor. After quitting the text editor, the user is logged out.This is a handy technique you can use to restrict users, especially children, if you onlywant them to play a game.If you want to set the default shell or home directory for all new OpenLinux users, usethe lisa command like so:# lisa --useradmAfter you press Enter, scroll down the menu (as shown in Figure 21.2) to Set defaultvalues and press Enter. You’ll see the lisa menu as shown in Figure 21.3.FIGURE 21.3The lisa commandcan set the defaultshell and directoriesfor all your newOpenLinux systemusers.You can put other system-wide settings or restrictions in place. The next section showsyou how you can limit how much of your system’s hard drive can be used.Setting Disk QuotasOn a large, multiuser systems, disk quotas (hard drive storage space limits forNEW TERMusers) are not only a way of life, but also a necessity. You can impose disk quotason your Linux system, and you should, especially if you worry about your disk spaceor if you’re afraid the users will create huge files and overrun your hard drive. You canalso use disk quotas as a warning device (and maybe justification for a new hard drive).This section explains how to start, set, and stop disk quotas.21


474 Hour 21Quota Manipulation with the quota, quotaon, and quotaoffCommandsDisk quotas limit the amount of hard drive space in several ways. You can set quotas fora group of users, using the GID, or impose limits on individual users. To manage diskquotas, you’ll use some or all of these commands:The default Linux kernel included with OpenLinux does not support diskquotas. You must configure, rebuild, and install a new Linux kernel withquota support. For complete and definitive directions on rebuilding yourOpenLinux kernel to support disk quotas, browse tohttp://www.calderasystems.com/support/techguide/COL12-Kernel-Rebuild-1.html.●●●●●●quota—Reports disk quotasquotaon—Turns on and sets disk quotas for usersquotaoff—Turns off disk quotas for usersrepquota—Also reports on quotasedquota—Edits user quotasquotacheck—Checks filesystem on quota usageThis book won’t discuss all the details of these programs (read the manual pages), butthis section shows you how to set a disk quota for the new user you created. The firstthing you must do is to enable quotas for your Linux filesystem. This involves editing thefilesystem table, fstab, in the /etc directory.Be very careful when editing system configuration files in the /etc directory,especially the fstab, or filesystem table file. You should always first make abackup copy and then make sure you don’t make incorrect changes, or youcould cause boot problems. You have been warned!Make sure you’re logged in as root, and then use your favorite text editor to open thefstab file and edit the line containing the entry for your Linux partition:# /dev/hda3 / ext2 defaults 1 1


Basic System Administration 475Add a comma and the word usrquota to the word default:/dev/hda3 / ext2defaults,usrquota 1 1Save the /etc/fstab file. Next, use the touch command to create a file calledquota.user, and make the file read-write enabled:# touch /quota.user# chmod 600 /quota.userAfter you have done this, reboot your computer using the shutdown command with the -r, or restart, option. Log back in as root, and use the edquota command, in the/usr/sbin directory, along with the -u option, to edit quotas for your new user:# edquota -u cloobieThe edquota command will read in the user.quota file under your root, or /, directory.This file is normally a binary file, but edquota will open the file using the text editordefined in your EDITOR environment variable. If you don’t like the default editor, you canfirst specify your own temporarily:# EDITOR=/usr/bin/pico;export EDITORThis will make the edquota command use the pico text editor. When edquota runs,you’ll end up in your editor with the following text:Quotas for user cloobie:/dev/hda3: blocks in use: 58, limits (soft = 0, hard = 0)inodes in use: 41, limits (soft = 0, hard = 0)Although it is not important to understand all the information here (see Albert M.C.Tam’s mini-HOWTO, Quota, in /usr/doc/HOWTO/mini for details), you can easily setboth the maximum number of files and the maximum size of your user’s directory. To setlimits to 3 to 5MB for disk space (blocks) and between 500 and 1000 files (inodes),change the values for the soft and hard limits for the blocks and inode listings:Quotas for user cloobie:/dev/hda3: blocks in use: 58, limits (soft = 3000, hard = 5000)inodes in use: 41, limits (soft = 500, hard = 1000Save the file. Then, as a last step, you must set a grace period using edquota again, butthis time with the -t option. Your new user will be warned if the lower, or “soft,” limit isexceeded:# edquota -t cloobie21


476 Hour 21You can then set the grace-period warnings for exceeding either the number of files ordisk use:Time units may be: days, hours, minutes, or secondsGrace period before enforcing soft limits for users:/dev/hda3: block grace period: 1 days, file grace period: 1 daysIf you want to warn your user right away, use a grace period of one day. (You can alsouse minutes or seconds.) Finally, you can use the quota command to check the newquota:# quota cloobieDisk quotas for user cloobie (uid 502):Filesystem blocks quota limit grace files quota limitgrace/dev/hda3 58 3000 5000 41 500 1000Using disk quotas might sometimes be necessary. If your disk space is at a premium, thiscould be one way to manage your hard drive resources.SummaryThis hour introduced you to some of the basic system administration skills you need tomaintain a computer running OpenLinux. You also learned how to get information aboutwhat is going on inside your computer’s memory while Linux runs and how to controlbackground processes, users, and system resources, such as hard drive space.Q&AQ I tried to define pico as my default editor, but I either get an error message orvi runs anyway.A Make sure you have installed the pine email program (using lisa, rpm, or glint)from your OpenLinux CD-ROM. The pico editor is part of the pine distribution.Q I used lisa to remove a user from my system, but the user’s directory under/home is still there.A Utilities such as lisa do not remove a user’s directory. If you use X11, run theRed Hat usercfg client. When you click a user’s name and then click the Removebutton in usercfg’s dialog, you see an option to delete the user’s home directory.Alternatively, log in as root and use the rm command to delete the user’s files anddirectory. You’ll also need to remove the user’s mail files (in the /var/spool/maildirectory).


Basic System Administration 477Q What other utilities come with OpenLinux to administer users?A To handle the administrative chore of creating dozens or hundreds of new users atone time, see the newusers command. This command reads a text file containingnew users’ names and passwords and can create many users with a single commandline. To modify a user’s account, use the usermod command. You can alsoremove users with the userdel command.Exercises1. View your system processes with other X11 utilities such as xosview, xload, orperf. How are these clients different?2. The /home and /var/spool directories might contain files belonging to yourOpenLinux system’s users. How can you easily find all files on your system thatbelong to a user?21


HOUR 22Handling Files and YourFile systemThis hour continues with the basics of system administration and introducesyou to handling files under Linux. You’ll learn how to mount filesystems,manage the filesystem table (fstab), and format floppies. You’ll see howyou can protect files and directories. You’ll also learn how to install or uninstallsoftware from the command line or during your X sessions.You will use this knowledge to administer your Linux system. Knowing howto manage file ownership is an important Linux skill and can help you overcomeproblems later.One great reason to get up to speed about file access and ownership concernssecurity. There are some important files in your Linux system that, asroot operator, you don’t want all users to access. If you’ve set up your systemto handle dial-in calls, you want to make sure that important files, andeven other mounted filesystems, such as DOS or Windows, are protected. Ifyou share your computer, you normally wouldn’t want other users to haveaccess to your files, but on the other hand, you might want to share fileswith other people but don’t know how.


480 Hour 22This hour starts with a discussion of the Linux file system. There’s a differencebetween a file system and a filesystem. A file system is the layout of the directoriesand hierarchy of files on a partition. A filesystem is the layout of the lower-levelformat of a storage device, such as a hard drive. OpenLinux recognizes more than adozen filesystems. You can find a list in the fstab, or filesystem table, manual page inthe /usr/man/man5 directory, but it’s best to look at the current list of supported systemsin the mount command manual page. Why? The mount command is used to mount thefilesystem at a mount point, or path, you specify. For now, take a look at the Linuxfilesystem.NEW TERMHow OpenLinux Is OrganizedThe software that comes with the Linux kernel comes from a variety of different UNIXsystems. Some programs, utilities, and commands, such as mail, come from a UNIXdistribution called the Berkeley Software Distribution, or BSD. Other programs andmethods of organizing software, such as startup scripts and the organization of files usedduring startup, come from either AT&T System V UNIX or later variants. Because of thismixed heritage, Linux has a mix of directories, and although most pundits say Linuxleans towards being System V-ish, you’ll find elements of BSD and System V.To give you a better idea, Listing 22.1 contains an edited directory listing, courtesy of thetree command.LISTING 22.1THE BASIC OPENLINUX FILE SYSTEM, OR DIRECTORY TREE/ - the root directory|-- bin - programs considered necessary|-- boot - Linux boot image|-- dev - devices, like serial ports, printers, hard drives|-- etc - configuration files for network, X11, mail, etc.|-- home - where users live (including root as a user)|-- lib - software libraries, kernel modules|-- lost+found - recovered files (from e2fsck)|-- mnt - where you mount other filesystems| |-- cdrom (CD-ROMs)| |-- dos (DOS filesystems)| |-- flash (flash memory)| |-- floppy (floppy diskette)| `-- zip (Zip drives)|-- opt - optional software (such as Applix, KDE, Netscape, or WordPerfect)|-- proc - kernel, device, process status files|-- root - where the sysadmin works|-- sbin - system binaries (many root-only)|-- tmp - temp files stored, deleted from here


Handling Files and Your File System 481|-- usr - hosts much, much software, libraries| |-- X11R6 - X Window System software| |-- bin - more software| |-- dict - dictionaries| |-- doc - FAQs, HOW-TOs, software documentation| |-- etc - software configuration files| |-- games - fun, fun, fun!| |-- i386-linux - development utilities| |-- include - header files for programming| |-- info - GNU information| |-- lib - more software libraries| |-- libexec - sendmail, news configuration files| |-- local - locally developed programs| | |-- bin| | |-- doc| | |-- etc| | |-- games| | |-- info| | |-- lib| | |-- man| | |-- sbin| | `-- src - source code to local programs| |-- man - manual pages| | |-- man1..9n| |-- sbin| |-- share| |-- src - source for the Linux kernel!!!| | |-- linux -> linux-2.0.35| | |-- linux-2.0.35| `-- tmp -> ../var/tmp`-- var - system logs, spool directories, compressed manual pages22As you can see, the main directory structure is not that complicated. What is important tounderstand here is that you should know where you are as you navigate the file system.When you install software using package-management utilities such as Red Hat’s rpm,KDE’s kpackage, or the lisa command (all covered later in this hour), you won’t knowwhere software is installed unless you have a basic knowledge of your file system.Knowing generally where different software should reside on your system might helpyou track down or troubleshoot difficulties if a problem should arise. Many programswill require different software components to be installed in different parts of yourOpenLinux file system.If you look at the file system listing, you see a /mnt, or mount, directory. Although youdon’t have to use this directory as a gateway to other filesystems, this is traditionallywhere other systems are mounted. The next section discusses how to make these othersystems appear under the mount directory.


482 Hour 22Using the mount Command to Access OtherFilesystemsThe mount command, found in the /bin directory, is an essential program used not onlyby system administrators, or sysadmins, but also by OpenLinux during startup and shutdown.This command is used to mount filesystems and make them available in yourOpenLinux directory tree. During startup, the primary Linux partition, an ext2 filesystem,is mounted at the root, or /, directory.You can have other filesystems automatically mounted when OpenLinux starts, or youmount and unmount filesystems, using the mount and the umount commands, while youwork. The Linux mount command recognizes and will mount (depending on how yourkernel’s modules are configured) more than a dozen different filesystems. This sectionconcentrates on the most common, such as ext2 for Linux, msdos or vfat for DOS orWindows, and iso9660 for CD-ROMs.Support for different filesystems, such as vfat (which provides long filenames for Win9xfilesystems), is contained in loadable kernel modules.Understanding the Filesystem Table,/etc/fstabWhen you start Linux, one of the first scripts to run is the rc.boot script underthe /etc/rc.d directory. This script first mounts the swap partition (createdwhen you first installed OpenLinux and used to temporarily hold portions of systemmemory) and then mounts your OpenLinux partition as read-write after it checks the partitionfor errors. If everything is okay, it will mount all filesystems described in thefilesystem table, fstab, in the /etc directory with the following command:NEW TERM# mount -avt nonfsThis mounts all filesystems described in the /etc/fstab (excluding those not meant tobe automatically mounted, such as CD-ROMs), which is a short text file:# /dev/hda2 / ext2 defaults 0 1/proc /proc proc defaults 0 0/dev/hda3 none swap defaults 0 0/dev/fd0 /mnt/floppy ext2 defaults,noauto 0 0/dev/hdc /mnt/cdrom iso9660 ro,noauto 0 0/dev/hda1 /mnt/dos vfat noauto,dev,exec,suid 0 0/dev/sda4 /mnt/zip vfat noauto,dev,exec,suid 0 0/dev/hde1 /mnt/flash vfat noauto,dev,exec,suid 0 0


Handling Files and Your File System 483The fstab columns show the device name, where the filesystem will be mounted, thetype of filesystem, any mount options, whether the dump command (discussed in Hour 23,“Archiving”) needs to check for files to be archived, and the order in which the filesystemis checked during reboot.22Your filesystem table will look different from the example shown here, especiallyif your computer uses a SCSI interface. The filesystem table describedhere is only an example.The fstab rows show a Linux ext2 filesystem; the /proc or kernel process directory; theOpenLinux swap directory; a floppy diskette drive (/dev/fd0); the CD-ROM device (inthis listing, the OpenLinux CD-ROM device, /dev/cdrom, is a symbolic link to/dev/hdc); a DOS filesystem partition on the same hard drive as the Linux ext2 partition(because both filesystems use the /dev/hda device); an entry for an Iomega Zip drive(/dev/sda4); and a DOS VFAT filesystem on a flash RAM card.You should know that editing the filesystem table is inherently dangerous.You learned to add quotas in Hour 21, “Basic System Administration.”Always make a backup copy before adding a hard drive, new partitions, andso on. Make sure you have your OpenLinux boot disk on hand (created duringinstallation). If things go awry, you can boot with your floppy, use themount command to mount your OpenLinux partition on your hard drive, andthen copy and restore the original /etc/fstab file.Normally, the root operator mounts and unmounts filesystems. If you take my advice anddon’t run Linux as root all the time, you’ll have to use the su command to mount andunmount filesystems:# su -c “mount /mnt/cdrom”This command will mount an inserted CD-ROM at the /mnt/cdrom directory. The moreformal version of this command (depending on what the symbolic link /dev/cdrompoints to in your system) is# su -c “mount -t iso9660 /dev/hdc /mnt/cdrom”This command uses the mount command to specify the filesystem type iso9660 and thedevice hdc (yours may be different) to be mounted at the /mnt/cdrom directory.


484 Hour 22Does this seem like a lot of typing? If you want to make this process easier, use the useroption of the mount command. You won’t have to use the su command to mount CD-ROMs, enter passwords, or type long command lines. For example, open the /etc/fstabfile with your favorite text editor (as the root operator), and change the original fstabentries to/dev/hdc /mnt/cdrom iso9660 noauto,ro,user,dev,exec 0 0The ro option specifies that the device is mounted read-only. The exec option will allowanyone to run programs from the CD-ROM. Save the file after making your changes.You’ll be able to mount CD-ROMs without having to be the root operator, by using# mount /dev/hdcor# mount /mnt/cdromThis will automatically mount your CD-ROM’s filesystem at the /mnt/cdrom path. You’llalso be able to switch your disks with the umount command, for example:# umount /dev/hdcor# umount /mnt/cdromAlthough you should enable this type of convenience only if you’re using Linux on astandalone computer, and only for certain types of filesystems, such as CD-ROMs, it isconvenient, especially for removable filesystems (such as Iomega Zip disks or flashmemory cards). Another type of removable filesystem is the venerable floppy drive. Thenext section discusses floppy drives and follows with a discussion of a package of floppyutilities that might make life easier when you’re dealing with floppies under Linux.Formatting a FloppyThis section introduces you to four programs you can use to format a floppy from theLinux command line. I also take you step-by-step through the process. You might findthis information useful if you want to back up files or use the floppy to install and testnew software. You’ll also learn how to format and then mount your floppy in Linuxnativeformat using the ext2 filesystem.


Handling Files and Your File System 485Floppy devices are located under the /dev directory; there are quite a few of them. You’llfind a device corresponding to just about any type of floppy device ever made. You canlook at the /dev directory for floppy devices:22# ls /dev/fd*/dev/fd0 /dev/fd0h880 /dev/fd0u3520 /dev/fd1h1494➥/dev/fd1u1743/dev/fd0CompaQ /dev/fd0u1040 /dev/fd0u360 /dev/fd1h1600➥/dev/fd1u1760/dev/fd0H1440 /dev/fd0u1120 /dev/fd0u3840 /dev/fd1h360➥/dev/fd1u1840/dev/fd0d360 /dev/fd0u1440 /dev/fd0u720 /dev/fd1h410➥/dev/fd1u1920/dev/fd0h1200 /dev/fd0u1600 /dev/fd0u800 /dev/fd1h420➥/dev/fd1u2880/dev/fd0h1440 /dev/fd0u1680 /dev/fd0u820 /dev/fd1h720➥/dev/fd1u3200/dev/fd0h1476 /dev/fd0u1722 /dev/fd0u830 /dev/fd1h880➥/dev/fd1u3520/dev/fd0h1494 /dev/fd0u1743 /dev/fd1 /dev/fd1u1040➥/dev/fd1u360/dev/fd0h1600 /dev/fd0u1760 /dev/fd1CompaQ /dev/fd1u1120➥/dev/fd1u3840/dev/fd0h360 /dev/fd0u1840 /dev/fd1d360 /dev/fd1u1440➥/dev/fd1u720/dev/fd0h410 /dev/fd0u1920 /dev/fd1h1200 /dev/fd1u1600➥/dev/fd1u800/dev/fd0h420 /dev/fd0u2880 /dev/fd1h1440 /dev/fd1u1680➥/dev/fd1u820/dev/fd0h720 /dev/fd0u3200 /dev/fd1h1476 /dev/fd1u1722➥/dev/fd1u830The most common devices for 3.5-inch, 1.44MB floppies are/dev/fd0—Drive A/dev/fd1—Drive BA number of supported floppy formats are listed in the fdprm, or floppy drive parameterfile, in the /etc directory. Take a look at a portion of the file:# /etc/fdprm - floppy disk parameter table# Common disk formats. Names are of the form# actual media capacity/maximum drive capacity# (Note: although 5.25” HD drives can format disks at 1.44M, they’relisted# as 1200 because that’s the common maximum size.)# size sec/t hds trk stre gap rate spec1 fmt_gap360/360 720 9 2 40 0 0x2A 0x02 0xDF 0x50


486 Hour 221200/1200 2400 15 2 80 0 0x1B 0x00 0xDF 0x54360/720 720 9 2 40 1 0x2A 0x02 0xDF 0x50720/720 1440 9 2 80 0 0x2A 0x02 0xDF 0x50720/1440 1440 9 2 80 0 0x2A 0x02 0xDF 0x50360/1200 720 9 2 40 1 0x23 0x01 0xDF 0x50720/1200 1440 9 2 80 0 0x23 0x01 0xDF 0x501440/1440 2880 18 2 80 0 0x1B 0x00 0xCF 0x6C...The format you’ll most likely be interested in is the 1440/1440 description of today’s3.5-inch high-density drives. If you don’t have a 1.44MB floppy diskette, you can use aname (such as 360/360) from this file with the setfdprm (set floppy disk parameter)command (found in the /usr/bin directory) to associate your drive A: floppy with adevice, such as /dev/fd0:# setfdprm -p /dev/fd0 360/360After that, you can proceed with a low-level format of your drive. To do this, you use thefdformat (floppy disk formatting) command (found in the /usr/sbin directory). To performthis operation on the default floppy device, a 1.44MB diskette, insert a blankdiskette in your drive and then use# fdformat /dev/fd0Double-sided, 80 tracks, 18 sec/track. Total capacity 1440 kB.Formatting ... doneVerifying ... doneHere, you’ve told the fdformat command to do a low-level format of the /dev/fd0device. Be careful! Be sure to specify the correct device.You should also know that you can alternatively use a specific floppy deviceto do the low-level format, for example:# fdformat /dev/fd0H1440This tells fdformat to use the specific floppy device for high-density drives, inthis case, the A: drive.The next step is to create a filesystem on the floppy. You’ll use the mke2fs command tomake a Linux second extended filesystem on the floppy. The mke2fs command, found inthe /sbin directory, has at least two dozen command-line options, but you’ll only use afew, for example:# /sbin/mke2fs -c -v -L “Linux1” /dev/fd0mke2fs 1.10, 24-Apr-97 for EXT2 FS 0.5b, 95/08/09Linux ext2 filesystem formatFilesystem label=Linux1


Handling Files and Your File System 487360 inodes, 1440 blocks72 blocks (5.00%) reserved for the super userFirst data block=1Block size=1024 (log=0)Fragment size=1024 (log=0)1 block group8192 blocks per group, 8192 fragments per group360 inodes per group22Running command: badblocks -s /dev/fd0 1440Checking for bad blocks (read-only test): doneWriting inode tables: doneWriting superblocks and filesystem accounting information: doneThe preceding example uses the -c option to check the diskette for any bad blocks andthe -L option to give the floppy a name. To see what’s going on, it also used the -v (verbosemode) option. The mke2fs command will automatically determine the size of yourfloppy, check it using the badblocks command, found in the /sbin directory, and thencreate your Linux filesystem. You might also want to use the -m option with a value of 0to have the most room available and specify the high-density floppy device (to overridemke2fs’s default behavior of reserving five percent of the filesystem for the rootoperator):# mke2fs -m 0 /dev/fd0H1440 1440As a final step, you can mount the floppy, using the mount command, and then check thefloppy’s size, for example:# mount -t ext2 /dev/fd0 /mnt/floppy# df /dev/fd0Filesystem1024-blocks Used Available Capacity Mounted on/dev/fd0 1390 13 1377 1% /mnt/floppyI’ve shown you the formal mount command line to mount a floppy. However,because the floppy device is defined in the default OpenLinux filesystemtable, /etc/fstab, you can simply mount a floppy with mount /mnt/floppy.Knowing how to format floppy drives is important. If you use the K DesktopEnvironment, read the next section and learn how to use the KFloppy utility.


488 Hour 22Formatting Floppies with the KFloppy ClientIf you use X11 and KDE, you can format floppy diskettes with a point-and-click clientcalled KFloppy. To start this client, click the Utilities menu on your desktop’s panel andthen click KFloppy on the pop-up menu. The KFloppy dialog will appear as shown inFigure 22.1.You can also start KFloppy from the command line of a terminal window bytyping kfloppy & and pressing Enter.FIGURE 22.1Use the KFloppy clientto format floppies forthe ext2 or DOSfilesystems.To format a floppy for Linux, click the File System pop-up menu and select ext2fs. TheKFloppy dialog will automatically select a Full Format. Insert a floppy diskette and clickthe Format button to start formatting. A progress indicator will appear, as shown inFigure 22.2. Click the Abort button if you want to cancel formatting.FIGURE 22.2The KFloppy clientshows a progress barwhen formattingfloppies.


Handling Files and Your File System 489When KFloppy finishes, it will display a dialog reporting whether the floppy was formatted,how many bad blocks, if any, were found, and the raw capacity (in bytes) of the formatteddiskette. (Bad floppies should be discarded.) To format a floppy for DOS, clickthe File System pop-up menu and select DOS. You can then click Quick Erase (foralready formatted disks) or Full Format for the diskette. You can also type a volume labelof up to 11 characters. Click the Format button to start the format.22Fortunately, the kfloppy client will report an error if you try to format amounted floppy. You must unmount your floppy with umount /mnt/floppybefore attempting to format additional floppies.If you’re only interested in DOS floppies, you’ll want to explore the mtools package,discussed next.The mtools PackageThe mtools package is a set of programs you can use in just about any operation on MS-DOS floppies. These commands are useful because you don’t need to mount the floppyin order to read, write, or make changes to the floppy’s contents. These utilities include●●●●●●●●●●●●●●●mattrib—Change file attributesmbadblocks—Floppy testing programmcd—Change directory commandmcheck—Check a floppymcopy—Copy files to and from diskettemdel—Delete files on diskettemdeltree—Recursively delete files and directoriesmdir—List contents of a floppymformat—Format a floppyminfo—Categorize and print floppy characteristicsmkmanifest—Restore Linux filenames from floppymlabel—Label a floppymmd—Create subdirectorymmount—Mount floppymmove—mv command for floppy files and directories


490 Hour 22●●●●●●●mpartition—Make DOS filesystem as partitionmrd—Delete directoriesmren—Rename a filemtoolstest—Test mtools package installationmtype—Types (lists) a filemzip—Zip/Jaz drive utilityxcopy —Copy one directory to anotherThis hour won’t cover all these utilities, but from the list, you should be able to see thatthe most often used are the mformat, mdir, mcopy, and mdel commands. The mformatcommand will format nearly any type of floppy device. One nice feature of this packageof software is that you don’t have to remember the specific names of floppy devices,such as /dev/fd0, and you can use the (possibly) familiar A: or B: drive designators. Forexample, to format a floppy in your drive A:, you would use# mformat a:This will automatically format your diskette. After the mformat command has finished,you can copy files to and from the diskette with the mcopy command, for example:# mcopy *.txt a:This will copy all files ending in .txt to your diskette. To copy files from your diskette,just reverse the arguments (in DOS form) to the mcopy command:# mcopy a:*.txtThis will copy all files ending in .txt to the current directory or a directory you specify.To see what is on the diskette, use the mdir command, for example:# mdir a:x*.*Volume in drive A has no labelDirectory for A:/xena msg 8708 11-21-1997 12:14p xena.msgxgames msg 2798 11-21-1997 12:14p xgames.msgxrpm msg 3624 11-21-1997 12:14p xrpm.msg3 file(s) 15 130 bytes1 067 008 bytes freeTo label the diskette, you can use the mlabel command, for example:# mlabel a:Volume has no labelEnter the new volume label : LINUX


Handling Files and Your File System 491You can also use special shell command-line quoting to label the diskette from the commandline:# mlabel a:’DOS DISK’22This is a handy way to use spaces in a diskette’s label. If you want to delete files on yourdiskette, use the mdel command:# mdel a:*.txtThis will delete all files ending in .txt on the diskette in the A: drive. If you need to performmore than these basic operations (such as use the floppy as a destination in anOpenLinux command line), you can also mount your diskette. For details, see the mmountmanual page, along with the mount command manual page.Now that you know how to manage different filesystems, the next section covers how tomanage your files.Managing File Ownership and PermissionsManaging files in Linux means more than moving files around the file system or keepingfiles grouped by similar behavior or topic. You can change which user or group owns afile or directory and whether you, your group, or others can read, write, or execute (run)your files.The chmod (change access permissions) command, found in the /bin directory, is used togive or take away permission of groups or others to your files. Before you can begin touse the chmod program, you should understand Linux files and how Linux handles filepermissions. In Hour 4, “Reading and Navigation Commands,” you learned how to get along-format directory listing using the -l option with the ls (list) command. This optionshows the mode and permissions flags of files, for example:# ls -l book/*doc-rw-r--r-- 1 bball bball 78073 Nov 16 19:58 book/24hr06or.doc-rw-r--r-- 1 bball bball 52287 Nov 16 19:57 book/24hr11or.docThe mode and permissions flags for directories and files are listed in the first 10 columnsand consist of a sequence of 10 letters. (See the section “Reading File PermissionsFlags” later in this chapter.) The first letter tells you the type of file.


492 Hour 22Understanding Linux File TypesThere are at least eight file types in Linux, but these are the four most common ones:●●●●b—Block device (such as a hard drive)c—Character device (such as a serial port)d—Directory (also a file)l—Symbolic link (a small file pointing to another)You’ll usually find block and character devices in the /dev directory. Your modem orprinter port on your PC will probably be a character device, whereas your floppy drive isa block device, for example:# ls -l /dev/lp0 /dev/ttyS1 /dev/fd0brw-rw-rw- 1 root root 2, 0 Aug 19 04:22 /dev/fd0crw-rw---- 1 root lp 6, 0 Aug 19 04:22 /dev/lp0crw-rw-rw- 1 root uucp 4, 65 Nov 24 13:46 /dev/ttyS1As you can see, the different devices have either a b or a c in front of the permissionsflags (denoting a block or character device). You can also use the ls command to list thepermissions of a directory, using the -d (directory) option, for example:# ls -ld bookdrwxrwxr-x 2 bball bball 1024 Nov 18 19:35 bookThe d in the permissions flag denotes a directory. Symbolic links will also have designatedtype l in the ls -l listing, for example:# touch file1# ln -s file1 file2# ls -l file2lrwxrwxrwx 1 bball bball 5 Nov 23 11:14 file2 -> file1Now that you understand some of the basic file types, the next section shows you how toread the permissions flags.Reading File Permissions FlagsAlthough the permissions sequence of letters might seem cryptic and mysterious at first,you can easily decipher what these mean. To do this, break the sequence of nine charactersinto three groups of three. Each group of characters represents (from left to right)r—The file can be read.w—The file can be written to.x—The file can be executed, or run, or in the case of a directory, searched.


Handling Files and Your File System 493The first group of three characters is for the owner. If you create the file, you can changeany of these permissions. The next group of three characters is for the group. If yourecall the discussion of the /etc/passwd file in Hour 21, “Basic System Administration,”you know that by default, you are assigned to two groups when your account is first created,one with your name and the other to the group users. As the system administrator,or sysadmin, you can organize users on your system by assigning users to differentgroups.22You’ll find a list of groups for your Linux system in the group file in the /etc directory.This file contains a text database of groups. Here are a few sample entries:root::0:wheel::10:bin::1:bin,daemondaemon::2:bin,daemonsys::3:bin,admadm::4:adm,daemon...users::100:bball,cloobiebball::500:bballcloobie::502:cloobieThe format of the /etc/group file is group, password, group number, and a commadelimitedlist of users who belong to the group. This means that you can assign read,write, or execute permissions to your group and allow or deny access to your files. As theroot operator, or sysadmin, you can organize your users into different groups. This isimportant and is one of the reasons you might need to use the chown (change ownership)command, as you’ll see later in this hour.The final set of three characters denotes the read, write, and execution permissions yougrant all other users. Now that you know how to read the permissions, take a look atsome examples before moving on to the chmod program.When you create a file, by default, you and the members of your group have read andwrite permissions on that file. You can change the default of file creation permissionswith your shell’s umask command. (See your shell’s manual page for details.) Here’s asimple example:# touch myfile# ls -l myfile-rw-r--r-- 1 bball users 0 Dec 26 09:29 myfile


494 Hour 22This shows that only you (rw-) can read and write the file myfile, whereas your group(r--) and all others (r--) can only read the file. If myfile were available to everyone onyour system, the permissions would look like this:-rw-rw-rw- 1 bball users 0 Dec 26 09:29 myfileNow, anyone (rw-) can read or write this file. If myfile were only available for readingand writing to you, the permissions would look like this:-rw------- 1 bball users 0 Dec 26 09:29 myfileThis shows that you (rw-), but not your group (---) or others (---), can read the file.How do you change these settings? You use the chmod command.Changing File Permissions with the chmodCommandYou can use the chmod command in several ways to change file or directory permissions.Learning how to use this command is not as easy as 1-2-3, but it is as easy as 4-2-1!You can use the chmod command in at least two different ways. Although you can usechmod to create simple commands from text files, using the +x command-line option (asyou learned in Hour 6, “Using the Shell”), you might want to set exact permissions ofcertain files in your home directory, or as the sysadmin, of critical files on your system.The chmod command uses octal, or base eight, notation in modifying file or directorypermissions. The 4-2-1 sequence corresponds to the three rwx sequences in the permissionsflags.How does this work? Well, suppose you want to make one of your files private so that noone else (except the root operator, of course) can read or write your file. When you firstcreate the file, perhaps you and your group can read and write the file, whereas otherscan only read it. Knowing that 4-2-1 matches rwx, and knowing that the group and otherspermissions follow your permissions in the permissions flag, you can use chmod with theoctal number 600 to change the permissions:# chmod 600 afile# ls -l afile-rw------- 1 bball users 0 Dec 26 14:50 afile


Handling Files and Your File System 495This makes the file readable and writable only by you because you’ve enabled read (4) +write (2) for yourself and no one else. To change the file permissions back to the originalaccess permissions, you would want to enable read (4) + write (2) for you (6) and yourgroup (6) and read-only permissions for all others (4), and use the octal number 664:22# chmod 664 afile# ls -l afile-rw-rw-r-- 1 bball users 0 Dec 26 14:50 afileYou can also change file directory permissions and either let other people list the contentsof your directory or have access only to the files in a directory and not be able tolist the directory contents. For example, to protect a directory from prying eyes (again,from everyone but the root operator), you can try# mkdir temp# cd temp# touch file1 file2 file3# cd ..# chmod 700 temp# ls -ld tempdrwx------ 2 bball users 1024 Dec 26 14:52 tempIf anyone else tries to look into your directory, they will see# ls /home/bball/templs: /home/bball/temp: Permission deniedWhat if you want to allow others to read files in the directory without being able to listthe contents? To do this, you can enable execute permission of your directory:# chmod 711 temp# ls -ld tempdrwx--x--x 2 bball users 1024 Dec 26 14:52 tempNow, no other users will be able to list the contents of your directory but can read filesthat you tell them are within. For example:# ls -l /home/bball/templs: /home/bball/temp: Permission denied# ls -l /home/bball/temp/file1-rw-r--r-- 1 bball users 0 Dec 26 14:52/home/bball/temp/file1As you can see, using the chmod command’s octal notation is not hard. What you have todecide is to whom you want to grant access and what kind of access you’d like your filesto have. The chmod command also has a command-line form:ugoa +-= rwxXstugo


496 Hour 22This book doesn’t go into all the details of this notation (you can read the chmod command’smanual page for more details), but the next few examples duplicate chmod’sactions using the previous examples. You can protect a file from anyone else with# ls -l file1-rw-r--r-- 1 bball users 0 Dec 26 14:52/home/bball/temp/file1# chmod go-rwx file1# ls -l file1-rw------- 1 bball users 0 Dec 26 14:52 file1As you can see, the file is now readable and writable only by you because you havespecified that your group (g) and others (o) do not (-) have read, write, or execute (rwx)permission. Now, you can protect your directory from prying eyes as follows:# chmod go-rwx tempTo mimic the last example, to enable others to read files in the directory but not list thedirectory contents, you can use# chmod go+x tempYou’re now familiar with file and directory permissions and using the chmod command.The next section shows how you can change ownership of files or directories using thechown command.Changing File Ownership with the chownCommand.The chown (change ownership) command, found in the /bin directory, is used to change,either permanently or temporarily, the ownership of files or directories. If you recall theprevious discussion of the /etc/group file in this hour, you’ll remember that your userscan be assigned to different groups. Using the chown command, you can assign ownershipto different users or groups, permitting reading, writing, or deletion of files anddirectories.For example, if you’ve created a text file, you can share it with members of your groupor others with the chmod command. By using chown, you can tell Linux specifically whatother users or groups can have access to your file. You can use the groups command tofind out what groups you belong to:# groupsusers


Handling Files and Your File System 497This shows that the user, bball, belongs to the group users. As the root operator, youbelong to the group root, for example:# groupsroot22To find out who belongs to a group, look at the /etc/group file, or use the name of auser:# groups cloobiecloobie : usersThis shows that cloobie belongs to at least one group, called users. To assign one ofyour files to the users group, and give cloobie access, you can use the chown command’ssyntax of user:group:# chown :users myfile# ls -l myfile-rw-r--r-- 1 bball users 0 Dec 26 15:19 myfileYou might think that to assign specific ownership, you can use the following:# chown cloobie:users myfilechown: myfile: Operation not permittedWhat happened? This shows why Linux has groups. You can assign access of one ofyour files to a group, but unless you’re the root operator, you cannot assign one of yourfiles to appear to have been either created by or owned by another user. Make sure you’relogged in as the root operator, and use# chown cloobie:cloobie myfile# ls -l myfile-rw-rw-r-- 1 cloobie cloobie 0 Dec 26 15:19 myfileAs you can see, even though the file myfile was created by the user bball, as the sysadmin,you can assign ownership to any users and any group. If you just want to changethe group ownership of a file or directory, you can use the chgrp command, and if youwant to change your users or your own group, you can use the newgrp command.Changing Groups and Ownerships with thechgrp and newgrp CommandsThe chgrp (change group) command, found in the /bin directory, is used only to changegroup ownerships. In this regard, it is not as flexible as the chown command, which cando both. The chgrp command accepts a group name or group ID (GID), for example:# ls -l myfile-rw-r--r-- 1 bball users 0 Dec 26 15:26 myfile


498 Hour 22This shows that the file belongs to user bball and group users. To change the groupownership and grant access to other members of the group, use# groups bballbball : bball users# chgrp users myfile# ls -l myfile-rw-rw-r-- 1 bball users 0 Nov 23 14:16 myfileNow, other members of the users group can access the file. Along with the chgrp command,you can use the newgrp command, which is found in the /usr/bin directory.Although the chgrp command will change group ownership of one of your files or directoriesto a group you belong to (or if you’re the root operator, any group), you can usenewgrp to shift your current group membership:# groupsbball users# touch file1# ls -l file1-rw-rw-r-- 1 bball bball 0 Nov 23 14:53 file1# newgrp users# groupsusers bball# touch file2# ls -l file2-rw-rw-r-- 1 bball users 0 Nov 23 14:54 file2# newgrp bballThis shows that the user bball originally belonged to the default group bball. This wasverified by creating a file showing the current user and group ownership. Next, the userbball changed to the users group, created a file, and verified that the created file has thenew group’s access. Finally, the user bball changed back to the original group, bball.The newgrp command will launch a new shell, and you must use the shell’sexit command to return to your original prompt. If you only need to run asingle command as the member of a different group, use the sg command,which will not replace your shell.As you can see, Linux offers you a great deal of flexibility in assigning file ownershipsand permissions. By using different combinations of directory and file ownership andpermissions, you can organize your system along lines of types of work, types of users,or types of files.


Handling Files and Your File System 499Managing Linux Software with rpm, lisa,and kpackageSoftware installation and removal under OpenLinux is accomplished with theRed Hat Package Manager, or rpm command. The rpm command works by usingsoftware packages and databases of installed software for your system under the/var/lib/rpm directory. A software package is an archive of files, information, andscripts used before and after files are decompressed and saved into your file system. Therpm command, its databases, and the format of the software packages are the backendsystem for front-end utilities such as lisa and the kpackage client.NEW TERM22This section introduces you to the rpm command and then shows you how to use thekpackage client and the lisa command to install or remove software.Using the rpm CommandYou use the rpm command to install, query, upgrade, uninstall, and verify software. Whatmakes rpm so handy is that you can use it to easily track what software is installed andwhich version of a software package is installed and then upgrade the software package,and if desired, uninstall the software—all with a single command line!The rpm command has many different command-line options, but most users will onlyuse five of its options, or modes:●●●●●-i, or install-e, or uninstall-q, or query-U, or upgrade-V, or verifyTo install a software package (usually with a filename ending in .rpm), use the -i option,followed by the name of a software package. Software package names usually includethe name of the program, its version, what computer platform the software is designedfor, and an .rpm extension. You must be logged in as the root operator or have root permissionbefore installing or removing software. For example, to install the taper backupsoftware package from your OpenLinux CD-ROM, insert and mount the CD-ROM andthen use rpm:# rpm -i /mnt/cdrom/Packages/RPMS/taper-6.8.2-2.i386.rpm


500 Hour 22To have rpm report on what it is doing, using the -v or verbose secondary option. Ifyou’d like to see a progress indicator, which prints hash signs (#) (hence the -h name forthe option) during the installation, also use the -h option like this:# rpm -ivh /mnt/cdrom/Packages/RPMS/taper-6.8.2-2.i386.rpmtaper ##################################################The software package components will be extracted and copied to the proper directoriesin your OpenLinux file system. After a successful installation, the rpm databases willthen be updated to include the new software. To verify that the taper software has beeninstalled, use the -V, or verify option:# rpm -V taperEverything is okay if nothing happens. However, if any files in the taper package havechanged in size, ownership, or permission, you’ll receive various error messages. To findout more about a package, either before or after installing the software, use rpm’s -q, orquery option. For example, to see a description of the taper software package after installation,use the -q option, along with the secondary i or information option:# rpm -qi taperName : taper Distribution: OpenLinux 1.3Version : 6.8.2 Vendor: Caldera, Inc.Release : 2 Build Date: Wed Aug 19 06:11:401998Install date: Mon Dec 28 14:02:03 1998 Build Host:buildmeister.caldera.comGroup : Administration/Archiving Source RPM: taper-6.8.2-2.src.rpmSize : 425903Packager : Raymund Will URL: http://www.multiline.com.au/~yusuf/Summary : Menu driven backup system with support for compression.Description :This is a tape backup and restore program that provides a friendly userinterface to allow backing/restoring files to a tape drive. Alternatively,files can be backed up to hard disk files. Selecting files for backup andrestore is very similar to the Midnight Commander interface and allowseasytraversal of directories. Recursively selected directories are supported.Incremental backup and automatic most recent restore are defaultssettings.SCSI, ftape, zftape, and removable drives are supportedWARNING: Please note that this is BETA software.


Handling Files and Your File System 501To query a software package before installation, use the -q option along with -i and the-p, or package file option, followed by the pathname to the package like this:# rpm -qpi /mnt/cdrom/Packages/RPMS/taper-6.8.2-2.i386.rpm22You’ll see the same information as shown in the previous example. Do you want to seewhat commands, files, or documentation are included in a package before installation?Use -q along with the -l option:# rpm -qpl /mnt/cdrom/Packages/RPMS/taper-6.8.2-2.i386.rpm/sbin/bg_backup/sbin/bg_restore/sbin/taper/usr/doc/taper-6.8.2/usr/doc/taper-6.8.2/BUGS/usr/doc/taper-6.8.2/CHANGES.html/usr/doc/taper-6.8.2/COMPRESSION/usr/doc/taper-6.8.2/COPYING/usr/doc/taper-6.8.2/CREDITS/usr/doc/taper-6.8.2/FAQ.txt/usr/doc/taper-6.8.2/VERSION6.8/usr/doc/taper-6.8.2/WARNINGYou can also use rpm’s -U, or upgrade option, to upgrade, overwrite, and replace existingsoftware with newer versions. For example, to upgrade to a new version of the tapercommand, use the -U option:# rpm -U taper-6.8.4-2.i386.rpmDeleting software can be a daunting task; many programs have configuration files, supportlibraries, or documentation scattered about the file system. However, if you use rpm,you can easily remove software with a single command line. For example, to remove thepackage for taper, use the -e, or erase option, followed by the name of the program:# rpm -e taperNote that this is not the same as the name of software’s .rpm file! The rpm command willalso check, before removing software, whether the software you’re going to remove willcause problems for other software packages. If this is the case, rpm will report a dependencyerror. This occurs because another package may depend on the installed software.


502 Hour 22If you’re worried about installing or removing software, use rpm’s --testoption. To see exactly what rpm will do, also include the vv, or ultra-verbose,option. For example, to see exactly what rpm will do when it removes thetaper software without removing the software, use a command like this:# rpm -test -evv taperD: counting packages to uninstallD: opening database in //var/lib/rpm/D: found 1 packages to uninstallD: uninstalling record number 88728D: will remove files test = 1D: /usr/doc/taper-6.8.2/WARNING - removingD: /usr/doc/taper-6.8.2/VERSION6.8 - removingD: /usr/doc/taper-6.8.2/FAQ.txt - removingD: /usr/doc/taper-6.8.2/CREDITS - removingD: /usr/doc/taper-6.8.2/COPYING - removingD: /usr/doc/taper-6.8.2/COMPRESSION - removingD: /usr/doc/taper-6.8.2/CHANGES.html - removingD: /usr/doc/taper-6.8.2/BUGS - removingD: /usr/doc/taper-6.8.2 - removingD: /sbin/taper - removingD: /sbin/bg_restore - removingD: /sbin/bg_backup - removingD: removing database entryUsing kpackageThe kpackage client, included with the K Desktop Environment, or KDE, is a graphicalinterface to the rpm program and runs under the X Window system. You must be loggedin as the root operator in order to use kpackage to install and remove software. As withother root-permission commands, if you’re not logged in as the root operator, start theclient from the command line of an X11 terminal window:# su -c kpackageThis will start kpackage, and its window will list the groups of packages installed onyour system (as shown in Figure 22.3).


Handling Files and Your File System 503FIGURE 22.3The kpackage client,included with KDE,runs under X11and uses the rpmcommand’s databasesto display installedsoftware in yourOpenLinux system.22Note that your OpenLinux software is grouped under separate folders. Click the smallplus (+) sign in front of the Archiving folder under Administration and then click thetaper icon. A description of the package will appear, as shown in Figure 22.4.FIGURE 22.4The kpackage clientdisplays informationabout an installedpackage from yoursystem’s rpm database.


504 Hour 22If you click the File List tab, a listing of each file in the taper package and the file’slocation in your Linux file system will appear, as shown in Figure 22.5. To uninstall thesoftware, click the Uninstall button at the bottom of the file information or file list.FIGURE 22.5The kpackage clientdisplays the name ofeach file in aninstalled package andoffers a one-clickUninstall button toremove software.To install a package, select the File menu and then click the Open menu item. Thekpackage file selection dialog will appear as shown in Figure 22.6. If your OpenLinuxCD-ROM is inserted and mounted, you can navigate to the RPMS directory and installby double-clicking its name.FIGURE 22.6The kpackage clientinstalls software usingdrag-and-drop orthrough a file selectiondialog.


Handling Files and Your File System 505Using the lisa CommandThe lisa command is not only a graphical interface program to most OpenLinux systemadministration tasks, but also can install or remove software. Again, you must be loggedin as the root operator in order to install and remove software using lisa. However, youdo not need to run X11.22To jump right into software package management, start lisa from the command linewith its --pkg option:# lisa --pkgThe lisa dialog will appear as shown in Figure 22.7.FIGURE 22.7You can also use thelisa command toinstall or removeOpenLinux software.To install a software package, you must first select the directory or filesystem. PressEnter to choose where the software package is located. A selection dialog will appear, asshown in Figure 22.8.FIGURE 22.8To install softwarewith lisa, you mustfirst choose where thepackage is located.


506 Hour 22If you select CD-ROM, lisa will try to first detect your CD-ROM (you should mountthe CD-ROM first), confirm your CD-ROM, and then present the initial dialog (as shownin Figure 22.7) with the software installation line (line number 3) highlighted. PressEnter to go to the Installation dialog, shown in Figure 22.9.FIGURE 22.9The lisa commanduses a scrolling list offiles in its softwareinstallation selectiondialog.A list of available packages is displayed after the list of .rpm files on your CD-ROM arecompared against the list of installed .rpm files in your OpenLinux system’s rpm database.To select a file, scroll through the list and press the spacebar. When finished, pressEnter to install the software.To remove software, select the software removal item in the main software administrationdialog (as shown in Figure 22.7) and press Enter. You’ll see a list of installed packageson your system (as shown in Figure 22.10). To remove a package, scroll through thelist and press the spacebar. When finished, press Enter to remove the software.FIGURE 22.10The lisa commanduses a scrolling list offiles in its softwareremoval dialog.


Handling Files and Your File System 507To get information about a package, select the information line item in the main softwarepackage administration dialog (as shown in Figure 22.7) and press Enter. The lisa commandwill then query your system’s rpm database and show a list of package names, asshown in Figure 22.11.22FIGURE 22.11To get informationabout a package,scroll through the listof installed software,select a file, and pressEnter.Scroll through the list and select a package with the spacebar, and then press Enter tosee the package information. This information is exactly the same as shown by the rpmcommand’s -qi options.OpenLinux also includes the Caldera Open Administration System, whichfeatures, another graphical interface to your system’s rpm database. COASrequires X11, and uses a large window you can use to install and removesoftware.SummaryThis hour introduced you to the concept of the OpenLinux file system, or the organizationof directories and files for Linux. You also learned about different filesystems andhow to read your OpenLinux filesystem table, fstab in the /etc directory. In addition,you learned how to read and change file ownership and permissions. You also found outhow to query, install, and remove software from your system using three different utilities.All these skills are an important part of knowing how to administer, maintain, andtroubleshoot OpenLinux.


508 Hour 22Q&AQ I tried formatting a floppy with the fdformat command. After I inserted afloppy, typed the command, and specified the /dev/fd0 device, the commandreported Could not determine current format type: No such device. Iknow my floppy works. What’s going on?A It’s possible that you didn’t have a floppy inserted in the drive. If you get this errorwith an inserted floppy, the floppy was not blank and was previously formatted.The best approach to use when performing a low-level format is to specify theexact type of device (such as /dev/fd0H1440) as in fdformat /dev/fd0H1440.Q How do I create a folder for my KDE desktop xe “KDE (K DesktopEnvironment):desktop” xe “K Desktop Environment (KDE):desktop” that,when opened, shows the contents of my Windows partition?A Mount your Windows partition xe “Windows partition:mounting” and then create asymbolic link xe “symbolic links” with a name such as dos inside the Desktopfolder in your home directory. Make sure this link points to the Windows desktopfolder—for example, ln -s /mnt/dos/windows/desktop $HOME/Desktop/dos.Exercises1. Format a floppy and then prepare the diskette with the Linux ext2 filesystem .Mount the floppy and copy files from your home directory to the diskette. Whatutilities did you use?2. Make a backup of your system’s filesystem table and copy it to a diskette. Then,edit your filesystem to allow others to mount and unmount CD-ROMs.3. Open the KDE help application from your desktop’s panel and then click the UsingTemplates to access Applications and Devices item. Follow the directions and createa desktop icon for your floppy drive. After you finish, copy files to your floppyby dragging them from your home folder.


HOUR 23Backing Up andRestoring Your SystemThis hour continues the discussion of basic system administration skills andshows you how, as the root operator, to back up and restore your systemusing several different Linux utilities. With a little practice, you can easilyperform these system administration tasks.Considerations Before PerformingBackups and RestoresThere are several things to consider before backing up or restoring your system.Although one ideal time to back up is after you install Linux and makesure all your devices (such as the sound card, graphics card, or tape drive)are working, there are other considerations. For example, if the kernel suppliedon the CD-ROM works well for your system, you can simply rely onthe CD for your initial backup if you have to do a full restore.


510 Hour 23There is a difference between a backup and an archive. Backups are performed at regularintervals to save important documents, files, or complete systems. Archives are made tosave important documents, files, or complete systems for long periods of time. Thismeans that you should first devise a backup strategy and ask yourself the followingquestions:●●●●●●●●●●Do I need to use a formal backup strategy?Do I need to back up the entire system each time?Do I need to back up selected files or whole directories?How often should I back up?How long do I need to keep my archived copies?Do I need reports or statistics on the backups?What media (such as floppy, tape, or removable hard drive) should I use?What software format (such as tar or dump) should the backup be in?Do I need to use any specialized software tools, such as backup scripts, or can Iperform the backups by hand?Should compression, straight copy, or encryption be used?You can answer some of these questions by looking at the way you use OpenLinux. Ifyou just use Linux for word processing or running spreadsheets, you can probably getaway with only backing up certain files or directories. If you use Linux to learn programming,keep original copies of your programs, along with different versions. If you haveother users on the system, save not only copies of their directories, but the /etc/passwdfile, portions of the file system that take a long time to recreate (such as the entire /etcdirectory), or even the whole system. Do this so that you can quickly restore the systemin the event of a hard drive crash (unlikely) or system operator error (more likely).The size of your system and the capacity of your hard drives or other storage devicesmight be determining factors in approaching a backup strategy. If your Linux system issmall enough (around 200MB), you can quickly back up everything to another hard driveor a tape drive. You also can use a removable media drive, such as an Iomega Zip or Jazdrive or Syquest EZ-flyer. If you only have to save copies of a small number of smallfiles, you might even be able to use high-density floppies for storage.You’ll probably decide on a combination of archiving and regularly scheduled full or incrementalbackups. You need to choose software to use and explore how to automate as muchof the process as possible, perhaps by using crontab entries (discussed in Hour 24, “UsingScheduling to Automate System Management”). Whatever you do, when you decide on yourstrategy, stick to it! The worst time to create and use a backup strategy is after you run intoproblems or lose files.


Backing Up and Restoring Your System 511Configuring the BRU Backup System for Backups andRestoresYou can download a free copy of Enhanced Software Technologies’ BRU 2000 PE bybrowsing to http://www.estinc.com. This is a complete personal edition of a commercialsoftware backup application you can use to back up your system or files using nearlyany tape drive, removable hard drive, and even floppies. This section shows you how toconfigure BRU 2000 PE and highlight selected features of this software, which providesdata verification, error detection, data compression, and selective backup and restores.23The BRU 2000 PE software included with this book’s CD-ROM is exactly thesame as the commercial version of BRU 2000 but does not support the samefeatures (such as network backups). The personal edition is quite adequatefor backup operations on a desktop OpenLinux system.FIGURE 23.1The BRU 2000 backupand restore utility featuresmenus and buttonsto manage Linuxsystem backups.Install the BRU software by using the lisa, rpm, glint or kpackage programs (see Hour22, “Handling Files and Your File System”). The software is installed into the /bru directoryin your file system.You can use the BRU software from the command line or during an X11 session. UsingBRU with X is a lot easier, but you can perform backup operations from the commandline of a console. BRU has more than 50 command-line options you can use to specifyfor your backup process. To use BRU at the command line, type bru [options]. To startthe X interface, type xbru in an xterm window. See BRU’s man page for details.


512 Hour 23When you first run BRU, you must also tell BRU which device to use to back up yourfiles. First, pull down the File menu with your mouse, and then select the Configure BRUmenu item. A window called BRU Configuration Utility appears, as shown in Figure 23.2.You must run BRU as the root operator in order to configure the software.FIGURE 23.2The BRUConfiguration Utilityfeatures severalwindows, including atape device selectionlist.Click the Devices button in this window, and then click the New button. A New Devicewindow, as shown in Figure 23.3, with a scrolling list of different devices appears.FIGURE 23.3You can create newbackup devices to usewith BRU 2000 PE.Click the New button to select a new device from BRU’s built-in list, as shown inFigure 23.4.


Backing Up and Restoring Your System 513FIGURE 23.4BRU lists 37 differentdevices in its tapedevice selection list.23There are 37 different devices listed, including floppy drives. If you don’t see a deviceyou have in the list, select the OTHER device option to create your own. For example, ifyou have an older, floppy-based tape drive that uses the QIC-80 format, select OTHERand specify the tape device (most likely /dev/rft0, the rewinding tape device).To create a backup device using a Zip drive, first select OTHER. After you select thebackup device, type in the Zip drive’s device (/dev/sda4 for a parallel-port Zip drive).To complete your Zip backup device definition, click in the Device Name field, enter ZipDisk, then click the Size field, and enter 100 (make sure to click M to specify the size inmegabytes), as shown in Figure 23.5.FIGURE 23.5You can create yourown BRU device definitionfor an IomegaZip drive backupdevice.To finish the definition, click Save and Exit from the File menu items of the BRUConfiguration window. To begin a backup, insert a Zip disk into your computer’s Zipdrive.


514 Hour 23You don’t have to mount the Zip disk with the mount command; BRU automaticallyuses the disk through the /dev/sda4 device. If you start a backupwithout first inserting a Zip disk, BRU reports an error!To start a backup, first click New Device from BRU’s File menu, and then select/dev/sda4 from the list of devices, as shown in Figure 23.6.FIGURE 23.6Select a backupdevice, such as/dev/sda4, for the Zipdisk before beginningbackup operations.Select Backup from the BRU program’s File menu, or click the top icon in the mainBRU dialog box (showing an arrow going from the disks to a tape).A file selection dialog box appears, as shown in Figure 23.7, which enables you to selectwhole files or directories to back up. After you finish selecting and adding the directoriesor files, click the Options button to select file compression or other options, or click theBegin Backup button to start your backup. BRU asks for a backup name or volume labeland then starts backing up your data. If multiple volumes, or disks, are required, you’reprompted to insert them when needed.FIGURE 23.7The BRU directory andfile selection dialogbox offers selectivebackup sets for archivingdirectories andfiles.


Backing Up and Restoring Your System 515The BRU program has many different features, including compression, scheduling, andtape archive verification. You can find out more about this program by browsing to thefollowing site:http://www.estinc.comBacking Up Your System with the tar CommandAlthough use of the tar command is discussed in Hour 5, “Manipulation and SearchingCommands,” as the system administrator, you need to explore some of the more complextar command-line options and experiment with creating backups before implementingyour backup strategy.23The tar command creates a tape archive. You can write the archive to your hard drive, atape drive, or nearly any other Linux device. To create a quick backup of your users’home directories, use tar to create the archive as in the following example:# tar cPfC users.tar / homeThis command line creates the tape archive users.tar in the current directory. To savedisk space, an even better approach is to use compression when creating your tapearchive. The tar command supports gzip compression with the z command-line option.Just include z in the tape creation command line and revise the archive’s name, like so:# tar czPfC users.tar.gz / homeOne easy way to regularly back up these directories is to save them on a different filesystem. If you have a DOS or Windows partition mounted (see Hour 22), automate thebackup process with an /etc/crontab entry:30 17 * * * root tar czPfC /mnt/dos/windows/desktop/users.tar.gz / homeOnly the root operator can create or modify entries in /etc/crontab.This entry, in the /etc/crontab file, backs up your users’ directories at 5:30 p.m. eachday and saves the archive in the Windows desktop folder. As you can see, automating thebackup process isn’t that hard and has the benefit of working in the background withoutyour attention; this type of process is called an unattended backup. If you save your dataon a separate file system, make sure to mount the drive before trying to restore yourinformation. If you use compression, don’t forget to include the z option when yourestore with the tar command’s x, or extract, option:# cd /# tar xzvf /mnt/dos/windows/desktop/users.tar.gz


516 Hour 23These command lines restore your users’ directories and files, starting at the /, or rootdirectory. The v option lists each file as it is restored. Although backing up files toanother file on your hard drive is easy, you can also use the tar command with tapedrives by specifying the tape device on the tar command line.Unfortunately, there are no utilities to format tapes under Linux. Althoughyou must still use a DOS or Windows utility to do this, you don’t have tobother with formatting if you make sure to purchase preformatted tapes.This hour does not detail all the ins and outs of installing or using different tape devices,but it does show you the general approach and some examples you can try. To use a tapedrive with the tar command, you must find the tape device under the /dev directory.There are a number of them, but I’m using the general floppy tape driver, /dev/ftape, asan example.Although most tape drives can rewind a freshly inserted tape, you can use the mt, ormagnetic tape, command to rewind or retension your tape. Insert the tape, and then usethe following:# mt -f /dev/ftape rewindAfter the tape rewinds, erase it with the mt command’s erase option:# mt -f /dev/ftape eraseAfter the tape is erased, you can write a tar archive to the tape by specifying the/dev/ftape device:# cd /# tar cf /dev/ftape /homeThis command creates a tape archive of all the files and directories under the /homedirectory. To restore your tape archive, you must use the tar command’s x option:# cd /# tar xf /dev/ftapeThere are many more options with the tar command. Explore some of them, such as thed option to test archives. For more information, see the tar manual page and read theftape HOWTO under the /usr/doc/HOWTO directory.


Backing Up and Restoring Your System 517Using the cpio Command to Backup and RestoreThe cpio, or copy in and out, command can be used in much the same way as the tarcommand, but with several differences, especially with archive creation or extractioncommand-line options. For example, to create a cpio archive, you must use the -o, orcreate, option. The cpio command also requires a list of filenames, with paths, to buildan archive. To do this, use the find command, which handily creates the required namesfor you.For example, if you have a directory called x11 that contains a number of files you wantto archive, you can combine the output of the find command with the cpio command tobuild the archive, as follows:# find x11 | cpio -ov >x11.cpiocpio: x11: truncating inode numberx11x11/xfree86faq.txtx11/xappsfaq.txtx11/x11faq.txtx11/disaster.txtx11/XHints1.txt1082 blocks23This command line shows that the cpio command has been fed the names of the filesinside the x11 directory, creating an archive with the -o option and showing you the filesbeing added with the -v option. The name of the archive is x11.cpio, and it is createdusing the greater than, or >, redirection operator.To restore a cpio archive, use the cpio command’s -i, or extract, command-line option:# cpio -i < x11.cpio1082 blocksThis command line shows that to extract a cpio archive, you can use the less then, or today.cpio


518 Hour 23This command line creates a cpio archive called today.cpio that contains all filesyou’ve modified in the last 24 hours. You’re only limited by your imagination in how todevise your backups and how to back up your system. For more information on the cpiocommand, read its manual page. For more information about the find command, seeHour 5, or read the find manual page.Using the taper Script for Tape Drive Backups andRestoresThe taper program, by Yusaf Nagree, is a backup and restore program used to createcompressed or uncompressed archives of selected files or directories. This program providesa nice interface to create and maintain tape archives. You also can use other typesof media to do your backups.Using the taper command is easy. Specify the type of media to use with the -T mediaoption. According to the latest documentation, the taper command supports the followingoptions:●●●●●ftape—floppy drive:tape driver that is included with your system and is used fortape drives that attach to the floppy interfacezftape—more recent floppy drive tape driver that handles additional tape formatsscsi—driver for tape drives using a scsi interfaceide—driver to support ide tape drivesremoveable—driver to support floppies, or removeable hard drivesIf you don’t have a tape drive but would like to try the taper program to test a backup ofa directory to floppy diskettes, use the -T command-line option with the removableoption:# taper -T removeableThis starts the taper program, as shown in Figure 23.8. taper uses the default removeabledevice, /dev/fd0, which is the floppy. To change the type of device to use a Zipdisk, scroll down to the Change Preferences item, and press Enter. In the following dialogbox, press Enter at the Tape Drive Preferences item.In the Tape Drive Preferences dialog box, as shown in Figure 23.9, change both instancesof /dev/fd0 to /dev/sda4, which is the default Zip disk device. Press Esc, and return tothe main menu. In the main menu, press Enter at the Backup Module item.


Backing Up and Restoring Your System 519FIGURE 23.8The taper scriptprovides a graphicinterface for archivesor backup operationsof directories and files.23FIGURE 23.9You can use differentbackup devices, such as/dev/sda4, for a Zipdisk during your taperbackup operations.In the taper selection dialog box, as shown in Figure 23.10, you’re asked to select filesor directories before you start the backup. Scroll through the list of directories and files,and select items by pressing the I key. To get help, press the H or ? keys. When you finish,press the F key to start the backup operation.The taper program has many different features. Its documentation is under the/usr/doc/taper directory in the file FAQ.txt.


520 Hour 23FIGURE 23.10Scroll through thetaper selection dialogbox, selecting files ordirectories to back upwith the I key.SummaryThis hour introduced you to different programs and ways to back up your OpenLinuxsystem. Performing periodic backups is an important role for a system administrator, andperfecting the practice of preserving your system and important files enhances your computingexperience.Q&AQ I don’t want to use floppies to back up my system. I don’t have a removeablehard drive. I also don’t have a tape drive. What’s the safest approach I cantake to back up important files?A You can at least back up your /etc directory. This directory probably containsfewer than 2.5 megabytes of files, which can be backed up to two floppy disks.Another method you can use is to back up important files to another partition (suchas a mounted msdos or vfat partition). If you have the hard drive space, you canalso create a small spare Linux ext2 partition to hold periodic backups of your system’sconfiguration files. If something happens to your root partition, you can thenrestore from this spare partition.Q Help! My system has crashed! I didn’t back up my files! What can I do?A First, don’t panic! You did back up your important files, right? Do you have anemergency boot disk on hand? It might be possible to recover some files by bootingwith the emergency boot disk and then attempting to mount your OpenLinuxpartitions with the boot disk’s mount command. If your Linux partitions still exist,it might also be possible to dump the contents of a partition to a compressed file onanother volume and then extract pertinent files by hand (although this is tediousand not guaranteed). Always have a boot disk with recovery utilities on hand!


Backing Up and Restoring Your System 521Q What’s the best backup medium to use?A There are many different types of removeable media on the market today. In thelast 10 years, the price and cost per megabyte (a possible yardstick) of removeableoptical drives has come down quite a bit. You have to decide on a balance of cost,speed, and reliability. You already have a wonderful backup included with thisbook—your OpenLinux CD-ROM, which is a working archive of nearly all thesoftware used in this book. If you carefully preserve your /home and /etc directories,you can recover from a hard drive disaster to a working system within minutes.23Exercises1. Use the tar command to create a compressed archive of your /etc and /homedirectories. How large is the file?2. Use the du command to estimate the size of your OpenLinux system. How else canyou find out how much space is required?3. Investigate ways to prepare for a hard drive disaster. If your hard drive crashes,what files do you most fear losing? What steps can you take to prevent losing thesefiles?


HOUR 24Using Scheduling toAutomate SystemManagementIn this hour, you’ll finish by learning basic system administration skills. Bynow you know most of the commands used by sysadmins and are familiarwith most of the tasks you have to perform to maintain your system foryourself or other users. This hour shows you how to put all this knowledgetogether in order to automate these tasks using the cron daemon and otherOpenLinux scheduling programs.By using the programs and techniques outlined in this hour, you can automatemany different system administration jobs and maintain a healthy,well-running system. The first topic is the cron daemon, and then you’lllearn how to administer the at command facilities for different users on yoursystem.


524 Hour 24Using the cron DaemonThe cron daemon, crond, is a program that starts after you boot Linux by the cron scriptin the /etc/rc.d/init.d directory on your system. This is done automatically, so youdon’t have to worry about starting the cron daemon every time you boot Linux. Thecrond program runs in the background and checks several files. The first is the crontabfile in the /etc directory. A portion of this file reads as follows:...03 3 1 * * root [ -x /usr/sbin/cronloop ] && /usr/sbin/➥cronloop Monthly04 4 * * 6 root [ -x /usr/sbin/cronloop ] && /usr/sbin/➥cronloop Weekly05 5 * * * root [ -x /usr/sbin/cronloop ] && /usr/sbin/➥cronloop Daily42 * * * * root [ -x /usr/sbin/cronloop ] && /usr/sbin/➥cronloop Hourly...As you can see, this is a list of commands that runs tasks hourly, daily, weekly, andmonthly. The cronloop command is a shell script that looks in the /etc/cron.d directoryand then runs assigned tasks (in the form of shell scripts) according to files found inthe Monthly, Weekly, Daily, and Hourly directories under /etc/cron.d. The actual shellscripts are found in the lib directory under the /etc/cron.d directory.For example, if you look at the contents of the Daily directory, you find a file called50update-locatedb that is linked to a shell script called update-locatedb in the/etc/cron.d/lib directory. This shell script, according to the preceding Daily/etc/crontab entry, builds a new database for the locate command at 5:50 a.m. eachday:#!/bin/bash# Make/update the file name database. /etc/cron.d/lib/functionsTMPDIR=$(cronloop_mk_TMPDIR)declare -rx TMPDIR# remove TMPDIR on exittrap cronloop_rm_TMPDIR EXITOMIT=”/tmp /proc /mnt /var/tmp /var/spool /dev /net /auto /amd /NetWare”/usr/bin/updatedb --prunepaths=”$OMIT” --netuser=nobody 2> /dev/nullexit 0


Using Scheduling to Automate System Management 525You can see that this script executes the updatedb command to build your system’slocate database (see Hour 4, “Reading and Navigation Commands”).The cron command also searches the /var/spool/cron directory for personal crontabfiles with users’ names. These files are created with the crontab command, found underthe /usr/bin directory, and are used by your users to schedule their own regular tasks.How do you tell cron when to run these scripts, and how do you know that that locatedbscript is run at 5:50 a.m. each day? Read on to see the format of the cron commands.Managing User cron SchedulingThe /etc/crontab file is for scheduling regular, systemwide tasks. However, OpenLinuxenables users to create their own cron schedules. As the root operator, if you want toenable your users to use the crontab command to create personal cron files under the/var/spool/cron directory, you first create two files: /etc/cron.allow and/etc/cron.deny. Under the /etc/cron.allow file, insert the root operator name, root,and the names of any users you want to enable access to the cron daemon. Because neitherof these files exists in the default OpenLinux installation, all users have access topersonal cron files. You can create files for your users with the crontab command, orusers can create their own.24Always use the crontab command’s -u command-line option. If you runcrontab while running as root (after using the su command) and don’t usethis option, you receive a usage error message.The next section shows you the format of the crontab file and the difference between theformat of a cron entry for your Linux system and for individual users.Setting Schedules with the crontab CommandThe format of crontab entries is detailed in the crontab manual page under section 5.To see the manual page, use the following:# man 5 crontabThis page provides specifications for crontab entries. However, to make things simpler,I’ll give you some examples and at the end of this hour, some samples you can use. Ingeneral, the fields of an entry are as follows:minutes hour day of month month day of week command


526 Hour 24Entries are usually separated with a space. However, cron entries in the /etc/crontabfile must have a username inserted between the day of week entry and the command. Ausername field is not needed for personal crontab entries.For example, if you run OpenLinux on a laptop but find that OpenLinux loses time afteryou wake up your laptop from a battery-saving sleep, edit the /etc/crontab file as root,and insert a command to update OpenLinux’s time every minute from the laptop’s hardwareclock. Use the hwclock commmand in your crontab entry like so:* * * * * root /sbin/hwclock --hctosysAnother handy entry can be used to build the database for the whatis command. Forexample, if you know that few users are present on your system early in the morning,schedule the makewhatis command to run at 2 a.m. with this setting:30 2 * * * root /usr/sbin/makewhatisOn the other hand, as a regular user, you can have OpenLinux tell you the time every 15minutes by first calling the crontab command with the -e command-line option, andthen adding the following:0,15,30,45 * * * * /usr/local/bin/saytime %By default, OpenLinux launches the vim editor when you use crontab withits -e option. See Hour 18, “Personal Productivity Tools,” for a tip on how touse the pico editor instead.This tells the cron daemon to execute the saytime command to speak the time every 15minutes. You can find the saytime command at the following:http://metalab.unc.edu/pub/Linux/apps/sound/speech/saytime.tgzIf you want to hear the time every minute (though it might drive you crazy!), you can usethis:* * * * * /usr/local/bin/saytime %Note that if you don’t use a carriage return at the end of the line in your entry, youshould use a percent (%) sign.Here are some more sample entries:* 22 * * 1-4 /usr/bin/wall ‘Time for bed! Finished your homework yet?’ %0 1 * * * /usr/bin/find / -xdev -name core -exec /bin/rm {} \; %0,30 * * * /usr/bin/tput bel >/dev/console %* 12 25 12 * /bin/echo ‘Happy Holidays’ | /bin/mail -s Greetings root %


Using Scheduling to Automate System Management 527The first example broadcasts a gentle reminder to all your users using the wall commandat 10 p.m., Monday through Thursday; the number 22 represents the hour in 24 hour format,whereas the digits 1-4 represent Monday through Thursday. The second example(probably best suited for an /etc/crontab entry) runs the find command to search yoursystem at 1 a.m. each morning for core files and deletes any found. The third rings yourterminal’s bell on the hour and half hour (0 and 30 minutes), using the tput command tooutput. The last example sends a mail message at noon on December 25 th to the rootoperator.The format and details of the fields in a crontab setting are explained indetail in Hour 18. These settings are also outlined in the crontab man pagein section 5 of the man pages. See this man page for other sample settings.24Experiment with different tasks and times. Use OpenLinux to directly search results forfiles, reports of users online, and uptime reports to log files. Or use OpenLinux to emailthe information to you. You can also use cron to schedule backups when you’re away orhave your system shut down at a preselected time.Managing User Scheduling with the atrunCommandThe cron daemon is useful for scheduling regularly run programs or performing regulartasks, as you found out in Hour 18. The at command is useful for onetime or reminderjobs. Even though your Linux system is set up automatically after installation to handleuser at scheduling requests, you should know how to manage the at command facilities.By default, when a user uses the at command, the command is run with a default CPUpriority. If too many users start running tasks with higher priorities or CPU-intensiveprograms in the background, your system’s performance can be affected. Read on tolearn to manage your system’s at command facilities to provide the best performanceand control possible.Your system’s at command facilities are enabled by the cron daemon, which, after startingwhen you boot Linux, checks the /etc/crontab file and sees the following entry:...# Run any at jobs every minute* * * * * root [ -x /usr/sbin/atrun ] && /usr/sbin/atrun...


528 Hour 24As you can see, this is why the at command depends on the cron command: the croncommand runs the atrun command, found under the /usr/sbin directory, each minuteyour system is up. The atrun command, in turn, searches the /var/spool/atjobs directoryto look for jobs to run. For example, if the root operator creates a job at 14:46 forthat day (2:30 p.m.), you see the following:# at 14:46at> echo Helloat> warning: commands will be executed using /bin/shjob 11 at 1998-12-14 14:46# ls -l /var/spool/atjobstotal 1-rwx------ 1 root root 842 Dec 14 14:43 a0000b00e85b62To create an at command, use the word at, followed by a time. After you press Enter,the at > prompt appears. You can then enter a command and press Enter. To quit enteringcommands and save your job, press Ctrl+D. The at command then tells you the job numberand the date and time the command executes. As you can see in the atjobs directorylisting after entering the command, there is a job waiting for the root operator.You can get more specific information about waiting at jobs with the atqcommand. If you’re the root operator, you see all the jobs your users havescheduled, instead of just the ones you’ve scheduled.Controlling the batch and at CommandsNow that you know how the at facilities run, how do you control how at works, and forwhom, on your system? One way to control how at works on your OpenLinux system isto use the atrun command’s -l (load average) option. This option controls any jobs submittedby users using the batch command (discussed in Hour 18 with the at command).You can limit when batch jobs are run by specifying a number lower than 1.5 (thedefault), which tells atrun to run batch jobs only when the system load average is low.The load average is determined by a value in the /proc/loadavg file while the system isrunning.You can see the current load average with the following:# cat /proc/loadavg0.20 0.11 0.03 2/50 1228


Using Scheduling to Automate System Management 529This shows the load average for the last 5, 10, and 15 minutes. You can also get the loadaverage by using the uptime command, for example:# uptime7:40pm up 2:44, 3 users, load average: 0.13, 0.08, 0.02To enable your users to use batch nearly any time, change the value of the -l option inthe atrun command entry in your system’s /etc/crontab file to a number higher thanthe default 1.5 value.How do you control whether users are enabled to use the at command on your system?By default, after you install OpenLinux, anyone on your system can use the at command.There are four ways to control who can use the at command. Look in your/etc directory, and find a file called at.deny.For security reasons, the at.deny file contains a list of OpenLinux users, including daemonsor other processes, who are not enabled to use at. However, everyone else can usethe at command to schedule jobs. If you want to prevent a user from using the at command,put the user’s username in /etc/at.deny. If you don’t want anyone on yoursystem to use the at command (of course, this doesn’t apply to you because you’re theroot operator), either create an empty at.allow file or delete the at.deny file from your/etc directory. If you want to enable only certain users to use the at command, create afile called at.allow in the /etc directory, and put the user’s username in the file. If theat.allow and at.deny files are removed from the /etc directory, only the root operatorcan use the at command.As a final, desperate measure to control at jobs as the root operator, list all at jobsscheduled on your system with the atq command, and if you see too many jobs scheduled,delete them with the atrm command, for example:# atqDate Owner Queue Job#20:00:00 11/26/97 bball c 1220:10:00 11/26/97 bball c 1320:15:00 11/26/97 bball c 1420:30:00 11/26/97 bball c 15...# atrm 12 13 14 15 ...24Here, I’m assuming you see a long, long list of job numbers, and delete them. This is anabrupt, rude way to handle enthusiastic users. A better method might be to email the userto find out if there are tasks being run that can be automated during off-hour or off-peaktimes.


530 Hour 24As the system administrator, you have complete control of scheduling commands for theusers of your OpenLinux system. Think about tasks you should run hourly, daily, weekly,and monthly. With a little imagination, you can soon automate any custom tools, commandlines, and reports you’ve created to help you manage your system. You can end upwith more disk space, a better running system, and happier users.SummaryThis hour introduced you to a valuable skill required of all system administrators—thecapability to schedule and automate complex tasks at any required date or time. This isone of the secrets to becoming a successful system administrator—to initially spend thetime crafting a general-purpose approach or tool for system maintenance that can be usedover and over again.Q&AQ I’d like to have my computer automatically connect to the Internet during theearly morning hours and then download the day’s news and email the news tome. Is this possible?A Yes. Use the name of a shell script in your system’s crontab file to initiate theconnection, temporarily sleep, wake up, and then download and mail the news. Forexample, the lynx browser’s dump option can be used with the mail command likethis:lynx http://some.newsource.com/news.html –dump | mail➥–s “news” rootExercises1. Create personal crontab settings to remind you several days in advance of importantdates, such as anniversaries or birthdays. What do you think is the best way tohave OpenLinux notify you?2. Draw up a list of some important tasks to automate. How can you do this? Whendo you run the tasks?


INDEXSymbols% operator, 133? option, 76$EDITORenvironment, 403variable, 320, 403$HOME environmentvariable, 139$PATHenvironment variable,128variable, 127$PRINTER, 355$PS1 environment variable,129$REMOTE_IPstring, 232variable, 232$TERMCAP variable,129’ol bit bucket, 139+rv (reverse video)option, 162+x option, 494-- -bpp (bits per pixel)option, 179-- -bpp 16 option, 146-- -bpp 16 startx option,374-9 option, 464–9 signal, 463-a limit option, 462-a option, 79, 334, 462-atime option, 74-b (backup) option, 99,101-b option, 99, 333, 456-bd option, 162-bg option, 161-boardSize small option,442-bpp 16 option, 145-bpp option, 145—bytes option, 456-C (color) option, 278-C cls2 option, 219-C command-line option,389–c option, 245, 253, 453,459, 487-calendar option, 406–clear option, 394—color option, 80-COLUMN option, 339-component-bar option,301-d (decompress) option,82, 91, 114-d (delete) option, 139-d (directory) option, 492–d option, 141, 253, 331-digital option, 175-display command, 400-e (empty) option, 139-e (erase) option, 501-e (uninstall) option, 499-E option, 110, 159, 342,403, 413, 526-exec option, 459-f (flood) option, 245-f (script file) option, 332-F option, 79-80, 96, 109,112, 333, 401—fetchmailrc option, 252-fg option, 161


532 -fr option-fr option, 96-97—full-time option, 94-fullscreen option, 169-grab option, 445–gray option, 394-h (halt) option, 38-h (help) option, 139-h option, 275, 499-Ha option, 462-help option, 76, 84, 301,369-i (extract) option, 517-i (install) option,499-500-i (interactive) option, 95,99-101, 130, 134-inroot option, 172-k (keep) option, 252-K option, 78, 456—kilobytes option, 456-l (list shells) option, 472-l (list) option, 114, 139,333, 405-l (load average) option,528-l (long) format listing,330-l mode, 333–l option, 213, 333, 340,487, 491, 501usage, 464-lock option, 171-M command-line option,88-m option, 79, 487-mail option, 260—modem option, 201–mono option, 394-mtime option, 74, 517-n 2 option, 89-n option, 84, 91, 273-news option, 282—nosplash option, 369-nw (no-window) option,316-nw option, 409-o (create) option, 517-O option, 342-out option, 167-p (package file) option,500-p (parent) option, 97-p option, 98, 102, 252—pkg option, 503-pointsize option, 394-popup option, 407-q (query) option, 89,499-500-qi options, 505-r (reboot) option, 38-r (recursive) option,95-96, 101, 457-r (remove) option, 405-r (restart) option, 475-r option, 50, 82, 219,273, 342—remove-files option,111–rpn option, 383-rv (reverse video)option, 162-s (squeeze) option, 330-s command, 461-s option, 103, 118, 255,453-size option, 442-sound option, 445-speed option, 445-stipple option, 383—summarize option, 456-T media option, 518-t option, 114, 342, 345,455, 457, 475, 518—test option, 501-topbottom option, 368-tv option, 114–tvtwm option, 394-U (upgrade) option, 499,501-u option, 252, 319, 475,525-update 1 option, 175-user option, 517-useradm option, 469-v (verbose mode) option,487-V (verify) option, 499-v option, 112, 219, 517-w 60 option, 342-w option, 149, 204-x (extract) option, 79,112-x option, 457-xdev option, 75-xrm option, 162-z option, 110.GIF, 360.GIF format, 298, 368.GIF graphics, 374.html files, 377.JPG, 360file, 375graphics file creating,367.PCX, 360.pdf documents, 377.pdf files, 377, 416.ppm format, 368.TIF, 360.tiff file, creating, 368.xpm format, 367/boot directory, 50/dev/modem, creating,lisa command usage,201/etc/fstab, 482/JOIN command, 305/LEAVE command, 305/LIST command, 305/proc directory, 483/QUIT command, 3050x224, 130x382, 133Com Palm PilotProfessional, 123Com/U.S. Robotics, 2243D graphics, 391, 393generation, 391


ash shell 5333D scrollbars, 1513D video card, 2253D window buttons, 1514-2-1 sequence, 494490-based AMD CPUs,1156K ITU V.90 modems,129-pin male serial port,200Aabbreviated hostnames,297about\ mozilla, 303abuse, 442accelerated video graphics,43account expiration, 471account information, 228account name, 241account programs, dialin,251acm, 442Acrobat (Adobe), 377active image window, 371active Internet connection,304, 308, 436adduser command, 469usage, 469Adobe Acrobat, 377Adobe PhotoShop, 369adventure game, 440AfterStep, 155starting, 155usage, 156window manager, 152,155, 157agents, 250transport, 250user, 250, 253usage, 251AIM (AOL InstantMessenger), 306alarm dialog, 408box, 412alarms settingknotes client usage, 411Albanowski, Kenneth, 12Almquist, Kenneth, 119Alpha chip, 9amaya Web browser, 310ambient light conditions,176America Online (AOL),300Web site, 306America Online InstantMessenger (AIM)configuring, 306installing, 306amstex system, 356animationusage, 175selection, 172anonymous access, 308anonymous ftp connection,291AOL (America Online),300, 306Web site, 306APOP, 252appearance, 152append redirection operator,125Apple Macintosh, 176appliance directory, 295applicationdefault settings, 163resource file, 164Application Starter, 184,216, 234, 278, 323button, 180, 189, 192menu, 189, 195application-launchingdefinitions, 152Applix, spreadsheets, 391Applix Words, 327-328Applix, Inc., 327Applixware, 327-328, 391productivity suite, 329spreadsheet program,commercial features,393Appointmentscalendar, 175cron-type scheduling,406entering, 411keeping, emacs usage,409listing, 408reminders, 409creating, X11 icalclient usage, 405time, 411appt-delete command,411apropos command,77-78, 410, 447usage, 72apropos program, 71ar command, 79archived copies, keeping,510archivescpio archives, creating,113creating, tape archive(tar) command usage,110-113archiving, 509Exercises, 521Q&A, 520Summary, 520Artwork, installed, list,422as command, 79ASCIIcommand, 290database, 349file formats, 390list, 334


534 at (AT) commandash shell, 118-119at (AT) command, 79,206, 208, 238, 400-401,403, 413controlling, 528creating, 528string, 207, 209usage, 400, 527, 529at scheduling requests,527AT&T System V UNIX,480AT&V command, 209ATA/IDE card drives, 57ATA/IDE CD-ROMinterfaces, 57ATAPI, 13ATDT, 233ATI Rage II, 14atjobs directory, 528ATLx command, 221ATM machines, 226ATM0, 234command, 221ATM1 command, 221atq command, 401,528-529atrm command, 402, 529atrun command, 529usage, 527Attorney General, 264,268Auto Spellcheckenabling, 427AutoFormat ChartStarCalc, 431dialog box, 431AutoPilot, 423selecting, 424Aztech Systems, 224Bb file type, 492backend system, 499backgammon, playing,X11, 444background, 374background colors, 160,278setting, 168background installation,23background operator,214background pattern, setting,168background processes,119, 131background settings, 152backspace key work, 433backupBRU backup systemconfiguring, 511cpio command usage,517device, 513devices creating, 512full, 510incremental, 510medium usage, 521name, 514network, 511performing considerations,509scripts, 510strategy, 510devising, 510need, 510taper Script usage, 518tar (tape archive) commandusage, 515unattended, 515utilityBRU 2040, 511backup (-b) option,99-101backup (BAK) files, 459backup copy, 474badblocks command, 487BAK (backup) files, 459bash (Bourne AgainShell), 30manual page, 140, 141bash (Bourne AgainShell) shell, 121, 124,127-128, 138, 272, 403,406, 459, 462, 472features, 120running, 132usage, 139BASIC, 396language, 395basic system administration,451batch command, controlling,528baud rate, 199, 205, 210,348bball, 497user, 135, 498bball user, 350BBS (Bulletin BoardService), 221BBS (bulletin boardsystem), 204, 208, 232bc calculator, 396bc command, 387language, 387bc language interpreterusage, 386bc manual page, 386Beamer, 422usage, 423BeOS, 35Berkeley SoftwareDistribution (BSD), 317,480bg command, 132biff man pages, 267binary command, 290


cd (change directory) command 535binary transfer mode,295BIOS, 15, 19manager, 24Bischoff, Michael, 444bitmap client, 379bitmap directories, 379bitmap file format, 220bitmap graphics files, 168bits, number, 207bits per pixel (-- -bpp)option, 179block device, 492block devices, input/output,461block moves, 319blueprints, 379boldfacing, 337bookmarks, 83, 297editor, 297boot device, 24boot disk, emergency,520boot diskette, 17boot problems, 474boot-prompt option, 149BootMagic, 18, 32, 38installing, 19, 33setup window, 32borders, settings, 151Bourne Again Shell(bash) shell, 120-121Bradley, John, 375Brief, 321Brown, Mark, 299Browsing, files, less command,87-88BRUbuilt-in list, 512configuration utility,512configuration window,513device definition, 513directory, 514file selection, 514software, 511BRU 2040, 511restore utility, 511BRU 2040 PE, 511-512software, 511BRU backup system,configuring, 511BRU-2040, 113, 180brushes, 369-371BSD (Berkeley SoftwareDistribution), 42, 480built-in calendar, 409built-in help, 178,318-320, 322, 327, 406command, 138, 290built-in list, BRU, 512built-in telecommunicationsscripting language,206built-in text editor, 206builtins command, 122Bulletin Board Service(BBS), 221bulletin board system(BBS), 204, 208, 232burn-in effect, 169BusMouse, 46buttons, 151, 156mouse, 159bye command, 295, 291bzip2 command, 115Cc (create) option, 111c file type, 492C language, 395C-Kermit, 225CAD-like companion,396cal (calendar), 405program, 174calculatingkcalc client usage, 383X11 xcalc client usage,383calculator programming,bc language interpreterusage, 386calculators, 382Caldera, 7, 11, 23, 34,148, 228, 264, 266, 328splash screen, 24Caldera OpenAdministration System(COAS)System menu, 64usage, 53, 61Caldera System, 9, 177Web site, 352calendar (cal), 405appointment, 175built-in, 409checking, emacs usage,409display program, 174mode, 410-411printing, 406program, 174size, 406views, 405calendar filesautosaving, 405group sharing, 406importing/exporting,405candidate files, 460Canon BJC80, 12capture software packages,379Card Services, 58Cardinal, 224carriage return, 340Casas, Ed, 211case statement, 139


536 CD Database (CDDB)cat (concatenate) command,84-86, 88, 91,116, 125, 329usage, 80-81cd (change directory)command, 73, 79, 105,118, 290, 295usage, 72, 91, 416CD Database (CDDB),437CD music playingkscd client usage, 435xplaycd client usage,435CD-ROM controllertype, 13CD-ROM drive interfaces,10ATA/IDE, 57cdda2wav command, 447CDDB (CD Database),437Editor dialog box, 437CDE (Common DesktopEnvironment), 178cdpstarting, 439command, 439cdplay, 439cell movement, drag-anddrop,391, 393cell selection, 429Central Processing Unit(CPU), 8-9, 12, 225, 464activity, 461type, 13change access permissions(chmod)command, 56, 126, 136,204, 491, 495usage, 138, 436, 494program, 493change directory (cd)command, 73, 79, 105,118, 290, 295usage, 72, 91, 416change group (chgrp)command, 497change ownership(chown) command, 105,493, 496channel number, DMA,47character device, 492character mode devices,347chart graphics, 432chatdiscussions, 310manual pages, 247program, 227, 231, 246Chen, Peter, 221chess playing, xboardclient usage, 442chfn command, 469usage, 471chgrp (change group)command, 105, 497child directory, 97Child subdirectory, 97Chimera, 299chipset, 14chmod (change accesspermissions)command, 56, 126, 136,204, 491, 495usage, 138, 436, 494program, 232, 493chown (change ownership)command, 105,493, 496chsh command, 118, 130,453, 472Cirrus Logic, 14civ command, 447civclient command, 447civserver command, 447cksum command, 329cleanup operations, 458Client buttons, 181clientconfiguration, 162program, resources, 162resources, 162windows, customization,160clock client, 402clockchips, 45, 47cloobie, 497directory, 469user, 470close command, 291cmdlnopts, 139cmdtool program, 158COAS (Caldera OpenAdministration System)system menu, 64usage, 53, 61code modules, 50loadable, 50Collabra Discussions, 282color, 151, 421, 425background, 160setting, 168custom, 319, 323foreground, 160image, 374monitor, 168name, database, 46printers, Epson Stylus,352server, 48settings, 151, 317visual mode, 293window, 153color (-C) option, 278color depth, 45, 48, 148capability, 14usage, 145X11 server, 168color-capable terminalemulator, 158-159window, 389color-capable X11 consolewindow, 159colormapoption, 374table, 374


cp command 537column separator, 342comm command, 329comma-delimited list,493command interpreter,118command line, 296terminal, 374command summary, gettingapropos commandusage, 76whatis command usage,76command-line access,157command-line argument,127, 137command-line editing,119, 319command-line editor, 122command-line history,119command-line operators,119command-line option,119-122, 130, 139,158-162, 169-171, 212,214, 219, 244, 275, 290,299, 301, 316, 319-320,330, 332-334, 338-339,345, 374, 376, 389, 394,400, 402, 406-407, 409,442, 445, 452-453, 455,457, 459, 461, 466, 469,494, 515, 517-518,525-526command-line programs,468command-line prompt,121options, 123usage, 119command-line redirectionoperator, 254command-line shelldialog box, 207Common DesktopEnvironment (CDE),178communicationsprogramcalling outminicom programusage, 204seyon X11 clientusage, 206dialing out, 203setting upminicom programusage, 204seyon X11 clientusage, 206usage, 199Exercises, 221Q&A, 221Summary, 220component programs,415compress command,usage, 114compressed text file, 201compressing files,110-112compress command,114gzip command, 114compression, 515usage, 510utilities, 115computerabbreviated hostnames,297connection, telnet commandusage, 308memory, 460monitors, 169programs, 359software, interfaces,314concatenate (cat) command,84-85concatenate redirectionoperator, 125config command, 286configurationdialog box, 235menus, 152rules, 349configuration file, 119,151, 501fvwm, 151, 155processing, 152configure command, 216Connect button, 239connection speed, 237Connectix, 378consolegames, 439keys, 453programs, interactive,160consoles, virtual, 9context-sensitive help,327controller type, 13conversion programs, 360graphics, 368convertcommand, 367-368,373man pages, 368usage, 368man page, 367program, 368copy, straight usage, 510copy in and out (cpio)archive, 517, 518command usage, 517copying, files, cp commandusage, 100-102Copying/pasting operations,KDE usage, 166core dump, 45, 459, 462


538 CP/M operating systemCorel, 338, 354WordPerfect 8.0, 313,326cp command, 48, 96,101-102, 105, 141, 209usage, 100-102CP/M operating system,321cpio (copy in and out)archive, 517-518creating, 113command, 124usage, 517program, 109CPU (Central ProcessingUnit), 8-9, 12, 225, 464activity, 461priority, 527type, 13CPU-intensive programs,527create (-o) option, 517Create (c) option, 111CRiSPlite editor, 180printing, 336usage, 324Cristy, John, 373cron command, 95, 525cron daemon (crond),403, 525-527usage, 524cron scheduling, 113managing, 525cron settings, 405cron-type scheduling, 406crond (cron daemon),403, 525-527usage, 524cronloop, command, 524crontab, 413command, 405, 525usage, 176, 403565entries, 510, 525file, 298, 404, 524creating, 403editing, 403man page, 527requests, 404setting, 527settings, creating, 530cross-posting, 285csh shell, 120, 459usage, 462csh-compatible shell features,122csplit command, 329CSV files formats, 390cu man page, 204cu program, 204currency conversions,386cursor fonts, 164cursor modes, X11,changing, 164cursor movement, 319,329control, desktop usage,195cursor shape, 143cursor-driven list, 272custom colors, 274, 319,323custom fonts, 323custom keyboard functionkeys, support, 390customer ID, 336customized scripts, 224cut and paste operations,336cut command, 329, 331Cyrix CPUs, 11Dd file type, 492d option, 516daemon, 231, 233, 246,249, 253, 529line printer, 349mode, 251software package, 227dangling links, 458data entry, field, 429-430databasecontrols, 437testing, 127date/time (current),insertion, 323Davis, John E., 274, 321dc (desk calculator),396-397command, 382program, 382dd command, usage, 56Debian, 7debugging, 459decompress (-d) option,82, 91, 114decoration, 152, 156, 177default CPU priority, 527default fonts, changing,189default graphical interface,42default Linux Shell,features, 120default paper size, 353default resolution, selection,353default resource settingsfile, 163default settings, 340default shell, 470, 473default system editor, 321default text editor, 403default wallpaper, 169default window manager,153, 156-157delete, 139delete (-d) option, 139deleting files, rm commandusage, 95-96delimiter, field, 331desk calculations, dc(desk calculator) commandusage, 382


domain name 539desk calculator (dc),396-397command, 382program, 382desktopbuttonsappearance, 153location, 153client, Looking Glass,144configuration scheme,156display options, usage,185menu, 153panel, 180, 189usage, 181pattern, 168trash can, 178wallpaper, changing,187devicedriver, printer, 348identifiers, list, 48name, showing, 483options, list, 48df (free disk space)command, 79, 457usage, 454dial string, 221dial-in, account programs,251dialer script, 231, 246dialing out, communicationsprogram usage,203dialog boxcommand-line shell,207installation, 23Diamond SupraMax, 224diary, 409emacs, 410entry, 413file, 411dict file, 135dictionary, personal, 426digital cameras, 377digital clock, transparent,175dir command, 82, 84directory, 492archiving, 460backup, 510command-line option,91compressing, 460creating, mkdir commandusage, 96(-d) option, 492deleting, 460hierarchy, 127listing, 348dir command, 82long directory listing,80sending, 338specification, 81vdir command, 82listing, ls commandusage, 78-79manipulating, 93movement, cd commandusage, 72reading, 78removing, rmdir commandusage, 97searching, find commandusage, 74tracking, 456Disconnect button, 243discontiguous selection,429discussion areas, 269disk activity, 461disk quota, 292setting, 473support, 8disk space, 460, 468, 475conserving, 451freeing, 458informationgetting, 454saving, 458disk usage (du) command,usage, 455display colors, customizable,151display command, 373menu, 374usage, 374display font, settings, 152display item, 278display manager client,X, 149dma, 52DMA channel number,51DMA fields, 56DMA values, 13dmesg, 226command, 59, 201file, 201program, 225DNS (Domain NameServer), 30, 228address, 242server, 229, 233, 236doctor, 441documentauto-saving, enabling,420correction, ispell commandusage, 332creating, 425StarWriter usage,423icon, 280preparing, 335Exercises, 357Q&A, 356Summary, 356printing, LPRngPrinting Systemusage, 349spell checking, 332


540 Domain Name Server (DNS)templates, 424viewing area, 377document-creating wizards,423documentation, 346domain entry, 239domain name, 235Domain Name Server(DNS), 28, 228address, 242server, 229, 233, 236DontZap feature, 46DontZoom feature, 46DOS COM1 port, 209DOS filesystem, 104, 488partition, 483DOS floppies, 489DOS form, 490DOS operating system,321DOS partition, 17, 32, 74,95, 104, 454, 515DOS rebooting, 16DOS serial ports, 200DOS utility, 516DOS VFAT filesystem,483down command, 440downloading, visual status,297DR-DOS, 10, 12drag-and-drop actions,178drag-and-drop cell movement,391, 393drag-and-drop controls,408drag-and-drop icons, 36drag-and-drop notes, 405draggable track numbers,438drawing editing programs,379drawing programs, 367drawing tools, 423drive designators, 490drive space, 460driversdownloading, 201software, 225drop-down menu, 185DT command, 206du (disk usage) command,79, 521directory tracking, 456usage, 455du report, 456-457dual-boot computer, 18,35, 379dump, 510dump command, 124,483dump files, screen, 167dump format, X11 windows,167dump graphics file, X11window, creating,367-368dump option, 530dunnet, 441dvi files, 345dvips command, 346dynamic IP address, 232,235Ee command, 440echo command, 139ed command, 106, 314editingkeys, 371macros, 327sessions, 370tools, 369editor, 335defaults, 317EDITOR environment,413variable, 475Editor Macros (Emacs),315edquota, usage, 475edquota command,usage, 475efaxcommand, 214, 216manual pages, 211setting up, 218software, 211system, usage, 211egrep command, 108-109,126Eissfeldt, Heiko, 444electronic mail, 252, 257,261, 274, 442documents, sending,323programdistribution, pine,320pine, 319utilities, 250Ellis, James, 269elmmail program, 256configuring, 255usage, 255program, 253, 262Elm Development Group,255Emacs/emacs (EditorMacros), 87, 315, 316,328, 413appointmentcommands, 410functions, 410calender mode, 411command, 409diary, 410editor, 71, 133, 315,322, 332, 409, 441games, playing, 441


Fejes 541non-X11 version, 316text editor, 409usage, 409users, 315X11 version, 316email, 223, 249address, 277, 278, 298,420configuration, 419configuring, 249getting, 249message, 262program, 476retrievingfetchmail usage, 251setting up, 249usage, 226embedded text, 426emergency boot disk, 516empty, 139empty (-e) option, 139Empty menu, 182emulator, terminal, 134encryption, usage, 510End Horizontal Retracevalue, 47End Vertical Retracevalue, 47end-of-file (EOF) character,126end-of-input character,126end-of-input string, 127end-of-text (EOT), 400Enhanced SoftwareTechnologies, 511enlargement/reduction,424env command, 273environment variable, 76,117, 127, 129, 139, 272,400, 452, 475$EDITOR, 320environmental variables,115EOF (end-of-file) character,126EOT (end-of-text), 400Epson, 378printer, 13Stylus, color printers,11, 352eqn utility, 356equipment, inventory, 13erase (-e) option, 501erase option, 516error messages, 499esr (Raymond, Eric S.),251ESS, 13EtherFast 10/100 card(Linksys), 60Ethernetcards, 11interface, 53, 57configuring, 61Interface Configurationdialog box, 62network interface, configuring,41PC card, 59Ethernet/modem combinationcards, 57Evans and SutherlandComputer Corporation,151events, alarms, 405ex command, 314ex editor, 319exec option, 484executable programs, 121exit command, 452, 498expand command, 329Expect button, 236Explorer window, 423export command,128-129export statement, 272ext2 filesystem, 455,482-484, 488, 508ext2 partition, 483extended filesystem, 486extended partition, 18extract (-i) option, 517extract (-x) option, 79,112extract (x) option,515-516Ff (file) option, 111-112Falstad, Paul, 122FAQs (Frequently AskedQuestions), 71fast browsing, Lynx commandusage, 299Fast Ethernet interface,57FAT16, 18FAT32, 18faxclass support, 13filenames, 216graphic format, 219machine, phone number,220number, 203protocols, 211receiving, 211sending, 211shell script, 214-215,219software/documentation,211fax command, 214trying, 212usage, 213, 216fax documents, sending,218ksendfax client usage,216mgetty+sendfax usage,218


542 feltfax script, 216queries, 213faxing, efax systemusage, 211fdformat (floppy diskformatting) command,486fdprm, floppy driveparameter file, 485feature creep, 460Fejes, Frank, 155felt, 396fetchmailcommand, 252FAQ, 267program, 253running, 253usage, 251fg % command, 133fg command, 132fgrep, 400command, 108-109,273, 453, 458search, 118field delimiter, 331field insertions, 425fields, 423File (f) option, 111-112file compressing/compression,110-112, 367compress commandusage, 114gzip command usage,114file formats, 423opening/saving, 427word processing, 327file handling, 479Exercise, 507-511mc (MidnightCommander) Programusage, 104Q&A, 507Summary, 505file ownership, 479changing, chown commandusage, 496managing, 491file permissions, 131, 491changing, chmod commandusage, 494flags, reading, 492file reading, 78head command usage,88, 90more command usage,86tail command usage,88, 90File Transfer Protocol(FTP)document retrieval, 323listing, 178programs, usage, 290server, remote, 303usage, 226filename, 141completion, 116file-number extensions,460filesaccess, 479attachments, 258backup, 510browsing, less commandusage, 87-88combining, cat (concatenate)commandusage, 84-85conversions, 368copying, cp command,100-102creating, touch commandusage, 94deleting, rm commandusage, 95-96extensions, 368, 379finding, whereis commandusage, 75insertion, directorymode, 320linking, 102-103listing, cat (concatenate)command usage,84-85locating, locate commandusage, 76manipulating, 93matching, find commandusage, 74names, extension, 360procurement, FileTransfer Protocol(FTP), programsusage, 290renaming, mv commandusage, 98-99retrieval, 290ftp command usage,290searching, 105grep commandusage, 108-109regular expressions,106-108selection, 514size, 331transfers, 223programs, 206uncompressing,110-112filesystem, 18, 53, 69,131, 454access, mount commandusage, 482creating, 486definition, 480disk usage, gettingdu command usage,455DOS, 488ext2, 484, 488, 511extended, 486mounted, 479mounting, 479, 482mounting/unmounting,482-483navigating, 72, 481OpenLinux, 481option, 455pop-up menu, 488


ftp user 543removable, 484rows, 483searching, 72statistics, getting, dfcommand usage, 454support, 9vfat, 482Win9x, 482filesystem handling, 479Exercise, 507-511Summary, 505filesystem table (fstab),474, 479, 507columns, 483editing, 483entries, 484understanding, 482file\, //, 303filter, 134commands, 332programs, applying,367usage, 329, 331, 347writing, 265Filtering Mail FAQ, 267financial applications,396financial toolsExercises, 397learning, 381Summary, 396find command, 74-75, 82,105, 135, 459-460, 517,527usage, 74finding, files, 75finger command, usage,472flash card, 453-454flash memory, 13card, 453, 484flash RAM card, 95, 483floating windows, 369flood (-f) option, 245floppies formatting,KFloppy client usage,488floppy devicehigh-density, 487location, 485type, 485floppy diskformatting, 484(fdformat) command,486unmounting, 489floppy drive, 10, 24, 484,510, 513parameter file (fdprm),485tape driver, 518floppy utilities, 484flow control, 237fmt command, 329,340-342focus, 152policy, 153, 193fold command, 329follow-up messageposting, 270reading, 270font, 342, 346attributes, 425changes/changing, 158,335configuration, 419control, 423custom, 323effects, 425internalization, 8italic, 173X11 listing, xlsfontsusage, 172footnotes, building, 423forecasting, 387foreground color, 160,278formatted text, streams,349formatting commands,329TeX, 346formatting program, 338formatting toolbar, 425formatting utilities, 356Fortran, 395Fox, Brian, 120fractal drawing program,171fractal image, 171free command, displaying,461free disk space (df) command,457usage, 454free editor, 315free graphical interface,38Free SoftwareFoundation (FSF), 71,114, 315, 329, 394Free Wingz spreadsheet,finding, 390free-for-personal-usespreadsheets, 387Freeciv, 447freeware spreadsheetprogram, 390front-end utilities, 499FSF (Free SoftwareFoundation), 71, 114,315, 329, 394fstab (filesystem table),474, 479, 506columns, 483editing, 483rows, 483understanding, 482ftape driver, 518FTP (File TransferProtocol)document retrieval, 323listing, 178programs, usage, 290server, remote, 303usage, 226ftp command, 291,293-293, 308running, 291usage, 290


544 ftp\, //ftp connection, anonymous,291ftp directory, 292ftp login, 292ftp program, 291demonstration, 392usage, 291ftp server, 291ftp user, 291ftp\, //, 303full backup, 510fvwmcommand, 149display process, 152configuration file, 151customization, 155configuration menu,153root menu, 154window manager, 152,154-155, 157configuring, 151X11 window manager,144fvwm2, window manager,324Gg (global) command, 331Galaga, playing, X11,444gamesconsole, 439emacs, playing, 441simulation, 447X Window System ,442X11, 442garbage characters, 140,233, 247Gateway, 28gcal calendar, 405General Public License(GPL), 9, 71, 394Genius, 378geometric settings, usage,300geometryoption, 160settings, 174, 316, 369,376usage, 160specifications, 161get command, 290-291,291getopts command, 139getty command, 210Ghemawat, Sanjay, 405GID (group ID/identification),469, 474, 497GIF format, 136giftopnm command, 136Gildea, Stephen, 174GIMP (GNU ImageManipulation Program)Frequently AskedQuestions (FAQs),373image editor, 370information, 373installation, 369menu systemaccessing, 371resource files, 369running, 371usage, 369Gleason, Mike, 293glint, 396command, 310, 505program, 511usage, 476global (g) command, 331GNU, 9, 315text-utils package, 329GNU chess engine, 442GNU file utilities package,94GNU GNOME, development,176GNU ImageManipulation Program(GIMP)Frequently AskedQuestions (FAQs),373image editor, 370information, 373installation, 369menu system, accessing,371resource files, 369running, 371usage, 369GNU software, 394packages, 71GNU text, 88gnuchess manual page,441, 443gnuchess program, 440gnuplotdocumentation, 395FAQ, 395program, 381, 394-395usage, 394go west command, 440GPL (General PublicLicense), 9, 71, 394grace-period warnings,476graphic configuration,178graphic conversions, 136graphic files, 379converting, 367graphic images, 426graphic insertions, 423graphic interfaces, 520graphic utilities, 167graphical interface, 12,23, 143, 145, 234, 502default, 42free, 42graphical interface program,118, 223, 502


hierarchical root 545graphical mouse configurationutility, 165graphicsapplication capture softwarepackages, 379artists, 367card, 15, 46, 144-145,147, 149, 176, 509detection, 24type, 14chipsets, 43conversion, 374program, 219, 369,379converting/viewing, 367directory, usage, 375editor, 379formats, 211, 359, 374hardware, 42icons, 151images, 367insertions, 425manipulationfilters usage, 370monitor, 147, 176package, interactive,396pads, 45programs, 144services, 42stream, 368translating/translation,211, 359viewing, xv commandusage, 374graphics editingGIMP (GNU ImageManipulationProgram) usage, 369ImageMagick usage,373programs, 379graphics file, 373.jpg, creating, 367conversion, 379formats, 368, 376Linux, understanding,360types, 360image quality, 368loading, 374translation, 293graphics tools, 359Exercises, 379Q&A, 379Summary, 379grep command, 109, 112usage, 108-109grep programs, 105groff command, 343line, 344groff distribution, 346groff formatter, 345usage, 342groff formatting program,344, 349groff program, 346usage, 357groupcommand, 496membership, 498ID/identification (GID),469, 474, 497ownerships, changing,497root, 497group, changingchgrp usage, 497newgrp usage, 497Groups Server, 282gs PostScript, interpreter/companionviewer,211gunzip program, 114gv client, 347gv command, 376-377usage, 376gv previewer, 342gv program, 345-346gvim, 317gvimrc resource files, 318gzip command, 70, 110,115usage, 114gzip compression, 515HHaardt, Michael, 390hackers, 9halt (-h) option, 38Hankins, Greg, 201Har-Peled, Sariel, 439hard disk, interfaces, 10hard drive, 24, 38, 370,461adding, 483controller, type, 13crashes, 521dividing/mapping, 18partitioning, 14, 19, 23partitions, 14preparing, 18removable, 510, 518,516size, 13space, 10, 13, 369, 417,460, 474, 476amount, 22storage space limits,473hard limits, 462, 475hard link, 102-103creating, ln (link) commandusage, 102-103hardware devices, 377hardware vendors, 17Hart, Robert, 230, 247harvesting, software, 277hash signs, 499Hayes 56K Accura, 224Hayes-compatiblemodem, 202head command, 89, 329usage, 88-90


546 high-density drivesheader line, 218helpbuilt-in, 406command, 121, 290man command usage,69help (-h) option, 139here redirection operator,126Hewlett-Packard, 11, 378hierarchical root, 151high-density drives, 486high-density floppydevice, 487high-end network serveroperations, 9highlighting, 87Hind, David, 58, 61, 201home directory, 138, 154,163, 181, 270, 293, 317,321, 494home office management,StarOffice usage, 415Exercises, 433Q&A, 433Summary, 432hopalongclient, 171program, 171horizontal rule, 425horizontal scrolling, 319horizontal sync ranges,26, 45host IP (InternetProtocol) address, 292hostname, 228, 276, 290,308abbreviated, 293command, 64, 309definitions, 357resolution, 53HOSTNAME entry,changing, 64HP 344Cbi, 12HP printer, 13HP printer-control language,345HPCL, font type, 13HTML (HyperTextMarkup Language)documents, 327file formats, 390format, 72message format, 262page composition, 302http\, //, 303hwclock commmand, 526hyperlinks, insertion, 423HyperScript scriptinglanguage, 390hypertext links, 34HyperText MarkupLanguage (HTML)documents, 327file formats, 390format, 72message format, 262page composition, 302hyphenation controls,423Ii (information) option,500I/O address fields, 52ical calendar, 405ical client, 406-407usage, 405ical X11 client, 174icon, 152, 157appearance, 153assignments, 152definitions, 152dock, 151, 156, 158drag-and-drop, 33fonts, 153location, 153menus, 156id Software, 445IDE, 10, 13ide driver, 518ide tape drives, 518if ... then statement, 139ifconfig command, 62,127, 227, 467usage, 243IM (Instant Messenger),306buddy, 307running, 310imagefiles, editing, 370quality, graphics file,368thumbnails, 373image window, 369, 374active, 371image-processing program,369ImageMagickinformation, 374man pages, 368package, 368software package, 375usage, 373IMAP, 252incremental backup, 510indenting, 335indexes, building, 423info command, 121informationdisplay, 152fields, 465hiding, 389option (i), 500prompt, 87infrared (IR) port, 12, 13initdefault line, 150Initialization String,field, 238initialization table, 149inittab, 149inodes, 475listings, 475


IRQ 547input/output, 461inserted typesetting commands,347insmod command, 52,227usage, 64install (-i) option,499-500INSTALL.148, 16installation dialog boxes,23installation script, 433installed artwork, list,422Instant Messenger (IM),306buddy, 307running, 310interactive (-i) option, 95,99-101, 130, 134interactive commands,465interactive console programs,160interactive controls, 465interactive editors, 329interactive graphicspackage, 396interactive mode, 386interactive prompting,291interactive spelling program,332interfacecomputer software , 314graphic, 520serial-port, 378usage, 352internal IDE drive, 64internal modem, 200internal script variables,139Internet, 251, 443active connection, 304,308, 436activities, 242address, 303browsing, 289Exercises, 310Q&A, 310Summary, 309clients, 260starting, 436type, 310database, 436documents, FTPretrieval, 323downloading, 289Exercises, 310ncFTP programusage, 293Q&A, 310Summary, 309emailconfiguring, 249Exercises, 268Q&A, 267Summary, 267file transfer programs,289links, 37logging on, 307navigation, 323newsconfiguring, 269Exercises, 287Q&A, 286Summary, 286sites, 334Linux, 377Internet connecting, 223Exercises, 248hardware, 224minicom commandusage, 232OpenLinux usage, 15ppp-on script usage,233Q&A, 247Summary, 247connection, 226, 291Internet Protocol (IP), 53address, 28, 63, 229,232, 235, 243, 246,251, 295static, 228addressing, 228Internet Relay Chat(IRC), 309chatting, 304Internet Service Provider(ISP), 223, 226, 249,251-253, 258-259, 267,270-273, 279-280, 283,286, 289, 392, 293, 306,387, 467connecting, 232, 254Hookup HOWTO, 15host servers, 245mail retrieval protocol,262name, 241needed information,228phone number, 241interpreter/companion,viewer, 211Interrupt Request (IRQ),47, 201inven command, 440Investment IntelligenceSystems Corporation,390io, 52Iomega Zip, 510disks, 484drivebackup device, 513usage, OpenLinuxusage, 64Plus drive, usage, 65


548 IRQ fieldsIP (Internet Protocol), 53address/addressing, 28,228, 229, 232, 235,243, 246static, 228IR (infrared) port, 12, 13IRC (Internet RelayChat), 309chatting, 304irc /HELP command, 305irc command, 304, 310help facility, 305irc program, 304ircII, man page, 305irq, 52IRQ (Interrupt Request),51, 201sound card, 13IRQ 5, 13IRQ fields, 56ISA/PCI modems, 224Islamic dates, 410iso9660, 482-483iso9660 filesystem, 455ISP (Internet ServiceProvider), 223, 226, 249,251-253, 258-259, 267,270-273, 279-280, 283,286, 289, 392, 293, 306,387, 467connecting, 232, 254Hookup HOWTO, 15host servers, 245mail retrieval protocol,262name, 241needed information,228phone number, 241ISP-Connectivity miniHOWTO, 230ispellcommand, usage, 332dictionary, 334manual page, 333package, 333program, 332-333spelling checker, 332italic fonts, 173JJava Development Kit(JDK), 310Jaz drive, 510utility, 490JDK (Java DevelopmentKit), 310jed, configuration files,322jed editor, configuration,321jmacs editor, 321job control, 8, 119, 132facilities, 134jobs command, 133joe configuration files,321joe editor, 321join command, 329Joy, Bill, 317Joy, William, 122JPEG format, 169, 187JPEG graphic formats,178jpico editor, 321jstar editor, 321Julian dates, 410Jung, John, 299junkemail, 264, 266, 268mail, 264-266, 277Juno, 251justification, 425KK Desktop Environment(KDE), 28, 53, 54, 62,72, 96, 216, 224, 269,302, 322, 324, 383-384,411, 487, 501applications, locating,192configuration manager,35configuring, KDEControl Center usage,184Control Center, 177,184, 189, 191, 192usage, 184cursor movement control,desktop usage,195default fonts, changing,189desktop, 188actions, performing,180panel, usage, 181desktop, features, 180Exercises, 192exploring, 177fonts dialog box, 190help, 180keyboard/mouse settings,changing, 191menu editor, 182panel, menu, editing,182properties, changing,193Q&A, 192screensaver, changing,188sessions, 193starting, 179Summary, 195


KFloppy 549system sounds,installing, 190themes, 32title bars, changing, 193usage, 145wallpaper, changing,187window buttons, changing,193windows, 190K DevelopmentEnvironment (KDE),12, 53, 158, 176, 234,278, 282, 383, 436, 447,481clients, 163Control Center, 169graphical interface, 279session, 38, 149taskbar, 425usage, 148, 166, 169,421users, 170K Display Manager(KDM), 32, 150Display ManagerOptions, usage, 185K display manager(kdm), login screen, 186K file manager (kfm),180usage, 183kcalccalculator, 384font/display, 385client, usage, 383dialog box, 384kCalc button, 384Kcalc calculator, 180kcsdclient, 435dialog box, 436player, 436KDE (K DesktopEnvironment), 28, 49, 54,62, 72, 96, 216, 224, 269,302, 322, 324, 383, 384,411, 487, 501applications, locating,192configuration manager,35configuring, KDEControl Center usage,184Control Center, 177,184, 189, 191, 192usage, 184cursor movement control,desktop usage, 195default fonts, changing,189desktop, 188actions, performing,180panel, usage, 181desktop, features, 180Exercises, 192exploring, 177fonts dialog box, 190help, 180keyboard/mouse settings,changing, 191menu editor, 182panel, menu, editing,182properties, changing,193Q&A, 192screensaver, changing,188sessions, 193starting, 179Summary, 195system sounds,installing, 190themes, 35title bars, changing, 193usage, 145wallpaper, changing,187window buttons, changing,193windows, 190KDE (K DevelopmentEnvironment), 12, 53,158, 176, 234, 278, 282,436, 447, 481clients, 163Control Center, 169graphical interface, 279session, 38, 149taskbar, 425usage, 148, 166, 169,421users, 170kde command, 49,144-145, 148KDE-aware applications,166kdehelp client, 192kdm (K display manager)client, 35login screen, 38, 186kdm graphical loginbypass process, 41display, usage, 48KDM (K DisplayManager), 35Display ManagerOptions, usage, 185kedit editing window, 336kedit editor, 322client, usage, 322keep (-k) option, 252Kelley, Colin, 394kernel, 8, 50, 118, 226message, 149process directory, 483kernel module, 58, 201,227, 348, 482boot-time control, 53configuring, 55sound, 52support, loading, 64


550 kfm (K file manager)kerning, 423key character, layout, 46keyboard, 24activity, 171configuration, 45internalization, 8server shutdown, 45settings, 152type, 13values, settings, 151X86Config, 46keyboard commands,154, 156, 327, 421, 425,431shortcut, 322WordStar-compatibile,321keyboard/mouse settings,changing, 191keys, number, 13KFloppyutility, 487client usage, 488kfm (K file manager),180usage, 183Kibell, Justin C., 445kill command, 131, 134,234usage, 133, 463killall command, 134Kimball, Spencer, 369Klasen, Lambert, 444kmenuedit editor dialogbox, 182kmix, 57knews, program, 286knotes alarms, 412knotes clientnote-taking features,412usage, 411Knuth, Donald E., 346Kodak DC20/DC25, 378Kojima, Alfredo Kenji,155koules, 442kpackage, 396, 481client, 447, 501command, usage, 499file selection, 502program, 511usage, 501Kpilot client, 12kppp, 223client, 15, 224, 229,234, 247, 272command, usage, 234configuration, finishing,238dialog box, 234Configuration dialogbox, 235connection, configuring,235krnclient, 280usage, 278configuring, 278dialog, features, 280identity dialog, 279newsreader, 270features, 279programs, 269newsreading, window,281program, 279, 284search, 287kscd client, usage, 435ksendfax client, 216usage, 216-217ksendfax directory, 216ksh, manual page, 122ksh shell, 120, 129command, 122kterm program, 158kvt program, 158kvt terminalemulators, 158window, 216LL (lookup) command,333l file type, 492language type, 46languages, 421laptop users, 10, 46LaStrange, Tom, 156LaTeX file formats, 390LaTeX macros, 346latex system, 356layouts, templates, 424Lea, Iain, 271less command, 87-88, 91,116, 225, 388usage, 87-88less pager, 91, 135, 201,339, 348lesskey option, 87letter-size paper, 342libraries, 346software, 369lilo command, 17, 34LILO (Linux loader), 17,21, 32boot prompt, 49, 120,149installation,39message screen, 34limit command, 462line editors, 314line printercommand, 135daemon (lpd), 351starting, 349spooling system, 349line termination, 237line wrapping, 204disabling, 46, 149link (ln) command, 102,105usage, 102-103linked objects, 327links, 423


locate 551Linuxarchive Web site, 175booting process, 8calculators, 382chat groups, 310console mode, 453custom partitioningscheme, 21definition, 8distribution, 9, 326, 332,368documentation, 303environment, wordprocessors, 313evolution, 50fax machine, 214file system, 502file types, 492filesystem, 474, 480gamesrelaxation/playing,435Exercises, 448Q&A, 447Summary, 447graphics file formats,understanding, 360installation, 458beginning, 24finishing, 28guide, 39HOWTO, 25installation preparation, 7Exercises, 22Q&A, 22Summary, 21installing, 23, 454Exercises, 39Q&A, 39Summary, 38Internet sites, 377kernel, 118, 201, 226,460, 464, 474, 480module, 227Laptop Pages, 11logging, 473logging in, 35native format, 484newsgroups, 270programs, 220, 349,416, 459rebooting, 35repository, 392required software, 226root partition, 22runlevel, 210running determinationuptime commandusage, 466w command usage,466shell, features, 120shutting down, 35sites, 290software managementkpackage commandusage, 499lisa command usage,499rpm commandusage, 499subjects, 270swap partition, 13, 24,370system, 121, 210-211,226, 289, 466,472-473, 479, 493backups, 511dialing in, 208setting up, 208upgrade, 451text editor, 257users, 7, 266utilities, 509Linux Basic InstallationGuide, 108Linux browsersusage, 293Linux Installation andSystem Adminisration(lisa)utility, 351Linux loader (LILO), 17,21Linux NetworkAdministrators Guide,228, 243Linux partition, 7, 17, 26,32, 474, 482creating, 20information, 26Linux SystemAdministrator’s Guide,98Linux User Group(LUG), 17lisa (Linux Installationand SystemAdministration), 396,468administration program,202command, 253, 310,346, 481usage, 201, 351, 469,473, 499, 502menu, 470program, 511usage, 357, 476utility, 351Lisp, 396, 410list, 139List (-l) option, 114, 139,333, 405list (ls) command, 491list files/directories (ls)command, 291list shells (-l) option, 472list variable, 139listingdirectories, 78-79dir command, 82directory specification,81long directory listing,80vdir command, 82files, cat command,84-85


552 locatedb scriptlmove, command, 286ln (link) command, 102,105, 203usage, 102-104lo (loopback) interface,63lo option, 63load average (-l) option,528loadable code modules,15, 50loadable code soundmodules, 50LOADLIN program, 17LOADLIN.EXE, 17local printers, 349locatecommand, 76-77, 82,524usage, 76database, 525ifconfig command, 227locatedb script, 525locating, files, 76lock file, 237log information, 351logged-in users, 467login entries, verifying,232login name, 228, 230login prompt, 147, 309login screen, 31, 147login script, 235building, 238dialog box, 236logins, restricting, 472long (-l) format listing,330long directory listing, 80long-filename filesystem,453Longyear, Al, 230, 247look command, 334, 440Looking Glass, 183client, 148, 152desktop, 148, 302, 324client, 144menu item, 154lookup (L) command,333loopback (lo) interface,63loopback device, 357loopback interface, 245Lotus 1-2-3 format files,390Lotus formats, 390low-level format, 486low-level SCSI protocol,65lp device, 348lp.o module, 348lp.o parallel printer kernelmodule, 348lpc commands, 350lpd (line printer daemon),351starting, 349lpost command, 286lpq command, 349lpr command, 349, 357lpr spooling system, 349lprm command, 350LPRng, 349configuration file, 351permissions control file,351Printing System, usage,349software distribution,351ls (list files/directories)command, 291ls (list) command, 491ls -aF option, 82ls -l listing, 492ls -l option, 80, 83, 232ls -R option, 82ls command, 79, 82, 105,107, 123, 130, 203, 330,492usage, 78-79ls man page, 80, 84ls program, 336lsa, 130lsac, 130lsc, 130lsl, 130lsmod command, 52LS_COLORS, 80Lucid, Inc., 315LUG (Linux UserGroup), 17lurk, 274luser, 285Lynxbrowser, 299, 530usage, 300command, usage, 299editor, usage, 356features, setting, 299Web browser, 321, 346,377, 387Mm option, 463Macintosh, Apple, 176MacOS, 35macros, 152, 346definitions, 152documentation, 344files, 151inserting, 346languages, 356LaTeX, 346man page, 344mm manuscript, 344set, 345support, 423typesetting, 344Mager, Neil, 410


MIT (Massachusetts Institute of Technology) 553magnetic tape (tp) command,516mail, 53, 255command, 255, 530daemon, 249message, 266, 472composing, 258retrieval protocol, 262sending, mail programsusage, 253server, 229, 251-253,258, 262, 263, 279protocol, 267utilities, 250mail information, gettingmailstats commandusage, 467pppstats commandusage, 467mail program, 262, 268message creating, 255responding, 254usage, 253Mail Transfer Agent, 253mail-retrieval protocols,251mailer configurationscreen, 258mailing list, 263mailstats command,usage, 467mailstats program, 467make command, 216makeindex command,356MakeTeXPK program,346makewhatis command,77, 526makewhatis program, 71man command, 69-71,73, 78, 87usage, 69man macros, 343man page macros, 344manipulatingdirectories, 93files, 93manipulation commands,93Exercises, 116Q&A, 115Summary, 115manual page, 70creating, 343manual sound configuration,57margins, 342Mariano, Adrian, 385Massachusetts Instituteof Technology (MIT),42, 151Master Boot Record(MBR), 17, 32math applications, 396math co-processor, emulation,8math toolsExercises, 397learning, 381Summary, 396mathematical formulasgraphing, gnuplotusage, 394Mattis, Peter, 369mattrib, 489Mayan dates, 410mbadblocks, 489MBR (Master BootRecord), 17, 32mc (MidnightCommander)command, 95-96Program,features/usage, 104mcd, 489McGough, Nancy, 267mcheck, 489mcopy, 489mcr command, 324md5sum command, 329mdel, 489command, 491mdeltree, 489mdir, 489command, 490mediaremovable, 521usage, 510Media Key, entering, 417memorycard, 453information, getting,460protection, 8reclaiming, kill commandusage, 463space, 159usage, 461virtual, 9memory reportingfree command usage,461vmstat command usage,461memory-efficient rxvtterminal, usage, 159menu-enabled X11 terminal,158menusfonts, 153settings, 151message, 246author, 270browsing, 270contents saving, 270creating, 255display, 274, 277file, 89headers, display, 274list, 260posting, 270reading, 270reminder, 411MetaLab, 292, 295mformat, 489mgdigest, 265mget command, 291


554 mkdir commandmgetty command, 218mgetty program, 220mgetty+sendfax, usage,218mgetty+sendfax programs,221Microchannel-based PCs,11Midnight Commander(mc), 118command, 96Programfeatures, 104usage, 104minfo, 489minicli client, 384minicomcommand, 227usage, 232communications program,205manual page, 232phone directory, 206program, 201, 203, 221,225, 232, 247running, 204usage, 204running, 210MIT (MassachusettsInstitute of Technology),42, 151mkdir command, 97-98,102, 105, 139, 265usage, 96mke2fs command, 486mkmanifest, 489mlabel, 489command, 490mm manuscript macros,344mmd, 489mmount, 489manual page, 491mmove, 489mode lines, matching,146mode value, usage, 146modeline, 317fine-tuning, 47parts, 47time display, 317understanding, 47modems, 11, 13, 5756K ITU V.90, 12bank, 226card, 200connect number, 228,230connection, 205, 226device, 237Hayes-compatible, 202internal, 200profile, 209port, 348, 492setting up, 199-200speed, 207setting, 207supports, 212testing, 200troubleshooting, 468type, 13modulesappearance, 153location, 153MODULES.148, 16monitoring program, 461monitorshorizontal refresh, 14maximum resolution,14resolution capabilities,147settings, 45specifications, 46vertical refresh, 14monochrome display,162, 168monochrome server, 48,161Moolenaar, Bram, 317more command, 86usage, 86Mosaic, 299Mosaic Web browser, 298Motorola FM56, 224mountmanual page, 455point, 457mount command, 454,516manual page, 480usage, 482-483mount directory, 481mount options, 483mount point, 480mounted filesystem, 452,454, 457mouse acceleration, 165mouse activity, 171mouse button, 159, 164,166, 371, 425, 433mouse commands, 156mouse configuration, 41utility, graphical, 165mouse cursor, 154, 166mouse modes, X11,changing, 164mouse pointer, 143, 147,154mouse pointing devices,10mouse settings, 152customization, 165mouse settings, changing,191mouse support, 320enabling, 277mouse type, 13Mouse-cursor awaremode, 274mouse-driven toolbars,393mouse-handling functions,152Mozilla, 310mpage (multiple page)command, 342mpartition, 490mpg127 command, 447


NNTPSERVER (nntpserver) 555MPU, 13mrd, 490mren, 490MS-DOS (MSDOS), 12,201floppies, 489partition, 516mt (magnetic tape) command,516mtools package, 489mtoolstest, 490mtype, 490multiuser runlevel, 45multilingual terminalemulator, 158Multimedia, 436multiple page (mpage)command, 342multiple-column option,341multiple-view format,169multitasking, 8multiuser systems, 473music playing, xplaycdclient usage, 438Mustek, 378mutt, 268mv command, 96, 99-101,105, 139, 141usage, 98-99Mwave adapter, 17, 224mxp, 396mzip, 490Nn command, 440Nagree, Yusaf, 518name server entry, 239naming, files, 98-99Nano-Warrior, 331Nation, Rob (Robert),151, 402native format, 484navigationfile system, 72keys, 300pwd (print workingdirectory) commandusage, 72navigation commands, 69Exercises, 91Q&A, 91summary, 90NCEMRSoft, 297ncftpcommand, 297-298status bar, 298usage, 298, 310ncFTP program, usage,297Nelson, Philip, 386NeoMagic, video graphicsdisplay, 146netcfg tool, 15Netmask, 28Netscape, 148, 180command, 260Discussions, 282newsreading, window,282web browser, 377, 464NetscapeCommunications, 300Netscape Communicator,260, 269, 282, 303-304exploring, 300Linux version, 303Web browser, 300Netscape Messenger, 249,261email configuring, 260email usage, 260mail server, 262text sending, 262Netscape Navigator, 387Netscape Web page, 303netstat command, 227usage, 244netstat manual page, 244netstat –r command, 245NetWare 3.x, utilities, 10NetWare 4.x, utilities, 10NetWare NDS client, 10network, 13backups, 511connection, 127, 289,310installation, 416IP addresses, 246ports, 466printers, 349server operations, 9services, 53traffic, 245windowing system, 42Network Informationconfiguring, COAS(Caldera OpenAdministrationSystem) usage, 61gettingmailstats commandusage, 467pppstats commandusage, 467Service, 53Network Object ModelEnvironment, 176Network TransparentAccess (NTA), 178networking cards, 10networking enhancements,349networking protocols, 8new group (newgrp)command, 497-498newgrp (new group)command, 497-498newmail, man pages, 267news readers, 257news server, 229, 258,272, 279, 282newsetup, command, 286


556 no-window (-nw) optionnewsgroups, 247, 257,271, 285, 287articles, navigating, 281command, 286index file, 270list, developing, 271message, 270posters, 285posting, 278subscribing/unsubscribing,270newsreader, 132, 244functions, 270newsreading, 279session, 278, 467utilities, 286window, 281-282, 284newusers command, 477NEXTSTEP, operatingsystem, 155Nikon, 378nl command, 329nn, program, 286NNTP (nntp), 272options, 279server, 258, 273, 274,279NNTPSERVER(nntpserver), 272file, 272variable, 275no-window (-nw) option,316noblank option, 170non-X11, emacs command,409non-X11 version, emacs,316nongraphical environment,160nonvolatile RAM(NVRAM), 234Not UNIX project, 315notes, cron-type scheduling,406notices, listing, 408nroff command, 343, 388nroff script, usage, 357nroff text formatting program,71NTA (NetworkTransparent Access),178NVRAM (nonvolatileRAM), 234Oobject files, 459object-oriented editors,379octal notation, 495od command, 329off-hour times, 529off-peak times, 529office suite, 415definition, 415office-automation productivitysuite, 415Office50 folder, 418oleo spreadsheet, 390open command, 291usage, 309Open Sound System(OSS), 57drivers, 15Open Source, software,251OpenLinux, 80, 90, 102,110, 113, 175, 178, 249,267, 274, 282, 286, 384,387, 390, 399, 402, 525,5271.3, 252distribution, 204boot disks, 23booting, 24planning, 17booting process, 8command, 70, 87, 115line, 491configuring, 149, 223console, 147default configuration,149definition, 9directory, 187, 460discussions, 264distribution, 116, 177,203document printing, 335documentation, 303editing programs, 335equipmentproblems, 11requirement, 10support, 10file, 460deletion, 96system, 103, 192,416, 458, 481, 499full installation, 51, 360graphics programs, 359installation/installing,61, 223, 249, 469, 511best way, 22booting alternatives,17CD-ROM booting,15creating, 22decision, 15floppy booting, 16planning, 14Internet connection, 15kernel, 474kernel modules, opening,54logging in, 72, 144,148, 186xdm commandusage, 149modems usage, 224module file, 348organization scheme,480partition, 482, 516


PDF documents 557Preparation, dialog box,19printer, 353printinghandling, 347system, documentation,351program, 401rebooting, 150running, 476scheduling programs,523session, 34, 118, 147,313shutting down, 38software, 18, 504sound configuration, 50,57sound utilities, 53system, 76, 80, 99, 123,163, 208, 220, 239,242, 249, 295, 416,420, 451, 502-503,511, 516-521, 528,530initialization table,149log, 60users, 473, 477usage, 64, 510users, 223, 264, 347,367, 473utilities, 359workstation, 416operating system, 9, 11,14, 17-18, 42, 225, 250,270, 286, 324, 359-360,457CP/M, 321DOS, 321kernel, 8operating system-specificdrivers, 11OSS (Open SoundSystem), 57drivers, 15output redirection, 84output stream, 367ownerships, changingchgrp usage, 497newgrp usage, 497Pp command, 382package file (-p) option,500Package Manager, 499page composition,HTML, 302page length option, 340page numbering, 335pagers, 86, 151module definitions, 152saving, 342size, 152painting programs, 367palettes, 370Palm III, 12Palm Pilot Professional(3Com), 12Panel Configuration dialogbox, 182paper sizedefault, 353list, 353paradise, 442paragraph justification,320Parallel Line (PLIP)interface, 15parallel port, 378assignment, 13parallel printer, 347devices, 347kernel module, 348parallel-port devices, 64parallel-printer ports,352parent (-p) option, 97parent directory, 97parent subdirectory, 97parity, 199, 207setting up, 207partitionadding, 483DOS filesystem, 483ext2, 483extended, 18primary, 18sizes, 454swap, 482Partition Magic, 24-25partitioninghard drive, 23scheme, 25PartitionMagic, 18, 22Caldera Editionhard drive recognition,21setup program, 20commercial version, 22Pascal, language, 395Passthru PostScriptprinter, 354passwdfile entry, 470text database, 470passwd command,469-470passwords, 27, 149,228-230, 240, 252,295-296, 309, 452, 469authentication, 241changing, passwd commandusage, 470entering, 172, 484entries, verifying, 232field, 470mandatory changes, 471protection, 171paste command, 329pasted graphics, 327path hierarchy, 127pathname, 72, 233, 295,413, 437, 440


558 pdksh (public domain Korn shell)pattern, 370-371options, 87usage, 172pbm2g3 program, 219pbmtext command, 219pbmtext program, 219PC card, 13controller, 58modem, 225slot, Type II/TypeIII, 57Winmodem, 58PC notebook, 46PCDOS, 12PCL (Printer ControlLanguage), formats,345PCMCIA, 16card, 10enabling, 57service, enabling, 41controller, 59type, 13device, 201manager, 225modem card, 200support, 58PCMCIA-HOWTO, 201PDF documents, 377pdksh (public domainKorn shell), 121, 453,459, 462shell, 91perf, 477peripheral controls, 53permissions, 331appearance, 494changing, 493-494files, 491flags, 491, 494reading, 492managing, 491root, 499personal dictionary, 333,335, 426personal name, 258personal productivity,399tools, learning, 399personal productivitytools, 178Exercises, 413Q&A, 413Summary, 412personal reminders,scheduling, at commandusage, 400personal tasks, scheduling,at command usage,400Peterson, Chris, 174PhotoShop (Adobe), 369pico, 204editor, 126, 149, 160,257, 259, 314, 322,332, 336, 413, 526features, 319text editor, 126, 136,229, 257, 272, 403,473, 475-476PID (process number),463, 470pilot-xfer command, 12pinecompose mode, 258distribution, 476electronic mail program,319distribution, 320email program, 126,286, 413, 476mail folder, 260mail program, 132, 136,249configuring, 257usage, 257mail reader, 133mailer, 132, 321configuration screen,258program, 253, 255, 257,262, 265Pine features, 319ping command, 227usage, 63, 245, 248pipelines, 329pipelining, 134pipes, 298, 329-330experimenting, 368usage, 134, 367pixmap directories, 379placement, 152Plass, Johannes, 376platforms, multiple, 8play option, 439PLIP (Parallel Line)interface, 15plot command, 395plug-in features, 299plug-in filters/tools, 369plug-ins, 303, 369pnews, command, 286pnmcrop command, 368pnmflip command, 368pnminvert command, 368pnmrotate command,367-368pnmscale command,367-368pnmsmooth command,367pnmtile command, 368pnnsmooth command,368point-and-click client,488point-and-click dialogconfiguration, 178point-and-click interface,117, 281Point-to-Point Protocol(PPP), 223, 225, 249connections, manualstart/stop, 232HOWTO, 15interface, 467manual setup, 229network connections,289


process 559protocol, 247sessions, 267startingkppp commandusage, 239xisp commandusage, 243stoppingkppp commandusage, 239xisp commandusage, 243support, 227Point-to-Point Protocol(PPP) connection, 224,226, 233, 251, 267, 269,289, 293, 304checking, 243configuringkppp commandusage, 234xisp client usage,240scripts, editing, 230starting, 299, 306stopping, 234Pop-up menus, 156, 178,181, 188pop-up reminder, 400pop-up root menus, 156POP3, 252portsinfrared (IR), 12parallel-printer, 352PostScript, 345-346, 349,356documents, 377compressed, 376driver, 354font type, 13format, 221, 376graphic, 214, 376files, 211, 213previewer, 376printer, 349, 352, 421usage, 394PostScript file, 70conversion, 347creating, 342viewing, gv commandusage, 376Powell, Patrick, 349PowerQuest, 19, 22PowerQuest Corp, 18ppa module, 65ppmtogif command, 136PPP (Point-to-PointProtocol), 15, 223, 225,249interface, 467manual setup, 229network connections,289protocol, 247sessions, 267starting, kppp commandusage, 239stopping, kppp commandusage, 239support, 227PPP (Point-to-PointProtocol) connection,224, 226, 233, 251, 267,269, 289, 293, 304, 405checking, 243configuringkppp commandusage, 234xisp client usage,240manual start/stop, 232scripts, editing, 230starting, 299, 306stopping, 234ppp-off script, 234ppp-on file, 227, 230ppp-on script, 231-232,246-247usage, 233ppp-on-dialer file, 227ppp-on-dialer script,231-232ppp0 interface, 245diagnosis, 243ppp0 listing, 244pppdcommand line, 231manual pages, 247pppd daemon, 231, 233,246software package, 227pppstats commandusage, 467pppstats program, 467pr command, 329, 338,340-342pr program, 339preformatted tapes, 516presentation graphics,client, 415previewer, 374PostScript, 376primary DNS address,242primary partition, 18print filters, 349print jobs, 349, 351deleting, 351print option, 215print previews, 391, 393print working directory(pwd), 118command, 105usage, 73printed pages, order, 342printenvcommand, 400printenv command, 127,129, 273, 453printer, 11accounting informationutility, 351activating/resetting, 348capabilities, 349, 353configuration, 419lisa command usage,351device driver, 348


560 processes (procs)disabling/enabling, 350filter, 351installation, 421model/type, 13Passthru PostScript, 354port, 492PostScript, 421reconfiguring, 357spool queue, 351warnings, 421Printer ControlLanguage (PCL), formats,345printingcommands, 347operation, cancelling,355requests, 349support, 389WordPerfect configuration,354process, 8number (PID), 131,134, 463, 470reporting, 455status (ps) command,131processes (procs), 461processors, multiple, 8procmail, 266approach, 260configuring, 264filters, 265recipes, 266, 268writing, 265service, 266usage, 265procs (processes), 461productivity programs,324productivity tools, 399profile file, 128profile resource file, 117programborders, 374documentation, reading,376lists, 157memory, dumps, 459names, 137operation, menus, 369running, background,131programmers, 313programmingconstructs, support, 119editor, 324project folder, 424creating, 423prompt command, 291prompt string, 129prompting, interactive,291properties, changing, 193ps (process status) command,79, 131, 133,463-464manual page, 464PS/2 keyboard, 13ps@presario printer, 350psc command, 388psychoanalyze-pinhead,441public domain Korn shell(pdksh), 121, 453, 459,462public domain sc(spreadsheet calculator)spreadsheet, usage, 387public domain softwarelicense, 329, 340put command, 290pwd (print workingdirectory), 118command, 73, 79, 105usage, 73Qq command, 382Q key, 88q option, 170, 273QIC-80 format, 513Quake, 50playing, X Windows,445server browser, 446quake.x11, 374query (-q) option,499-500queue option, 214Quick Erase, 489QuickCam, 378support, 379quotacommand, usage, 476hard limits, 392quota manipulationquota command usage,474quotaoff commandusage, 474quotaon commandusage, 474qweb, 299Rr option, 273r— option, 494RAM (random accessmemory), 45, 47amount, 13RAM (Read AccessMemory), 41, 43, 420Ramey, Chet, 120rasmol, 396RAWRITE3 program,starting, 16RAWRITE3.COM program,16Raymond, Eric S., 25esr, 251rc.boot script, 482rclock, client, 175, 402


pm 561Read Access Memory(RAM), 45, 47, 420read command, 140read permissions, 470read write execute (rws),sequences, 494read write execute (rwx),permission, 496read-only iso9660 filesystem,455read-write enabled file,475readingdirectories, 78files, 78head command, 88,90more command, 86tail command, 88, 90reading commands, 69Exercises, 91Q&A, 91summary, 90README files, 243real-time monitor, 461realname, 276RealNetworks, 304RealPlayerapplication, 303downloading, 310installing, 310plug-in, 304reboot (-r) option, 38receive (rz) files, 308recipes, writing, 264recording script, 56recursive (-r) option,95-96, 101, 457Red Hat, 7, 15, 226, 476,481, 499, 505redirection operator, 123,125, 254, 329, 333, 339,517registers, 382registration number, 336regular expressions, 82definition, 106-108regular reminders scheduling,crontab commandusage, 403remindercreating, 405cron-type scheduling,406message, 411scheduling, 403remote computer, 290,293, 308remote fax machine, 216remote FTP server, 303remote host computer,248remote retrieval, 273remote server, 273remote shell (rsh), 119remote Web page, 303removable filesystems,484removable hard drive,95, 510remove (-r) option, 405removeable driver, 518removeable hard drives,518, 516removeable media, 521removing, directories, 97renaming, files, 98-99reply, direct mailing, 270replyto, 276-277resolutioncapabilities, monitor,147support, 48virtual, 147resolv.conf file, resolving,229resource file, 121-122,162, 319resource settings, 151,162file, default, 163resource string, 162format, 163X11, 163resources file, X11, 171restart (-r) option, 475restoresBRU backup systemconfiguring, 511cpio command usage,517performing considerations,509taper Script usage, 518utility, BRU 2040, 511restricted editor, 321retrieval utility, usage,251reverse Polish notation(RPN/rpn), 382calculator, 383reverse video (+rv/-rv)option, 162revert-buffer command,335revision control, 424rgb (red, green, and blue)values, 161RJ-11 telephone jack,200rjoe editor, 321rm command, 97,100-101, 105, 141, 215,452, 459usage, 95-96, 476rmdir command, 96, 98,105usage, 97rmv script, 137, 140modifying, 141trying, 138ro option, 484rodentiometers, 10root, 77cursor, image, 164directory, 516menus, pop-up, 156partition, 454


562 RPMS directorypermission, 499display, 152, 157, 169,180, 401pictures display, 168window, utility, 168program, 164root operator, 46, 52, 125,128-129, 140, 149, 201,204, 208, 216, 219,229-230, 233, 240, 320,323, 328, 336, 350, 416,452-453, 462, 468,470-471, 479, 483-484,487, 493, 495, 497-498,527running, su (substituteuser) command usage,452root-permission commands,502route command, 227usage, 245rpm, 481command, 310, 346,458, 501usage, 58, 499database, 456, 499, 502,504program, 110, 511usage, 476RPMS directory, 502RPN/rpn (reverse polishnotation), 382calculator, 383rsh (remote shell), 119rtin, program, 273Rumsey, Joe, 444run configuration file,121runlevelmultiuser, 49X11, 49rw- option, 494rwx (read write execute)permission, 496sequences, 494rxvtwindow, 275client, 159-160program, 158rxvt terminal, 131, 136,166, 175, 402emulator, 134, 159starting, 160, 161usage, 159rz (receive) files, 308Ss button sizes, 421s command, 440s off option, 170s option, 170S.U.S.E., 7Saggaf, Muhammad M.,206SANE (Scanner AccessNow Easy), Web pages,378Savola, Tom, 299saytime command, 526sc (spreadsheet calculator),389, 397commands, 388program, 387-388usage, 387sc spreadsheet, 133scale lines, 466Scanner Access NowEasy (SANE), Webpages, 378scanners, 377drivers, 378software, 379support, 377scavenger, 442schedules setting, crontabcommand usage, 525scheduling, 515, 523Q&A, 530programs, OpenLinux,523requests, 527Summary, 530Workshop, 530scotty, 119scqref command, 388screencaptures, 143elements, customizable,151size, 45, 48, 164space, 131screen dumpcreating, 167files, 167screen resolution, 147label, 47screen saverssettings/programs, 169usage, 168X11, 169screen-oriented programs,253screensaver, changing,188screenshotcapturing, 167seeing, 167script, 151customized, 224file (-f) option, 332shells, 136variables, internal, 139scrollbars, 151, 281, 3773D, 151scrolling, 87list, 284window, 147, 279, 293SCSI (Small ComputerSystem Interface), 10,13, 378drive, 64driver, 518


slrn 563interface, 57, 483, 518protocol, low-level, 65support, loading, 65search and replace, 323,336capabilities, 423procedures, 425search criteria, 379search-and-destroy mission,460searchingdirectories, 74file, 105grep command,108-109locate command, 76regular expressions,106-108system, 72whereis command,75less command, 87searching commands, 93Exercises, 116Q&A, 115Summary, 115secondary DNS address,242security enhancements,349sed command, 331sed filter, usage, 329sed s (substitute) command,331self-extracting shellscript, 306send (sz) files, 308sendfaxconfiguration files, 218command, 219program, 218-220software, 218-219sendmail, 249daemon, 253distribution, 467program, 267serial boards, supported,10serial communicationsmodem/port, 199serial interfaces, 57serial mouse, 46serial port, 24, 220, 225,348, 466, 4929-pin male, 200assignments, 13configuring, 205DOS, 200list, 202monitoring, statserialcommand usage, 468number, 13recognition, 225setup, 199, 210speed, 203setting, 206troubleshooting, 468serial printers, 348serial-line connections,234Serial-Line IP (SLIP),234serial-line support, 201serial-port interface, 378server browser, 446server operations, 9ServerFlags,XF86Config, 46session management, 151,178set command, 127set floppy disk parameter(setfdprm) command,486setfdprm (set floppy diskparameter) command,486setup command, 286,325, 416setup script, 422seyonclient, 207communications program,206manual page, 208program, 203, 207, 221,247X11 client, usage, 206sg command, 498sh shell command, 122shadowentry, 471file entry, 470password, system, 471shared libraries, 8shared software libraries,328shareware, 9shell, 157availability, 118built-in commands, 119changing, 472command-line quoting,491consoles, 143customizing, 127definition, 117initialization script, 121launching, 498manual page, 493operators, 329ownership, 131programming, 113prompt, 316command line, 309standard input, 329startup file, 121support, 119UNIX, 117usage, 117, 140Exercises, 141Q&A, 140Summary, 140variable, 127, 137


564 slsc spreadsheetshell command, 131, 136line, 147, 149understanding, 123prompting, 290running, 290shell script, 144, 158, 204,211, 214-215, 219, 293,401, 408, 524, 530self-extracting, 306building, 136showrgb client, 161shutdown command, 38,150, 210usage, 475SIGKILL option, 464SIGKILL signal, 463simulation games, 447single word lookup, 334single-click convenience,178single-letter commands,253single-user mode, 120size, 425slideshow, creating, 167SLIP (Serial-Line IP),234slrnmanual page, 275, 278message display, 277newsreader, 278usage, 274program, 271-272, 278usage/setup, 269starting, 276, 278slsc spreadsheet, 397calculator, 389command, 389usage, 389slsc program, 389Small Computer SystemInterface (SCSI), 378smtp server, 258soffice script, 419soft limits, 462, 475softwaredrivers, 11, 225format, choice, 510installation/installing,451, 499libraries, 369shared, 328license, public domain,329, 330management, 53package, 499administration, dialog,504removing, 499tools, need, 510transport programs, 270solitaire, playing, X11,443sort command, 329, 456soundeasy configuration, 57kernel modules, 52support, 50utilities, 53sound card, 15, 51, 509I/O address, 13IRQ, 13support, 50, 57testing, 53type, 13usage, 41sound configurating/configuration,15COAS usagemanual, 57OpenLinux, 50testing, 53sound module, 51, 55loadable code, 50loading, 50SoundBlaster, 13, 52SoundBlaster-compatiblecard kernel modules,configuring, 56source code, 8-9, 324,384, 387-388, 396, 410retrieval, 290source command, 128,130, 406sox command, 447spacing, 423spam, 268fighting, 264lists, 277spammers, 264, 278spamming, 285SPARC, 9spell checking, 320, 332,421, 425spell command, 74spelling checker, 321correction, 423ispell, 332starting, 426spelling dictionary, 327spelling errors, 332spelling filter, 333spelling program, interactive,332split command, 329split windows, 318split-screen windows, 319spool queue, 351spooled files, 350spreadsheet, 387, 415,428documents, creating,416StarCalc, 433creating, 428data, 431graphing, 431documentsformats, 430files, 390free-for-personal-use,387programs, 208running, 510three-dimensional, 390


system 565spreadsheet calculator(sc), 389, 397, 429commands, 388program, 387-388usage, 387squeeze (-s) option, 330stack, 382Stallman, Richard, 315standalone computer, 463standalone Linux system,211standalone window, 160standard input redirectionoperator, 119standard output redirectionoperator, 119Star Division, 313, 432GmbH, 415StarCalc, 423, 425applications, 391AutoFormat Chart, 431calculations, 428document, 432graphing, 431spreadsheet, 391, 433creating, 428StarCalc SpreadsheetProgram, features, 391StarDivision, registrationpage, 325StarOffice, 96, 191, 324,336, 338, 391-3924.0, 391, 397components, 428-429customization, 420default features, 420desktop, 326, 419,421-422, 428document, 423documents, location,433folders, 422installationconfiguration, 416directory, 325error, 433guide, 416office suite, 10, 423options, 420post-installation, 419printer installation, 421programs, 421sessions, 421setting, 420, 427setup directory, 416starting, 419suite, 313, 324taskbar, 425templates dialog box,391usage, 415, 416, 421learning, 433StarOffice 5.0, 325, 336,391, 397, 416installation, 417dialog box, 416location, 418process, 418StarOffice Mail, usage,420Start Horizontal Retracevalue, 47Start Vertical Retracevalue, 47startup files, 119, 123startup script, 210startx command, 49,144-145, 148usage, 148, 151StarWriter, 324, 338, 423document, 336, 424,427-429, 432-433creating, 326, 336,424, 433saving, 426spell checking, 426text, 431document window,424usage, 423static IP (InternetProtocol) address, 228,235statserial command,usage, 468statserial program, 468status bar, 293status option, 214Staufer, Todd, 299Steuer, Detlef, 444Sticky Buttons, 178sticky note calendar,making, xmessage clientusage, 174stingy-memory-useoption, 370stop bits, 199setting up, 207storage device, 454, 510straight copy, usage, 510stream editors, 329, 331strings command, 116style, 425controls, 423sheets, 393su (substitute user)command, 451usage, 452su command, 90, 233,483, 525usage, 453, 469su - command, 201subjects, searching, 281substitute (sed s) command,331substitute user (su) command,451usage, 452suck command, 286sum command, 329Sun Microsystems, 9, 315SunDisk, 453sunsite, 392support files, 346, 369support routines, 317supported serial boards,10SVGA server, usage, 168swap file, 464, 466usage, 461


566 system administrationswap partition, 13, 24,482Linux, 370swap space, 22, 159, 461swap storage, 370symbolic link, 102-103,121, 158, 205, 210, 318,439, 468, 483, 492, 507checking, symlinkscommand usage, 457creating, 203, 207ln (link) commandusage, 102-103dangling, 458symlinks command,usage, 457sync ranges, 26horizontal, 26, 45vertical, 45sync values, entering, 28syntax errors, 332Syquest EZ-flyer, 510sysadmin (system administrator),458, 463, 468,482, 493, 497, 523sysconfig file, 60systemadministrator (sysadmin),313, 367, 482,493, 497, 516configuration files, editing,474crash, 516dictionary, 333-334editor, default, 321fonts, 46initialization table, 209OpenLinux, 149interrupts, 461log, reading, 246management, 469memory, 13, 19, 370,420, 460-461,464-465RAM, amount, 13resource information,53services, 53sounds, installing, 190usage, 461system administration,451basics, 479Exercises, 477Q&A, 476Summary, 476tool, 469tools, 351system backuprestore, 451tar (tape archive) commandusage, 515System Commander, 18system loadaverages, 466information, gettingtop command usage,464xload commandusage, 464System V, 480system-specific softwaredrivers, 225system-wide settings, 473systemwide alias definitions,129sz (send) files, 308sz -w 2088 filename.tgzcommand, 308Tt option, 116Tab window manager(twm)client, 156starting, 156window managementsession, 156table editor and planner(teapot) spreadsheet program,390table insertions, 425tables, building, 423tac command, 329tail command, 89, 329usage, 88, 90tape archive (tar)archive, 516command, 111-113, 116,515, 521usage, 110-113, 515options, 112program, 116verification, 515tape drive, 10, 509-510,516, 518backups, taper Scriptusage, 518ide, 518restores, taper Scriptusage, 518tape driver, floppy drive,518taperbackup software package,installing, 499command, 501usage, 518program, 518Script, 520usage, 518software, 499, 501tar (tape archive), 510archive, 516command, 111-113, 116,124, 216, 515, 521usage, 110-113, 515options, 112program, 116verification, 515target diskette, 16taskbar, 158, 180, 425Taylor, Dave, 255


toolbar 567Tcl interpreter, 119tclsh shells, 119TCP/IP (TransportControlProtocl/InternetProtocol), 227, 242tcsh, 30tcsh shell, 118, 129features, 122usage, 462teapot (table editor andplanner) spreadsheetprogram, 390tee command, 135Tektronix 4054 emulation,159telecommunicationsscripting language,built-in, 206telecommunicationsscripts, writing, 206telnet commandrunning, 308usage, 308telnet session, 308termcap, manual page,129terminal client, usage,147terminal command line,374terminal emulator,134, 159color-capable, 158-159kvt, 158multilingual, 158rxvt, 159starting, 161starting, 160X11, 158terminal programs,143, 158X11, 157terminal settingsxterm, changing, 158terminal window, 44, 129,137, 151, 158, 165, 166,204, 240, 244, 248, 282,286, 438, 443-444, 461,488, 502command line, 154,301, 324, 444, 448emulator, 158text regions, 166test option, 212TeXdirectories, 346distribution, 346files, 346documentation, 346formatting commands,346formatting system, 347Frequently AskedQuestions (FAQ) document,346information files, 346system, 356typesetting system, 346usage, 346-347TeX dvi, 345documents, previewing,346text, 345block, 320configuration files, 313control, 423editing tools, 335insertion, directorymode, 320menus, 322mode program, 439selections, 423stream, 329, 342tools, 314utilities, 329, 335text changefilter usage, 329sed filter usage, 329text documents, 332conversion, 356formatting, 335printing, 347spellchecking, 335text editor, 46, 56, 64,126, 136, 144, 149, 209,219, 229, 252, 254, 257,271-272, 313, 317, 332,335, 406, 409, 473, 475,484built-in, 206default, 403features, 320pico, 403usage, 128, 338, 474text file, 45, 87, 162, 204,331compressed, 201formatting, 347insertion, 323opening, 316sending, 338text filters, 329, 332usage, 338text formatting, 335, 342groff formatter usage,342TeX usage, 346text filters usage, 338text printing, 313Exercises, 336Q&A, 335Summary, 335text processing, 313Exercises, 336Q&A, 335Summary, 335text-based interface, 43text-only data files,importing, 388text-only Web browser,300text-only Web browsing,226text-wrap mode, 317tgif, 379TGUI9680, 14Theilson, Tim, 376


568 toolsthemes, K DesktopEnvironment, 35thesaurus, 327support, 424threads, reading, 270three-button emulation,159three-button emulator,enabling, 46three-dimensionalspreadsheets, 390TIFF graphic, 136tile-cache size, 370tiled format, 169time, keeping, X11 clocksusage, 174timeout, 237interval, 170tincalling, 273commands, 274manual page, 274newsreader, 271program, 269-273reader, 270settings, 274tinrc file, 274title bar, 156, 158changing, 193tload command, 466to-do checklists, 406Token-ring interface, 57toolbar, 419formatting, 425icon, 425vertical, 425, 427, 431tools, 371top command, 464usage, 464top program, 464Torvalds, Linus, 8touch command, 94usage, 94, 475touch-tone dialing, 226tput command, 527tr (transliterate) command,329usage, 331transfer mode, binary,291transliterate (tr) command,329transparent digital clock,175transport agents, 250Transport ControlProtocl/InternetProtocol (TCP/IP), 227,242transport programs, 270Tranter, Jeff, 468trash directory, 141tree command, 101, 480trn, program, 286Truscott, Tom, 269ttyS0, 226ttyS1, 226ttyS1 serial port, 219ttyS3, 226twm (Tab window manager),151client, 156window managementsession, 156window manager, starting,156two-button mouse, users,42Type II PC card slot, 57Type III PC card slot, 57typeset documents, 338typesettingcommands, 338inserted, 347macros, 344program, 338systems, 356UUID (user identification),469-470ulimit command, 459,462ulimit setting, 459ulimit shell, viewing, 462ultra-verbose (vv) option,501umask command, 493umount command, 433,484usage, 61uname -r command, 348uname -v command, 348uname command, 50unattended backup, 515uncompressing files,106-108undo command, 335undo levels, 369undump, X11 windows,167unexpand command, 329Uniform ResourceLocator (URL), 229,299, 303uninstall (-e) option, 499uniq command, 135, 329unit conversions performance,units commandusage, 385unitscommand, 385-386usage, 385manual page, 386Universal Serial Bus(USB), 13University of Helsinki, 8University of Kansas, 299University of NorthCarolina, 392University ofWashington, 319


vv (ultra-verbose) option 569University of Wisconsin-Milwaukee, 390UNIX, 134AT&T System V, 480distribution, 122, 480experience, 9mail, 250operating system, 286programs, 349shells, 117systems, 387, 480wizards, 249UNIXC, 249UNSUBSCRIBE, 266unused files, compressing,460up command, 440up option, 63updatedb command,76-77, 525upgrade (-U) option, 499,501uptime command, 529usage, 466URL (Uniform ResourceLocator), 229, 299, 303USB (Universal SerialBus), 13drive, 64USENET/Usenet, 229,267articles, 303group, preposting, 285news, 269, 286NetscapeDiscussions usage,282news readingkrn client usage, 278slrn newsreaderusage, 274tin newsreaderusage, 271newsgroups, 247, 257,270-271, 280, 283,304FAQs, 285postings, 277readers, 274software transport programs,270useraccess, managing, 468account, 469agent, 250, 253usage, 251bball, 135cloobie, 470creating, adduser commandusage, 469comma-delimited list,493cron scheduling, managing,525domain, 258group, 498hard drive storage spacelimits, 473identification (UID),469-470management, 49lisa command usage,469multiple, 8option, 484preference, 165scheduling managing,atrun command usage,527usermod command, 477username, 118, 149, 218,228-230, 252, 276-277,279, 295-296, 309,452-453, 469-470, 472,526usrquota, 475utilities distribution, 384uucp software documentation,204uudecode command, 115uuencode command, 115uugetty program, 220Vv option, 111, 116, 516van Smoorenburg,Miquel, 204vdir command, 82, 84velvet, 396verbose mode (-v) option,487verify (-V) option, 499Vertical Display Endvalue, 47vertical sync ranges, 45vertical toolbar, 425, 427,431Vertical Total value, 47VFAT/vfat filesystem,453, 482, 483vfat partition, 516vi command, 320vi default editor, 403vi editor, 317, 319, 413video card, 10, 65selecting, 26video chipset, 10, 45, 47video frequency, 47video graphics, display,NeoMagic, 146video memory, 147amount, 14, 46video modes, 43video monitors, 43video RAM, 47amount, 27video resolution, 45-46video sync pulse, 47video tuning, 45video-mode switching, 45videomode, 28VideoRam setting, 47view editor, 319view option, 214Viking Components, 225vim (visual improved)documentation, 319command, 319-320


570 w commandeditor, 318, 526variants, 317package, 318vimrc resource files, 318virtual console, 9, 48,131, 148, 453usage, X11 usage, 147virtual desktops, 151, 180virtual memory, 9command, vmstat commandusage, 461statistics, 461virtual resolution, 147virtual screen, 45, 48, 148size, support, 48visual improved (vim)command, 319, 320documentation, 319editor, 318variants, 317visual improved (vim)package, 318Vixie, Paul, 403vmstat command, usage,461vprint program, 390VRAM, 225VT Fonts, 159vv (ultra-verbose) option,501Ww command, 79, 440usage, 466w option, 111-112wait option, 214wall command, 527wallpaperdefault, 169pop-up menu, 187WAV format, 191wc (word count) command,88, 135, 329wc (word count) program,332Web, text-only browsing,226Web address, 299Web browser, 161, 271,298, 310, 377, 464amaya, 310lynx, 321, 346text-only, 300Web browsing, 223Web page, 229, 299browsing, 299content, 300Netscape, 303remote, 303Web site, 448Linux archive, 175web2 (dictionary), 334Weeks, Dan, 155Wharf dock, 156What is OpenLinux,usage, 7What-You-See-Is-What-You-Get (WYSIWYG)editor, 356whatis command, 72,76-77, 526whatis database, 77-78whatis program, 71whereis command, 77usage, 75whereis ifconfig command,227whoami command, 453whois command, 248wildcard, 84, 215usage, 172, 375Williams, Thomas, 394Win9x filesystems, 482window borders, 151window buttons3D, 151changing, 193window capture utility,373window colors, 152-153window controls, 157window shade-type,156window dumpfile, 367program, X11, 167window emulatorterminal, 158window frames, 374window information, getting,xwininfo clientusage, 173window manager, 143,148, 151, 158, 164, 176AfterStep, 155configuration, 151default, 153, 156-157fvwm, 152, 154-155configuring, 151modules, 151settings, 153twm, 151starting, 156X11, 150window operations, 156window settings, 161window shade-type windowcontrols, 156window-handling functions,152windowing shell (wish),119windowing system, network,42Windows, 3598, 2859x, 12applications, 457decorations, 152desktop, 19fonts, 153information utility, 173module definitions, 152NT, 9


X11 571operating system, 457partition, 74, 104, 515mounting, 507utility, 516Wing, Ben, 315Wingz, 390spreadsheet, finding,390WINMGR setting, 157Winmodem, 11-12, 225PC cards, 58winprinters, 11WinStorm, 225Wireless network interfaces,57wish (windowing shell),119wmconfig command, 152Woelfelschneider, Olav,438word count (wc) command,135word count (wc) program,332word processing, 161,319, 332, 510documents, creating,416file formats, 327word processor, 135, 166,208, 324, 326, 334, 335,338, 415, 423component, 328features, 320Linux environment, 313WYSIWYG, 328word search, 320word-wrap mode, 317word wrapping, 317, 319,320, 323, 340WordPerfectconfiguration, 354document window, 326documents, 355installation, 326WordPerfect 8.0 (Corel),313, 326, 338, 354WordStar, 321WordStar-compatiblekeyboard commands,321work area, 423World Wide Web(WWW)browsers, 289browsing, 298Linux browsers, usage,298Wuebben, BerndJohannes, 384WWW (World WideWeb)browsers, 289browsing, 298Linux browsers, usage,298WYSIWYG (What-You-See-Is-What-You-Get),327editor, 356word processor, 328XXconfiguring, 149server, options, 46starting, 144x (extract) option,515-516X display manager(xdm),150, 180client, 149X interface, 511X man page, 163X manual page, 160X resources, 163X server, 46, 48, 146usage, 48Xfree86, 46X session, 143, 147-148,157, 181, 190, 374-375,411, 436, 479colors, 146exiting, 46mode, 147resolution, 147settings, 153starting, 145, 148-149,151, 324startup, setup/settings,152usage, 148X terminal client, 166X Toolkit, 406command-line options,159-160options, 160, 173X window managers,148, 187X Window System, 10,18, 26-27, 35, 42, 72, 94,117, 156, 162, 175, 177,179, 203, 206, 223, 260,286, 319, 321, 324, 328,351, 373-374, 382-383,388-389, 444-445, 468,502configuring, 15, 41Exercises, 66process, 42Q&A, 65Summary, 65games, 442post-installation issues,41running, 299, 376usage, 143, 394Exercises, 176Q&A, 176Summary, 175X Windows, Quake, playing,445


572 X11, startingX-ISP dialog box, 240X11, 42, 72, 80, 119, 224,261, 270, 275, 278, 310,466, 502application defaults,298backgammon, playing,444basic operations, learning,160bitmap format, 168bitmap graphics directory,168color support, 389configuring, 14, 42console window, colorcapable,159cursor modes, changing,164cutting/pasting process,165display, 175, 176distribution, 65, 176environment, 145Galaga, playing, 444games, 442ical client, usage, 405interface, 405login, bypass process,41limitation, 374logging in, xdm commandusage, 149mouse modes, changing,164needing, 225nonusage, 439requiring, 505restarting, 157root window, customization,168runlevel, 49running, 203-204, 234,390, 416, 453, 503rxvt terminal, 136, 402screen savers, 169server, 11, 42settings, fine-tuning, 66solitaire, playing, 443usage, 61, 131, 147,204, 369, 409, 466,476, 488utilities, 175, 477workstations, 159xcalc Client, usage, 383xspread program, 390xwd command, 136X11, starting, 143, 149color depths usage, 145X11 client, 143, 148, 154,160, 162, 165-166, 207,211, 300, 306, 351, 375,379, 384, 396, 399, 401,407, 444, 447xboing, 445documentation, reading,376geometry settings,usage, 160launching, 156manual pages, 163resources, setting, 162running, 147usage, 167xpat2, 443X11 clockclient, 402usage, 174X11 desktop, 166, 374displays, 157X11 fontsdisplay, 164listing, xlsfonts usage,172X11 program, 220, 448exploring, 172X11 resourcefile, 171settings, 317strings, 163X11 server, 170, 173color depth, 168X11 sessions, 46, 235,267, 278 342, 374, 511starting, 49, 66, 144,148, 151X11 terminal, 129, 158emulators, 158menu-enabled, 158programs, 157window, 48, 204, 234,240, 255, 305, 309,316, 383, 395, 461,464X11 Toolkit options, 158,300, 316, 376, 442support, 369X11 windowscapturing/dumping, 167dump format, 167dump graphics file, creating,367-368dump program, 167manager, 131, 144, 150,178undump, 167X11 xvclient, 215, 220graphic program, 215x86 architecture, 9xargs command, 135, 459xbl, 442xboard clientusage, 442xboing, 147, 374manual page, 445X11 client, 445xcalccalculator, 383client, 383command, 383usage, 383manual page, 383xchomp, 442


xwininfo client, usage 573xclipboard client, 166xclock program, 171xcmap client, 161xcolorsel client, 161xcopy, 490xcutsel client, 166xdaliclock client, 175xdemineuer, 442xdmalternative, 150login screen, 149-150xdm (X display manager),180client, 150command, 149, 152usage, 149xdvi files, 345xemacs, 316, 335customization, 317Xemacs/xemacsenvironment, features,315editor, 318package, 317program, 317starting, 317XF86Config/xf86configcommand, 43-44file, 45-46, 146, 179,433understanding, 47keyboard, 46Screen, 48ServerFlags, 46settings, 46usage, 46XF86_Mono, 48, 161XF86_SVGA, 48server, 161mode, 48X11 server, 27XF86_VGA16, 42server, 48, 161xfd client, 164xfig, 147, 379xfmail, 268xfontsel client, 159xfontsel window, 159xfractint, 396XFree86, 158, 165user, 47X server, 46Xfree86 Project, Inc., 42,143XFree86 X WindowSystem, 383XFree86-Video-Timings-HOWTO, 47xgal game, 444xgammon client, 444Xi-Graphics, 178Xircom ethernet cards,11xisp, 223xisp accountclient, 15, 229, 247command, usage, 243configuring, 241xjed, 321xjewel, 442XKEYBOARD extension,433xlander, 442xload, 477client, 466command, 466usage, 464xloadimageclient, 167-168formatting, 169manual page, 167xlock client, 171xlsfontsclient, usage, 172usage, 172xmag client, 165xmag program, 165xman command, 72xmessage, 401command, 400program, 400xmessage client, 176usage, 174window display, 174xmgr, 396xmh, 268xminicomcommand, 204script, 204shell script, 204xmixer, 53, 57command, 448xmodmapclient, 165command, 433manual page, 165xmseconfig client, 165xosview, 477client, 466xpaintclient, 163, 379drawing program, 163drawing window, 165window, 165xpat2manual page, 444solitaire game, 443X11 client, 443xpdf, 377client, 416xpilot, 442xplaycdclient, usage, 435, 438player, 438xpmtoppm command,output, 368xpuzzles, 442xqf Quake server browser,446xrn, program, 286xscreensaver client, 170,171xscreensaver-commandclients, 170xsetusage, 165


574 Y2K compliancexset clientmanual page, 165usage, 170xset command, usage,170xset m \, 165xset s option, 170xsetrootclient, 164, 168command, 169xspread program, 390XT, 10xteddy client, 448xtermclient, 158-159program, 158running, 158starting, 158terminal, 80, 166, 204settings, changing,158window, 158-159, 275X11 terminal, 129xtrojka, 442xv client, 167, 375function, 375xv command, 376usage, 374xv documentation, 376xv X11 client, 379xvidtune client, starting,66xwd client, 367-368xwd command, 136xwd program, 167xwdtopnm command,136xwininfo client, usage,173YY2K compliance, 402yorick interpreter, 396yow, 441Zz option, 515Zawinski, Jamie, 170zftape driver, 518Zip 254 drive, 64usage, 65Zip backup device, 513Zip diskdevice, 518mounting/usage, 64unmounting, 65Zip drive, 64, 513usage, 41utility, 490Zip parallel-port drive,usage, 65Zip Plus drive, 64zless pager, 201ZMODEM communicationsprotocol, 308Zoltrix Phantom/Spirit,225zoom levels, 424zsh, 30zsh shell, 122, 135documentation, 135


GNU GENERAL PUBLIC LICENSEVersion 2, June 1991Copyright © 1989, 1991 Free Software Foundation, Inc.675 Mass Ave, Cambridge, MA 02139, USAEveryone is permitted to copy and distribute verbatim copies of this license document, but changingit is not allowed.PreambleThe licenses for most software are designed to take away your freedom to share and change it. Bycontrast, the GNU General Public License is intended to guarantee your freedom to share andchange free software—to make sure the software is free for all its users. This General PublicLicense applies to most of the Free Software Foundation’s software and to any other programwhose authors commit to using it. (Some other Free Software Foundation software is covered bythe GNU Library General Public License instead.) You can apply it to your programs, too.When we speak of free software, we are referring to freedom, not price. Our General PublicLicenses are designed to make sure that you have the freedom to distribute copies of free software(and charge for this service if you wish), that you receive source code or can get it if you want it,that you can change the software or use pieces of it in new free programs; and that you know youcan do these things.To protect your rights, we need to make restrictions that forbid anyone to deny you these rights orto ask you to surrender the rights. These restrictions translate to certain responsibilities for you ifyou distribute copies of the software, or if you modify it.For example, if you distribute copies of such a program, whether gratis or for a fee, you must givethe recipients all the rights that you have. You must make sure that they, too, receive or can get thesource code. And you must show them these terms so they know their rights.We protect your rights with two steps: (1) copyright the software, and (2) offer you this licensewhich gives you legal permission to copy, distribute and/or modify the software.Also, for each author’s protection and ours, we want to make certain that everyone understands thatthere is no warranty for this free software. If the software is modified by someone else and passedon, we want its recipients to know that what they have is not the original, so that any problemsintroduced by others will not reflect on the original authors’ reputations.Finally, any free program is threatened constantly by software patents. We wish to avoid the dangerthat redistributors of a free program will individually obtain patent licenses, in effect making theprogram proprietary. To prevent this, we have made it clear that any patent must be licensed foreveryone’s free use or not licensed at all.The precise terms and conditions for copying, distribution and modification follow.GNU GENERAL PUBLIC LICENSETERMS AND CONDITIONS FOR COPYING, DISTRIBUTION ANDMODIFICATION0. This License applies to any program or other work which contains a notice placed by thecopyright holder saying it may be distributed under the terms of this General Public License.The “Program“, below, refers to any such program or work, and a “work based on theProgram” means either the Program or any derivative work under copyright law: that is tosay, a work containing the Program or a portion of it, either verbatim or with modificationsand/or translated into another language. (Hereinafter, translation is included without limitationin the term “modification”.) Each licensee is addressed as “you”.


Activities other than copying, distribution and modification are not covered by this License;they are outside its scope. The act of running the Program is not restricted, and the outputfrom the Program is covered only if its contents constitute a work based on the Program(independent of having been made by running the Program). Whether that is true depends onwhat the Program does.1. You may copy and distribute verbatim copies of the Program’s source code as you receive it,in any medium, provided that you conspicuously and appropriately publish on each copy anappropriate copyright notice and disclaimer of warranty; keep intact all the notices that referto this License and to the absence of any warranty; and give any other recipients of theProgram a copy of this License along with the Program.You may charge a fee for the physical act of transferring a copy, and you may at your optionoffer warranty protection in exchange for a fee.2. You may modify your copy or copies of the Program or any portion of it, thus forming awork based on the Program, and copy and distribute such modifications or work under theterms of Section 1 above, provided that you also meet all of these conditions:a) You must cause the modified files to carry prominent notices stating that you changedthe files and the date of any change.b) You must cause any work that you distribute or publish, that in whole or in part containsor is derived from the Program or any part thereof, to be licensed as a whole atno charge to all third parties under the terms of this License.c) If the modified program normally reads commands interactively when run, you mustcause it, when started running for such interactive use in the most ordinary way, toprint or display an announcement including an appropriate copyright notice and anotice that there is no warranty (or else, saying that you provide a warranty) and thatusers may redistribute the program under these conditions, and telling the user how toview a copy of this License. (Exception: if the Program itself is interactive but doesnot normally print such an announcement, your work based on the Program is notrequired to print an announcement.)These requirements apply to the modified work as a whole. If identifiable sections of thatwork are not derived from the Program, and can be reasonably considered independent andseparate works in themselves, then this License, and its terms, do not apply to those sectionswhen you distribute them as separate works. But when you distribute the same sections aspart of a whole which is a work based on the Program, the distribution of the whole must beon the terms of this License, whose permissions for other licensees extend to the entirewhole, and thus to each and every part regardless of who wrote it.Thus, it is not the intent of this section to claim rights or contest your rights to work writtenentirely by you; rather, the intent is to exercise the right to control the distribution of derivativeor collective works based on the Program.In addition, mere aggregation of another work not based on the Program with the Program(or with a work based on the Program) on a volume of a storage or distribution mediumdoes not bring the other work under the scope of this License.3. You may copy and distribute the Program (or a work based on it, under Section 2) in objectcode or executable form under the terms of Sections 1 and 2 above provided that you alsodo one of the following:a) Accompany it with the complete corresponding machine-readable source code, whichmust be distributed under the terms of Sections 1 and 2 above on a medium customarilyused for software interchange; or,b) Accompany it with a written offer, valid for at least three years, to give any thirdparty, for a charge no more than your cost of physically performing source distribution,a complete machine-readable copy of the corresponding source code, to be distributedunder the terms of Sections 1 and 2 above on a medium customarily used forsoftware interchange; or,


c) Accompany it with the information you received as to the offer to distribute correspondingsource code. (This alternative is allowed only for noncommercial distributionand only if you received the program in object code or executable form with suchan offer, in accord with Subsection b above.)The source code for a work means the preferred form of the work for making modificationsto it. For an executable work, complete source code means all the source code for all modulesit contains, plus any associated interface definition files, plus the scripts used to controlcompilation and installation of the executable. However, as a special exception, the sourcecode distributed need not include anything that is normally distributed (in either source orbinary form) with the major components (compiler, kernel, and so on) of the operating systemon which the executable runs, unless that component itself accompanies the executable.If distribution of executable or object code is made by offering access to copy from a designatedplace, then offering equivalent access to copy the source code from the same placecounts as distribution of the source code, even though third parties are not compelled tocopy the source along with the object code.4. You may not copy, modify, sublicense, or distribute the Program except as expressly providedunder this License. Any attempt otherwise to copy, modify, sublicense or distribute theProgram is void, and will automatically terminate your rights under this License. However,parties who have received copies, or rights, from you under this License will not have theirlicenses terminated so long as such parties remain in full compliance.5. You are not required to accept this License, since you have not signed it. However, nothingelse grants you permission to modify or distribute the Program or its derivative works. Theseactions are prohibited by law if you do not accept this License. Therefore, by modifying ordistributing the Program (or any work based on the Program), you indicate your acceptanceof this License to do so, and all its terms and conditions for copying, distributing or modifyingthe Program or works based on it.6. Each time you redistribute the Program (or any work based on the Program), the recipientautomatically receives a license from the original licensor to copy, distribute or modify theProgram subject to these terms and conditions. You may not impose any further restrictionson the recipients’ exercise of the rights granted herein. You are not responsible for enforcingcompliance by third parties to this License.7. If, as a consequence of a court judgment or allegation of patent infringement or for anyother reason (not limited to patent issues), conditions are imposed on you (whether by courtorder, agreement or otherwise) that contradict the conditions of this License, they do notexcuse you from the conditions of this License. If you cannot distribute so as to satisfysimultaneously your obligations under this License and any other pertinent obligations, thenas a consequence you may not distribute the Program at all. For example, if a patent licensewould not permit royalty-free redistribution of the Program by all those who receive copiesdirectly or indirectly through you, then the only way you could satisfy both it and thisLicense would be to refrain entirely from distribution of the Program.If any portion of this section is held invalid or unenforceable under any particular circumstance,the balance of the section is intended to apply and the section as a whole is intendedto apply in other circumstances.It is not the purpose of this section to induce you to infringe any patents or other propertyright claims or to contest validity of any such claims; this section has the sole purpose ofprotecting the integrity of the free software distribution system, which is implemented bypublic license practices. Many people have made generous contributions to the wide rangeof software distributed through that system in reliance on consistent application of that system;it is up to the author/donor to decide if he or she is willing to distribute softwarethrough any other system and a licensee cannot impose that choice.This section is intended to make thoroughly clear what is believed to be a consequence ofthe rest of this License.


8. If the distribution and/or use of the Program is restricted in certain countries either bypatents or by copyrighted interfaces, the original copyright holder who places the Programunder this License may add an explicit geographical distribution limitation excluding thosecountries, so that distribution is permitted only in or among countries not thus excluded. Insuch case, this License incorporates the limitation as if written in the body of this License.9. The Free Software Foundation may publish revised and/or new versions of the GeneralPublic License from time to time. Such new versions will be similar in spirit to the presentversion, but may differ in detail to address new problems or concerns.Each version is given a distinguishing version number. If the Program specifies a versionnumber of this License which applies to it and “any later version”, you have the option offollowing the terms and conditions either of that version or of any later version published bythe Free Software Foundation. If the Program does not specify a version number of thisLicense, you may choose any version ever published by the Free Software Foundation.10. If you wish to incorporate parts of the Program into other free programs whose distributionconditions are different, write to the author to ask for permission. For software which iscopyrighted by the Free Software Foundation, write to the Free Software Foundation; wesometimes make exceptions for this. Our decision will be guided by the two goals of preservingthe free status of all derivatives of our free software and of promoting the sharingand reuse of software generally.NO WARRANTY11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WAR-RANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLELAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLD-ERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM “AS IS” WITHOUT WAR-RANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOTLIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESSFOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY ANDPERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAMPROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,REPAIR OR CORRECTION.12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO INWRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAYMODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BELIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCI-DENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE ORINABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OFDATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BYYOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITHANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEENADVISED OF THE POSSIBILITY OF SUCH DAMAGES.END OF TERMS AND CONDITIONSLinux and the GNU systemThe GNU project started 12 years ago with the goal of developing a complete free UNIX-likeoperating system. “Free” refers to freedom, not price; it means you are free to run, copy, distribute,study, change, and improve the software.A UNIX-like system consists of many different programs. We found some components alreadyavailable as free software—for example, X Windows and TeX. We obtained other components byhelping to convince their developers to make them free—for example, the Berkeley network utilities.Other components we wrote specifically for GNU—for example, GNU Emacs, the GNU Ccompiler, the GNU C library, Bash, and Ghostscript. The components in this last category are“GNU software”. The GNUsystem consists of all three categories together.


The GNU project is not just about developing and distributing free software. The heart of theGNU project is an idea: that software should be free, and that the users’ freedom is worth defending.For if people have freedom but do not value it, they will not keep it for long. In order to makefreedom last, we have to teach people to value it.The GNU project’s method is that free software and the idea of users’ freedom support each other.We develop GNU software, and as people encounter GNU programs or the GNU system and startto use them, they also think about the GNU idea. The software shows that the idea can work inpractice. People who come to agree with the idea are likely to write additional free software. Thus,the software embodies the idea, spreads the idea, and grows from the idea.This method was working well—until someone combined the Linux kernel with the GNU system(which still lacked a kernel), and called the combination a “Linux system.”The Linux kernel is a free UNIX-compatible kernel written by Linus Torvalds. It was not writtenspecifically for the GNU project, but the Linux kernel and the GNU system work together well. Infact,adding Linux to the GNU system brought the system to completion: it made a free UNIXcompatibleoperating system available for use.But ironically, the practice of calling it a “Linux system” undermines our method of communicatingthe GNU idea. At first impression, a “Linux system” sounds like something completely distinctfrom the “GNU system.” And that is what most users think it is. Most introductions to the“Linux system” acknowledge the role played by the GNU software components. But they don’t saythat the system as a whole is more or less the same GNU system that the GNU project has beencompiling for a decade. They don’t say that the idea of a free UNIX-like system originates fromthe GNU project. So most users don’t know these things.This leads many of those users to identify themselves as a separate community of “Linux users”,distinct from the GNU user community. They use all of the GNU software; in fact, they use almostall of the GNU system; but they don’t think of themselves as GNU users, and they may not thinkabout the GNU idea.It leads to other problems as well—even hampering cooperation on software maintenance.Normally when users change a GNU program to make it work better on a particular system, theysend the change to the maintainer of that program; then they work with the maintainer, explainingthe change, arguing for it and sometimes rewriting it, to get it installed.But people who think of themselves as “Linux users” are more likely to release a forked “Linuxonly”version of the GNU program, and consider the job done. We want each and every GNU programto work “out of the box” on Linux-based systems; but if the users do not help, that goalbecomes much harder to achieve.So how should the GNU project respond? What should we do now to spread the idea that freedomfor computer users is important?We should continue to talk about the freedom to share and change software—and to teach otherusers to value these freedoms. If we enjoy having a free operating system, it makes sense for tothink about preserving those freedoms for the long term. If we enjoy having a variety of free software,it makes sense for us to think about encouraging others to write additional free software,instead of additional proprietary software.We should not accept the splitting of the community in two. Instead we should spread the wordthat “Linux systems” are variant GNU systems—that users of these systems are GNU users, andthat they ought to consider the GNU philosophy which brought these systems into existence.This article is one way of doing that. Another way is to use the terms “Linux-based GNU system”(or “GNU/Linux system” or “Lignux” for short) to refer to the combination of the Linux kerneland the GNU system.Copyright 1996 Richard Stallman(Verbatim copying and redistribution is permitted without royalty as long as this notice is preserved.)The Linux kernel is Copyright © 1991, 1992, 1993, 1994 Linus Torvaldis (others hold copyrightson some of the drivers, file systems, and other parts of the kernel) and and is licensed under theterms of the GNU General Public License.


The FreeBSD CopyrightAll of the documentation and software included in the 4.4BSD and 4.4BSD-Lite Releases is copyrightedby The Regents of the University of California.Copyright 1979, 1980, 1983, 1986, 1988, 1989, 1991, 1992, 1993, 1994 The Regents of theUniversity of California. All rights reserved.Redistribution and use in source and binary forms, with or without modification, are permitted providedthat the following conditions are met:1. Redistributions of source code must retain the above copyright notice, this list of conditionsand the following disclaimer.2. Redistributions in binary form must reproduce the above copyright notice, this list of conditionsand the following disclaimer in the documentation and/or other materials providedwith the distribution.3. All advertising materials mentioning features or use of this software must display the followingacknowledgement:This product includes software developed by the University of California, Berkeley and itscontributors.4. Neither the name of the University nor the names of its contributors may be used to endorseor promote products derived from this software without specific prior written permission.THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS “AS IS” ANDANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THEIMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULARPURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORSBE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, ORCONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OFSUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESSINTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHERIN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHER-WISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISEDOF THE POSSIBILITY OF SUCH DAMAGE.The Institute of Electrical and Electronics Engineers and the American National StandardsCommittee X3, on Information Processing Systems have given us permission to reprint portions oftheir documentation.In the following statement, the phrase “this text” refers to portions of the systemdocumentation.Portions of this text are reprinted and reproduced in electronic form in the second BSDNetworking Software Release, from IEEE Std 1003.1-1988, IEEE Standard Portable OperatingSystem Interface for Computer Environments (POSIX), copyright © 1988 by the Institute ofElectrical and Electronics Engineers, Inc. In the event of any discrepancy between these versionsand the original IEEE Standard, the original IEEE Standard is the referee document.In the following statement, the phrase “This material” refers to portions of the system documentation.This material is reproduced with permission from American National Standards Committee X3, onInformation Processing Systems. Computer and Business Equipment Manufacturers Association(CBEMA), 311 First St., NW, Suite 500, Washington, DC 20001-2178. The developmental work ofProgramming Language C was completed by the X3J11 Technical Committee.The views and conclusions contained in the software and documentation are those of the authorsand should not be interpreted as representing official policies, either expressed or implied, of theRegents of the University of California.www@FreeBSD.ORGCopyright © 1995-1997 FreeBSD Inc. All rights reserved.


Bill BallTeach YourselfLinux®in24 HoursSECOND EDITIONA Division of Macmillan Computer Publishing201 West 103rd St., Indianapolis, Indiana, 46290 USA


Sams Teach Yourself Linux ® in 24 Hours,Second EditionCopyright © 1999 by Sams PublishingAll rights reserved. No part of this book shall be reproduced, stored in aretrieval system, or transmitted by any means, electronic, mechanical, photocopying,recording, or otherwise, without written permission from the publisher.No patent liability is assumed with respect to the use of the informationcontained herein. Although every precaution has been taken in the preparationof this book, the publisher and author assume no responsibility for errors oromissions. Neither is any liability assumed for damages resulting from the useof the information contained herein.International Standard Book Number: 0-672-31526-2Library of Congress Catalog Card Number: 98-88372Printed in the United States of AmericaFirst Printing: April 199900 99 98 4 3 2 1TrademarksAll terms mentioned in this book that are known to be trademarks or servicemarks have been appropriately capitalized. SAMS Publishing cannot attest tothe accuracy of this information. Use of a term in this book should not beregarded as affecting the validity of any trademark or service mark.Warning and DisclaimerEvery effort has been made to make this book as complete and as accurate aspossible, but no warranty or fitness is implied. The information provided is onan “as is” basis. The author and the publisher shall have neither liability norresponsibility to any person or entity with respect to any loss or damages arisingfrom the information contained in this book or from the use of the CD orprograms accompanying it.EXECUTIVE EDITORJeff KochACQUISITIONS EDITORGretchen GanserDEVELOPMENT EDITORSean DixonMANAGING EDITORBrice GosnellPROJECT EDITORGretchen UphoffCOPY EDITORKristine SimmonsKelly TalbotINDEXERRobert SaighPROOFREADERAndrew BeasterTECHNICAL EDITORKurt WallSOFTWARE DEVELOPMENTSPECIALISTMichael HunterINTERIOR DESIGNGary AdairCOVER DESIGNAren HowellLAYOUT TECHNICIANSAyanna LaceyHeather Hiatt MillerAmy Parker


Contents at a GlanceIntroduction 1PART I INSTALLATION AND CONFIGURATION 5Hour 1 Preparing to Install Linux 72 Installing Linux 233 Post-Installation Issues 41PART II LEARNING LINUX BASICS 67Hour 4 Reading and Navigation Commands 695 Manipulation and Searching Commands 936 Using the Shell 1177 Using the X Window System 1438 Exploring the K Desktop Environment 177PART III CONNECTING TO THE OUTSIDE WORLD 197Hour 9 Using Communications Programs 19910 Connecting to the Internet 22311 Configuring Internet Email 24912 Configuring Internet News 26913 Internet Downloading and Browsing 289PART IV USING LINUX PRODUCTIVELY 311Hour 14 Text Processing 31315 Preparing Documents 33716 Graphics Tools 35917 Learning Math and Financial Tools 38118 Personal Productivity Tools 39919 Home Office Management with StarOffice 41520 Relaxation and Playing Linux Games 435


PART V ADMINISTERING YOUR SYSTEM 449Hour 21 Basic System Administration 45122 Handling Files and Your File System 47923 Backing Up and Restoring Your System 50924 Using Scheduling to Automate System Management 523Index 531


Table of ContentsINTRODUCTION 1PART I INSTALLATION AND CONFIGURATION 5HOUR 1 PREPARING TO INSTALL LINUX 7What is Linux? ........................................................................................................8What is OpenLinux?................................................................................................9What Equipment is Required? ..............................................................................10What Equipment is Supported? ............................................................................10What Equipment Doesn’t Work? ..........................................................................11Winprinters ......................................................................................................11Winmodems......................................................................................................12Infrared Ports....................................................................................................12What Equipment Do I Have? ................................................................................13How Do I Plan for the Installation? ......................................................................14Booting the Install from CD-ROM ..................................................................15Booting the Install from Floppies ....................................................................16Other Ways ......................................................................................................17Planning Your Boot Process ..................................................................................17Preparing Your Hard Drive ....................................................................................18Preparing Your Hard Drive from Windows ......................................................19Summary................................................................................................................21Q&A ......................................................................................................................22Exercises ................................................................................................................22HOUR 2 INSTALLING LINUX 23Beginning the Installation......................................................................................24Finishing Your Linux Installation ..........................................................................31Logging in to Linux..........................................................................................35Rebooting and Shutting Down ........................................................................38Summary................................................................................................................38Q&A ......................................................................................................................39Exercises ................................................................................................................39HOUR 3 POST-INSTALLATION ISSUES 41The X Window System..........................................................................................42How the X Window System is Configured ....................................................42The XF86Config File ....................................................................................45Bypassing or Disabling the kdm Login Display ..............................................48Starting an X11 Session ..................................................................................49


viSams Teach Yourself Linux in 24 Hours, Second EditionConfiguring Sound for OpenLinux........................................................................50Loading Sound Modules ..................................................................................50Testing Your Sound Configuration ..................................................................53Configuring Sound with COAS........................................................................53A Quick Recording Script................................................................................56Configuring Sound the Easy Way ....................................................................57Enabling PCMCIA Cards ......................................................................................57Configuring Network Information with COAS ....................................................61Configuring Your Ethernet Interface ................................................................61Using an Iomega Zip Drive with OpenLinux........................................................64Summary ..............................................................................................................65Q&A ......................................................................................................................65Exercises ..............................................................................................................66PART II LEARNING LINUX BASICS 67HOUR 4 READING AND NAVIGATION COMMANDS 69Getting Help with the man Command ..................................................................69Navigating and Searching the File System............................................................72Moving to Different Directories with the cd Command ................................72Knowing Where You Are with the pwd Command ..........................................73Searching Directories for Matching Files with the find Command ..............74Finding Files with the whereis Command ....................................................75Locating Files with the locate Command ....................................................76Getting Command Summaries with whatis and apropos ............................76Reading Directories and Files................................................................................78Listing Directories with the ls Command ....................................................78Listing Directories with the dir and vdir Commands ..................................82Listing and Combining Files with the cat Command ....................................84Reading Files with the more Command ..........................................................86Browsing Files with the less Command ........................................................87Reading the Beginning or End of Files with the head and tail Commands ....88Summary................................................................................................................90Q&A ......................................................................................................................91Exercises ................................................................................................................91HOUR 5 MANIPULATION AND SEARCHING COMMANDS 93Manipulating Files or Directories..........................................................................93Creating Files with the touch Command........................................................94Deleting Files with the rm Command ..............................................................95Creating Directories with the mkdir Command..............................................96


ContentsviiRemoving Directories with the rmdir Command ..........................................97Renaming Files with the mv Command............................................................98Copying with the cp Command ....................................................................100Creating Hard and Symbolic Links with the ln Command ..........................102Handling Files with the Midnight Commander Program ..............................104Searching Files ....................................................................................................105What Are Regular Expressions? ....................................................................106Searching Inside Files with the grep Commands ........................................108Compressing and Uncompressing Files ..............................................................110Creating Archives with the Tape Archive Command ....................................110Creating cpio Archives..................................................................................113Compressing Files with the gzip Command ................................................114Compressing Files with the compress Command........................................114Summary..............................................................................................................115Q&A ....................................................................................................................115Exercises ..............................................................................................................116HOUR 6 USING THE SHELL 117What is a Shell? ..................................................................................................117What Shells are Available? ..................................................................................118Features of ash ..............................................................................................119Features of the Default Linux Shell—bash ..................................................120The Public Domain Korn Shell—pdksh ......................................................121Features of the csh-Compatible Shell—tcsh................................................122zsh..................................................................................................................122Understanding the Shell Command Line ............................................................123Customizing Your Shell..................................................................................127Running Programs in the Background ..........................................................131How to Use Pipes ..........................................................................................134Building Shell Scripts..........................................................................................136Summary..............................................................................................................140Q&A ....................................................................................................................140Exercises ..............................................................................................................141HOUR 7 USING THE X WINDOW SYSTEM 143Starting X ............................................................................................................144Starting X11 with Different Color Depths ....................................................145Using Virtual Consoles with X11 ..................................................................147Starting Multiple X11 Sessions......................................................................148Logging in to OpenLinux and X11 with xdm................................................149X11 Window Managers ......................................................................................150Configuring the fvwm Window Manager ......................................................151Starting AfterStep ..........................................................................................155Starting the twm Window Manager ................................................................156


viiiSams Teach Yourself Linux in 24 Hours, Second EditionX11 Terminal Programs ......................................................................................157Changing the xterm Terminal Settings ..........................................................158Using the Memory-Efficient rxvt Terminal..................................................159Learning X11 Basic Operations ..........................................................................160Using X11 Client Geometry Settings ............................................................160Setting Background and Foreground Colors for X11 Clients........................161Setting X11 Client Resources ........................................................................162Changing X11 Mouse and Cursor Modes......................................................164How to Copy and Paste in X11......................................................................165Capturing and Dumping X11 Windows ........................................................167Customizing the X11 Root Window and Using Screen savers......................168Exploring X11 Programs ....................................................................................172Listing X11 Fonts with xlsfonts ................................................................172Getting Window Information with the xwininfo Client ..............................173Making a Sticky Note Calendar with the xmessage Client..........................174Keeping Time with X11 Clocks ....................................................................174Summary..............................................................................................................175Q&A ....................................................................................................................176Exercises ..............................................................................................................176HOUR 8 EXPLORING THE K DESKTOP ENVIRONMENT 177Starting KDE........................................................................................................179Features of the KDE Desktop..............................................................................180Performing Basic Desktop Actions ................................................................180Using Desktop panel ......................................................................................181Editing the KDE Panel Menu ........................................................................182Using the kfm File Manager ..........................................................................183Configuring KDE with the KDE Control Center ................................................184Using Display Manager Options....................................................................185Changing Your Desktop’s Wallpaper..............................................................187Changing Your Screensaver............................................................................188Changing Default Fonts..................................................................................189Installing System Sounds ..............................................................................190Changing Keyboard and Mouse Settings ......................................................191Changing Window Buttons, Properties, and Title Bars..................................193Controlling Cursor Movement Through Desktops ........................................195Summary..............................................................................................................195Q&A ....................................................................................................................196Exercises ..............................................................................................................196


ContentsixPART III CONNECTING TO THE OUTSIDE WORLD 197HOUR 9 USING COMMUNICATIONS PROGRAMS 199Setting Up and Testing Your Modem ..................................................................200Creating /dev/modem with the lisa Command ..........................................201Dialing Out with Communications Programs ....................................................203Setting Up and Calling Out with minicom....................................................204Setting Up and Calling Out with the seyon X11 Client ................................206Setting Up Your Linux System for Dialing In................................................208Sending and Receiving Faxes..............................................................................211Faxing with the efax System ........................................................................211Sending Fax Documents with the ksendfax Client........................................216Sending Fax Documents with mgetty+sendfax ............................................218Summary..............................................................................................................220Q&A ....................................................................................................................221Exercises ..............................................................................................................221HOUR 10 CONNECTING TO THE INTERNET 223Hardware You Need ............................................................................................224Linux Software You Need....................................................................................226Information You Need from Your ISP ................................................................228Setting Up a PPP Connection Manually..............................................................229Editing the resolv.conf File ........................................................................229Editing the PPP Connection Scripts ..............................................................230Manually Starting and Stopping PPP Connections ............................................232Using minicom to Connect..............................................................................232Using Your ppp-on Script to Connect ............................................................233Stopping the PPP Connection ........................................................................234Configuring a PPP Connection with kppp ..........................................................234Configuring Your kppp Connection ................................................................235Starting and Stopping PPP with kppp ............................................................239Configuring a PPP Connection with xisp ..........................................................240Configuring a New xisp Account ..................................................................241Starting and Stopping PPP with xisp ............................................................243Checking the Connection ....................................................................................243Using the ifconfig Command ......................................................................243Using the netstat Command ........................................................................244Using the ping Command ..............................................................................245Using the route Command ............................................................................245Reading Your System Log..............................................................................246Summary..............................................................................................................247Q&A ....................................................................................................................247Exercises ..............................................................................................................248


xSams Teach Yourself Linux in 24 Hours, Second EditionHOUR 11 CONFIGURING INTERNET EMAIL 249Setting Up and Getting Your Email ....................................................................249Retrieving Your Email with fetchmail ..........................................................251Sending Mail with Mail Programs ......................................................................253Using the mail Program ................................................................................253Configuring and Using the elm Mail Program ..............................................255Configuring and Using the pine Mail Program ............................................257Configuring and Using Netscape Messenger for Email ................................260Subscribing to Mailing Lists ..........................................................................263Configuring procmail and Writing Recipes to Fight Spam................................264Summary..............................................................................................................267Q&A ....................................................................................................................267Exercises ..............................................................................................................268HOUR 12 CONFIGURING INTERNET NEWS 269Reading Usenet News with the tin Newsreader ................................................271Reading Usenet News with the slrn Newsreader ..............................................274Reading Usenet News with the krn Client ..........................................................278Reading Usenet News with Netscape Discussions..............................................282Before Posting to a Usenet Group ......................................................................285Summary..............................................................................................................286Q&A ....................................................................................................................286Exercises ..............................................................................................................287HOUR 13 INTERNET DOWNLOADING AND BROWSING 289Using File Transfer Protocol Programs to Get Files ..........................................290Retrieving Files with the ftp Command........................................................290Downloading with the ncFTP Program ..........................................................297Browsing the World Wide Web with Linux Browsers ........................................298Fast Browsing with the lynx Command ........................................................299Exploring Netscape Communicator ..............................................................300Chatting with Internet Relay Chat ......................................................................304Installing and Configuring AOL Instant Messenger............................................306Connecting with Other Computers with the telnet Command..........................308Summary..............................................................................................................309Q&A ....................................................................................................................310Exercises ..............................................................................................................310


ContentsxiPART IV USING LINUX PRODUCTIVELY 311HOUR 14 TEXT PROCESSING 313Word Processors in the Linux Environment........................................................313Features of the XEmacs Environment............................................................315Variants of the VIsual iMproved Editor —vim ..............................................317Features of Pine’s pico Editor........................................................................319Five Editors in One—joe ..............................................................................321Configuring the jed Editor ............................................................................321Using the kedit Editor Client ........................................................................322Using the CRiSPlite Editor ............................................................................324StarOffice’s StarWriter ..................................................................................324Corel’s WordPerfect for Linux ......................................................................326Applix Words..................................................................................................327Changing Text with sed and Other Filters ....................................................329Spell Checking Your Documents ........................................................................332Correcting Documents with the ispell Command ......................................332Single Word Lookup and Other Tricks ..........................................................334Summary..............................................................................................................335Q&A ....................................................................................................................335Exercises ..............................................................................................................336HOUR 15 PREPARING DOCUMENTS 337Formatting Text....................................................................................................337Formatting Text Using Text Filters ................................................................338Formatting Text with the groff Formatter ....................................................342Formatting Text with TeX ..............................................................................346Printing Text Documents ....................................................................................347Printing Documents with the LPRng Printing System ....................................349Configuring Your Printer with the lisa Command........................................351Configuring WordPerfect for Printing............................................................354Summary..............................................................................................................356Q&A ....................................................................................................................356Exercises ..............................................................................................................357HOUR 16 GRAPHICS TOOLS 359Understand Linux Graphics File Formats ..........................................................360Converting and Viewing Graphics ......................................................................367Graphics Editing with GIMP..........................................................................369Graphics Editing with ImageMagick ............................................................373Using the xv Command to View Graphics ....................................................374Using the gv Command to View PostScript Files ..........................................376


xiiSams Teach Yourself Linux in 24 Hours, Second EditionA Word About Digital Cameras and Scanners ....................................................377Summary..............................................................................................................379Q&A ....................................................................................................................379Exercises ..............................................................................................................379HOUR 17 LEARNING MATH AND FINANCIAL TOOLS 381Calculators ..........................................................................................................382Doing Desk Calculations with the dc Command ..........................................382Calculating with the X11 xcalc Client ..........................................................383Calculating with the kcalc Client ..................................................................383Performing Unit Conversions with the units Command ..............................385Programming Calculators with the bc Language Interpreter ........................386Spreadsheets ........................................................................................................387Using the Public Domain sc Spreadsheet ......................................................387Using the slsc Spreadsheet............................................................................389Finding the Free Wingz Spreadsheet ..............................................................390Features of the StarCalc Spreadsheet Program ............................................391Commercial Features of the Applixware Spreadsheet Program ....................393Using gnuplot to Graph Mathematical Formulas ..............................................394Summary..............................................................................................................396Q&A ....................................................................................................................396Exercises ..............................................................................................................397HOUR 18 PERSONAL PRODUCTIVITY TOOLS 399Scheduling Personal Reminders and Tasks with the at Command ....................400Scheduling Regular Reminders with the crontab Command ............................403Creating Appointment Reminders with the X11 ical Client..............................405Checking the Calendar and Keeping Appointments with emacs ........................409Setting Alarms with the knotes Client ................................................................411Summary..............................................................................................................412Q&A ....................................................................................................................413Exercises ..............................................................................................................413HOUR 19 HOME OFFICE MANAGEMENT WITH STAROFFICE 415Installing and Configuring StarOffice ................................................................416Starting StarOffice..........................................................................................419Customizing StarOffice ..................................................................................420Installing a Printer for StarOffice ..................................................................421Using StarOffice ..................................................................................................421Creating Documents with StarWriter ............................................................423Spellchecking and Saving StarWriter Documents ........................................426Calculating with StarCalc ..............................................................................428Graphing with StarCalc..................................................................................431


ContentsxiiiSummary..............................................................................................................432Q&A ....................................................................................................................433Exercises ..............................................................................................................433HOUR 20 RELAXATION AND PLAYING LINUX GAMES 435Playing Music CDs with the kscd and xplaycd Clients......................................435Playing Music with the xplaycd Client..........................................................438Games for the Console ........................................................................................439Playing emacs Games ....................................................................................441Games for the X Window System ......................................................................442Playing Chess with the xboard Client............................................................442Playing X11 Solitaire ....................................................................................443Playing Backgammon for X11 ......................................................................444Playing Galaga for X11..................................................................................444Breakout the Fun with the X11 Client xboing ..............................................445Playing Quake for X Windows........................................................................445Summary..............................................................................................................447Q&A ....................................................................................................................447Exercises ..............................................................................................................448PART V ADMINISTERING YOUR SYSTEM 449HOUR 21 BASIC SYSTEM ADMINISTRATION 451Running as the root Operator with the su Command..........................................452Getting Disk Space Information..........................................................................454Getting Filesystem Statistics with the df Command ....................................454Getting Filesystem Disk Usage with the du Command ................................455Checking Symbolic Links with the symlinks Command ..............................457Saving Disk Space..........................................................................................458Getting Memory Information ..............................................................................460Memory Reporting with the free Command ................................................461Virtual Memory Reporting with the vmstat Command ................................461Viewing Your Shell’s “Ulimit”ations..............................................................462Reclaiming Memory with the kill Command ..............................................463Getting System Load Information with the top and xload Commands..............464Determining How Long Linux Has Been Running with the uptime andw Commands ................................................................................................466Getting Network and Mail Information with the pppstats and mailstatsCommands ..................................................................................................467Monitoring Your Serial Ports with the statserial Command......................468Managing User Access ........................................................................................468


xivSams Teach Yourself Linux in 24 Hours, Second EditionCreating Users with the adduser Command ..................................................469Managing Users with the lisa Command ....................................................469Changing Passwords with the passwd Command ..........................................470Restricting Logins ..........................................................................................472Setting Disk Quotas........................................................................................473Summary..............................................................................................................476Q&A ....................................................................................................................476Exercises ..............................................................................................................477HOUR 22 HANDLING FILES AND YOUR FILE SYSTEM 479How OpenLinux Is Organized ............................................................................480Using the mount Command to Access Other Filesystems ..................................482Understanding the Filesystem Table, /etc/fstab ..............................................482Formatting a Floppy ............................................................................................484Formatting Floppies with the KFloppy Client ....................................................488The mtools Package ............................................................................................489Managing File Ownership and Permissions ........................................................491Understanding Linux File Types ....................................................................492Reading File Permissions Flags ....................................................................492Changing File Permissions with the chmod Command........................................494Changing File Ownership with the chown Command. ........................................496Changing Groups and Ownerships with the chgrp and newgrp Commands ......497Managing Linux Software with rpm, lisa, and kpackage ..................................499Using the rpm Command ................................................................................499Using kpackage ..............................................................................................502Using the lisa Command ..............................................................................505Summary..............................................................................................................507Q&A ....................................................................................................................508Exercises ............................................................................................................508HOUR 23 BACKING UP AND RESTORING YOUR SYSTEM 509Considerations Before Performing Backups and Restores..................................509Configuring the BRU Backup System for Backups and Restores ................511Backing Up Your System with the tar Command ........................................515Using the cpio Command to Backup and Restore ........................................517Using the taper Script for Tape Drive Backups and Restores ......................518Summary..............................................................................................................520Q&A ....................................................................................................................520Exercises ..............................................................................................................521


ContentsxvHOUR 24 USING SCHEDULING TO AUTOMATE SYSTEM MANAGEMENT 523Using the cron Daemon ......................................................................................524Managing User cron Scheduling....................................................................525Setting Schedules with the crontab Command ............................................525Managing User Scheduling with the atrun Command ......................................527Controlling the batch and at Commands ......................................................528Summary..............................................................................................................530Q&A ....................................................................................................................530Exercises ..............................................................................................................530INDEX 531


About the AuthorBill Ball is the author of several best-selling books about Linux: Sams Teach YourselfLinux in 24 Hours, Que’s Using Linux, Sams Red Hat Linux Unleashed, and Sams Howto Use Linux. He is a technical writer, editor, and magazine journalist and has been workingwith computers for the past 20 years. He first started working with Linux, beginningwith kernel version .99, after moving from BSD4.3 Machten for the Apple Macintosh.He has published articles in magazines such as Computer Shopper and MacTechMagazine and first started editing books for Que in 1986. An avid fly fisherman, hebuilds bamboo fly rods and fishes on the nearby Potomac River when he’s not driving hisvintage MG sports cars. He lives in the Shirlington area of Arlington County, Virginia.


DedicationTo my lovely wife Cathy for her kindness, understanding—and most importantly, killercoffee in the morning.AcknowledgmentsThanks are due to the following people at Macmillan: Theresa Ball (for books), LynetteQuinn (for being my mentor), Tracy Williams (for finding lost contracts), GretchenGanser (for making me chill out), Sean Dixon (a great development editor), Jeff Koch(for the opportunities), and Eric Goldfarb (for keeping mcp.com online all the time).Special thanks to Kurt Wall—without his technical expertise, edits, and advice, I’d looklike an idiot. Thanks are also due to the kind folks at Caldera Systems, Inc. and theNorthern Virginia Linux Users Group, especially Gregory J. Pryzby! Thanks to LinusTorvalds for Linux, Richard M. Stallman for the GNU GPL, and Eric S. Raymond (esr)for carrying forward the Open Source Software banner. Finally, thanks to Bill Gates formaking Linux more popular than ever.


Tell Us What You Think!As the reader of this book, you are our most important critic and commentator. We valueyour opinion and want to know what we’re doing right, what we could do better, whatareas you’d like to see us publish in, and any other words of wisdom you’re willing topass our way.As the executive editor for the Operating Systems team at Macmillan ComputerPublishing, I welcome your comments. You can fax, email, or write me directly to let meknow what you did or didn’t like about this book—as well as what we can do to makeour books stronger.Please note that I cannot help you with technical problems related to the topic of thisbook and that due to the high volume of mail I receive, I might not be able to reply toevery message.When you write, please be sure to include this book’s title and author as well as yourname and phone or fax number. I will carefully review your comments and share themwith the author and editors who worked on the book.Fax: 317.581.4663Email:Mail:opsys@mcp.comExecutive EditorOperating SystemsMacmillan Computer Publishing201 West 103rd StreetIndianapolis, IN 46290 USA

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!