BUY THIS BOOK

Safari Books Online

What is this?

Looking to Reprint this content?


Running Linux, Third Edition By Matt Welsh, Matthias Kalle Dalheimer, Lar Kaufman
August 1999
Pages: 752

Cover | Table of Contents | Colophon


Table of Contents

Chapter 1: Introduction to Linux
This is a book about Linux, a free Unix clone for personal computer systems that supports full multitasking, the X Window System, TCP/IP networking, and much more. Hang tight and read on: in the pages that follow, we describe the system in meticulous detail.
Linux has generated more excitement in the computer field than any other development of the past several years. Its surprisingly fast spread and the loyalty it inspires recall the excitement of do-it-yourself computing that used to characterize earlier advances in computer technology. Ironically, it succeeds by rejuvenating one of the oldest operating systems still in widespread use, Unix. Linux is both a new technology and an old one.
In narrow technical terms, Linux is just the operating system kernel, offering the basic services of process scheduling, virtual memory, file management, and device I/O. In other words, Linux itself is the lowest-level part of the operating system.
However, most people use the term "Linux" to refer to the complete system—the kernel along with the many applications that it runs: a complete development and work environment including compilers, editors, graphical interfaces, text processors, games, and more.
This book will be your guide to Linux's shifting and many-faceted world. Linux has developed into an operating system for businesses, education, and personal productivity, and this book will help you get the most out of it.
Linux can turn any personal computer into a workstation. It will give you the full power of Unix at your fingertips. Businesses are installing Linux on entire networks of machines, using the operating system to manage financial and hospital records, distributed-user computing environments, telecommunications, and more. Universities worldwide are using Linux for teaching courses on operating-systems programming and design. And, of course, computing enthusiasts everywhere are using Linux at home, for programming, document production, and all-around hacking.
Apart from workstation and personal use (many people find it convenient to run Linux on their laptop computers), Linux is also being used to drive big servers. Increasingly, people are discovering that Linux is powerful, stable, and flexible enough to run the largest disk arrays and multiprocessor systems—with applications ranging from World Wide Web servers to corporate databases. Scientists are wiring together arrays of Linux machines into enormous "clusters" to solve the most computationally intensive problems in physics and engineering. With the latest release of the Samba software suite, Linux can even act as a Windows file and print server—with better performance than Windows NT!
Additional content appearing in this section has been removed.
Purchase this book now or read it online at Safari to get the whole thing!
About This Book
This book is an overview and entry-level guide to the Linux system. We attempt to present enough general and interesting information on a number of topics to satisfy Unix novices and wizards alike. This book should provide sufficient material for almost anyone to install and use Linux and get the most out of it. Instead of covering many of the volatile technical details—those things that tend to change with rapid development—we give you enough background to find out more on your own.
This book is geared for those people who really want to exploit the power that Linux provides. Rather than gloss over all of the tricky details, we give you enough background to truly understand how the various parts of the system work, so you can customize, configure, and troubleshoot the system on your own.
Linux is not difficult to install and use. However, as with any implementation of Unix, there is often some black magic involved to get everything working correctly. We hope this book will get you on the Linux tour bus and show you how cool this operating system can be.
In this book, we cover the following topics:
  • What is Linux? The design and philosophy of this unique operating system, and what it can do for you.
  • All the details needed to run Linux, including suggestions on what kind of hardware configuration is recommended for a complete system.
  • How to obtain and install Linux. We cover the Red Hat, SuSE, and Debian distributions in more detail than others, but the background here should be adequate to cover any release of the system.
  • For new users, an introduction to the Unix system, including an overview of the most important commands and concepts.
  • The care and feeding of the Linux system, including system administration and maintenance, upgrading the system, and how to fix things when they don't work.
Additional content appearing in this section has been removed.
Purchase this book now or read it online at Safari to get the whole thing!
A Brief History of Linux
Unix is one of the most popular operating systems worldwide because of its large support base and distribution. It was originally developed as a multitasking system for minicomputers and mainframes in the mid-1970s. It has since grown to become one of the most widely used operating systems anywhere, despite its sometimes confusing interface and lack of central standardization.
The real reason for Unix's popularity? Many hackers feel that Unix is the Right Thing—the One True Operating System. Hence, the development of Linux by an expanding group of Unix hackers who want to get their hands dirty with their own system.
Versions of Unix exist for many systems, ranging from personal computers to supercomputers such as the Cray Y-MP. Most versions of Unix for personal computers are quite expensive and cumbersome. At the time of this writing, a one-machine version of AT&T's System V for the 386 runs at about $US1500.
Linux is a freely distributable version of Unix, originally developed by Linus Torvalds, who began work on Linux in 1991 as a student at the University of Helsinki in Finland. Linus now works for Transmeta Corporation, a start-up in Santa Clara, California, and continues to maintain the Linux kernel, that is, the lowest-level core component of the operating system.
Linus released the initial version of Linux for free on the Internet, inadvertently spawning one of the largest software-development phenomena of all time. Today, Linux is authored and maintained by a group of several thousand (if not more) developers loosely collaborating across the Internet. Companies have sprung up to provide Linux support, to package it into easy-to-install distributions, and to sell workstations pre-installed with the Linux software. In March 1999, the first Linux World Expo trade show was held in San Jose, California, with reportedly well over 12,000 people in attendance. Most estimates place the number of Linux users worldwide somewhere around the 10 million mark (and we expect this number will look small by the time you read this).
Additional content appearing in this section has been removed.
Purchase this book now or read it online at Safari to get the whole thing!
Who's Using Linux?
Application developers, system administrators, network providers, kernel hackers, multimedia authors: these are a few of the categories of people who find that Linux has a particular charm.
Unix programmers are increasingly using Linux because of its cost—they can pick up a complete programming environment for a few dollars and run it on cheap PC hardware—and because Linux offers a great basis for portable programs. It's a modern operating system that is POSIX-compliant and looks a lot like System V, so code that works on Linux should work on other contemporary systems. Linux on a modest PC runs faster than many Unix workstations.
Networking is one of Linux's strengths. It has been adopted with gusto by people who run community networks like Free-Nets or who want to connect nonprofit organizations or loose communities of users through UUCP. Linux makes a good hub for such networks. Since Linux also supports Network File System (NFS) and Network Information Service (NIS), you can easily merge a personal computer into a corporate or academic network with other Unix machines. It's easy to share files, support remote logins, and run applications on other systems. Linux also supports the Samba software suite, which allows a Linux machine to act as a Windows file and print server—many people are discovering that the combination of Linux and Samba for this purpose is faster (and cheaper) than running Windows NT.
Kernel hackers were the first to come to Linux—in fact, the ones who helped Linus Torvalds create Linux—and are still a formidable community. If you want to try tuning buffer sizes and the number of table entries to make your applications run a little faster, Linux is one of your best choices. You'll get a lot of sympathy on the Net when things go wrong, too.
Finally, Linux is becoming an exciting forum for multimedia. This is because it's compatible with an enormous variety of hardware, including the majority of modern sound and video cards. Several programming environments, including the MESA 3D toolkit (a free OpenGL implementation), have been ported to Linux. The GIMP (a free Adobe Photoshop work-alike) was originally developed under Linux, and is becoming the graphics manipulation and design tool of choice for many artists. For example, during the production of the movie "Titanic," Linux machines (with Alpha processors) were used to render some of the trick effects.
Additional content appearing in this section has been removed.
Purchase this book now or read it online at Safari to get the whole thing!
System Features
Linux supports most of the features found in other implementations of Unix, plus quite a few not found elsewhere. This section is a nickel tour of the Linux kernel features.
One potentially confusing aspect of Linux for newcomers is the way in which different pieces of software are assigned a version number. When you first approach Linux, chances are you'll be looking at a CD-ROM distribution, such as "Red Hat Version 5.2" or "SuSE Linux Version 6.0." It's important to understand that these version numbers only relate to the particular distribution (which is a prepackaged version of Linux along with tons of free application packages, usually sold on CD-ROM). Therefore, the version number assigned by Red Hat, SuSE, or Debian might not have anything to do with the individual version numbers of the software in that distribution. Don't be fooled—just because one distribution company uses a higher version number than another doesn't mean that the software is any more up-to-date.
The Linux kernel, as well as each application, component, library, or software package in a Linux distribution, generally has its own version number. For example, you might be using gcc Version 2.7.2.3, as well as the XFree86 graphical user interface Version 3.3.1. As you can guess, the higher the version number, the newer the software is. By installing a distribution (such as Red Hat and SuSE), all of this is simplified for you since the latest versions of each package are usually included in the distribution.
The Linux kernel has a peculiar version numbering scheme that you should be familiar with. As mentioned before, the kernel is the core operating system itself, responsible for managing all of the hardware resources in your machine—such as disks, network interfaces, memory, and so on. Unlike Windows systems, the Linux kernel doesn't include any application-level libraries or graphical user interfaces. In some sense, as a user you will never interact with the kernel directly, but rather through interfaces such as the shell or the GUI (more on this later).
Additional content appearing in this section has been removed.
Purchase this book now or read it online at Safari to get the whole thing!
Software Features
In this section, we'll introduce you to many of the software applications available for Linux and talk about a number of common computing tasks. After all, the most important part of the system is the wide range of software available for it. What's even more impressive on Linux is that most of this software is freely distributable.
Virtually every utility you would expect to find on standard implementations of Unix has been ported to Linux. This includes basic commands such as ls, awk, tr, sed, bc, more, and so on. There are Linux ports of many popular software packages including Perl, Python, the Java Development Kit, and more. You name it—Linux has it. Therefore, you can expect your familiar working environment on other Unix systems to be duplicated on Linux. All of the standard commands and utilities are there. (Novice Unix users should see Chapter 4 for an introduction to these basic Unix commands.)
Many text editors are available, including vi (as well as "modern" versions, such as vim), ex, pico, and jove, as well as GNU Emacs and variants, such as XEmacs (which incorporates extensions for use under the X Window System) and joe. Whatever text editor you're accustomed to using has more than likely been ported to Linux.
The choice of a text editor is an interesting one. Many Unix users still use "simple" editors such as vi (in fact, the authors wrote this book using vi and Emacs under Linux). However, vi has many limitations due to its age, and more modern (and complex) editors, such as Emacs, are gaining popularity. Emacs supports a complete LISP-based macro language and interpreter, a powerful command syntax, and other fun-filled extensions. Emacs macro packages exist to allow you to read electronic mail and news, edit the contents of directories, and even engage in an artificially intelligent psychotherapy session (indispensable for stressed-out Linux hackers). In Chapter 9, we include a complete
Additional content appearing in this section has been removed.
Purchase this book now or read it online at Safari to get the whole thing!
About Linux's Copyright
Linux is covered by what is known as the GNU General Public License, or GPL. The GPL, which is sometimes referred to as a "copyleft" license, was developed for the GNU project by the Free Software Foundation. It makes a number of provisions for the distribution and modification of "free software." "Free," in this sense, refers to freedom, not just cost. The GPL has always been subject to misinterpretation, and we hope that this summary will help you to understand the extent and goals of the GPL and its effect on Linux. A complete copy of the GPL is available at http://www.gnu.org/copyleft/gpl.html.
Originally, Linus Torvalds released Linux under a license more restrictive than the GPL, which allowed the software to be freely distributed and modified, but prevented any money changing hands for its distribution and use. The GPL allows people to sell and make profit from free software, but doesn't allow them to restrict the right for others to distribute the software in any way.
First, we should explain that "free software" covered by the GPL is not in the public domain. Public domain software is software that is not copyrighted and is literally owned by the public. Software covered by the GPL, on the other hand, is copyrighted to the author or authors. This means that the software is protected by standard international copyright laws and that the author of the software is legally defined. Just because the software may be freely distributed doesn't mean it is in the public domain.
GPL-licensed software is also not "shareware." Generally, "shareware" software is owned and copyrighted by the author, but the author requires users to send in money for its use after distribution. On the other hand, software covered by the GPL may be distributed and used free of charge.
The GPL also allows people to take and modify free software, and distribute their own versions of the software. However, any derived works from GPL software must also be covered by the GPL. In other words, a company could not take Linux, modify it, and sell it under a restrictive license. If any software is derived from Linux, that software must be covered by the GPL as well.
Additional content appearing in this section has been removed.
Purchase this book now or read it online at Safari to get the whole thing!
Open Source and the Philosophy of Linux
When new users encounter Linux, they often have a few misconceptions and false expectations of the system. Linux is a unique operating system, and it's important to understand its philosophy and design in order to use it effectively. At the center of the Linux philosophy is a concept that we now call Open Source Software.
Open Source is a term that applies to software for which the source code—the inner workings of the program—is freely available for anyone to download, modify, and redistribute. Software covered under the GNU GPL, described in the previous section, fits into the category of Open Source. Not surprisingly, though, so does a lot of other software that uses copyright licenses similar, but not identical, to the GPL. For example, software that can be freely modified but that does not have the same strict requirements for redistribution as the GPL is also considered Open Source.
The so-called "Open Source development model" is a phenomenon that started with the Free Software Foundation and which was popularized with Linux. It's a totally different way of producing software that opens up every aspect of development, debugging, testing, and study to anyone with enough interest in doing so. Rather than relying upon a single corporation to develop and maintain a piece of software, Open Source allows the code to evolve, openly, in a community of developers and users who are motivated by desire to create good software, rather than simply make a profit.
O'Reilly & Associates, Inc., has published a book, Open Sources, which serves as a good introduction to the Open Source development model. It's a collection of essays about the Open Source process by leading developers (including Linus Torvalds and Richard Stallman) and was edited by Chris DiBona, Sam Ockman, and Mark Stone.
Open Source has received a lot of media attention, and some are calling the phenomenon the "next wave" in software development, which will sweep the old way of doing things under the carpet. It still remains to be seen whether that will happen, but there have been some encouraging events that make this outcome seem not so unlikely. For example, Netscape Corporation has released the code for their web browser as an Open Source project called Mozilla, and companies such as Sun Microsystems, IBM, and Apple have announced plans to release certain products as Open Source in the hopes that they will flourish in a community-driven software development effort.
Additional content appearing in this section has been removed.
Purchase this book now or read it online at Safari to get the whole thing!
Differences Between Linux and Other Operating Systems
It's important to understand the differences between Linux and other operating systems, such as Windows 95/98, Windows NT, OS/2, and other implementations of Unix for the personal computer. First of all, it should be made clear that Linux will coexist happily with other operating systems on the same machine: that is, you can run Windows NT and OS/2 along with Linux on the same system without problems. There are even ways to interact between the various operating systems, as you'll see.
Why use Linux instead of a commercial operating system? We could give you a thousand reasons. One of the most important, however, is that Linux is an excellent choice for personal Unix computing. If you're a Unix software developer, why use Windows at home? Linux will allow you to develop and test Unix software on your PC, including database and X applications. If you're a student, chances are that your university computing system runs Unix. With Linux, you can run your own Unix system and tailor it to your own needs. Installing and running Linux is also an excellent way to learn Unix if you don't have access to other Unix machines.
But let's not lose perspective. Linux isn't just for personal Unix users. It's robust and complete enough to handle large tasks, as well as distributed computing needs. Many businesses are moving to Linux in lieu of other Unix-based workstation environments. Linux has an excellent price-performance ratio, is one of the most stable and powerful operating systems available, and because of its Open Source nature, is completely customizable for your needs. Universities are finding Linux to be perfect for teaching courses in operating systems design. Larger commercial software vendors are starting to realize the opportunities a free operating system can provide.
It's not uncommon to run both Linux and Windows 95/98 on the same system. Many Linux users rely on Windows for applications such as word processing and productivity tools. While Linux provides its own analogs for these applications (for example, TeX), and commercial software support for Linux is increasing, there are various reasons why a particular user would want to run Windows as well as Linux. If your entire dissertation is written using Microsoft Word, you may not be able to easily convert it to TeX or some other format (although the Star Office suite for Linux can probably do the trick). There are many commercial applications for Windows that aren't available for Linux, and there's no reason why you can't use both.
Additional content appearing in this section has been removed.
Purchase this book now or read it online at Safari to get the whole thing!
Hardware Requirements
Now, you must be convinced of how wonderful Linux is and of all the great things that it can do for you. However, before you rush out and install the software, you need to be aware of its hardware requirements and limitations.
Keep in mind that Linux was developed by its users. This means, for the most part, that the hardware supported by Linux is that which users and developers actually have access to. As it turns out, most of the popular hardware and peripherals for 80x86 systems are supported (in fact, Linux probably supports more hardware than any commercial implementation of Unix). However, some of the more obscure and esoteric devices, as well as those with proprietary drivers for which the manufacturers do not easily make the specifications available, aren't supported yet. As time goes on, a wider range of hardware will be supported, so if your favorite devices aren't listed here, chances are that support for them is forthcoming.
Another drawback for hardware support under Linux is that many companies have decided to keep the hardware interface proprietary. The upshot of this is that volunteer Linux developers simply can't write drivers for those devices (if they could, those drivers would be owned by the company that owned the interface, which would violate the GPL). The companies that maintain proprietary interfaces write their own drivers for operating systems, such as Microsoft Windows; the end user (that's you) never needs to know about the interface. Unfortunately, this does not allow Linux developers to write drivers for those devices.
Little can be done about the situation. In some cases, programmers have attempted to write hackish drivers based on assumptions about the interface. In other cases, developers work with the company in question and attempt to obtain information about the device interface, with varying degrees of success.
Linux includes a number of laptop-specific features, such as PCMCIA (or "PC Card") support and APM. The PCMCIA Tools package for Linux includes drivers for many PCMCIA devices, including modems, Ethernet cards, and SCSI adaptors; the PCMCIA HOWTO is the document that you need to get started.
Additional content appearing in this section has been removed.
Purchase this book now or read it online at Safari to get the whole thing!
Sources of Linux Information
As you have probably guessed, there are many sources of information about Linux available apart from this book.
If you have access to the Internet, you can get many Linux documents via web and anonymous FTP sites all over the world. If you do not have direct Internet access, these documents may still be available to you; many Linux distributions on CD-ROM contain all the documents mentioned here and are often available off the retail shelf. Also, they are distributed on many other networks, such as Fidonet and CompuServe.
There are a great number of web and FTP archive sites that carry Linux software and related documents. Appendix A contains a listing of some of the Linux documents available via the Internet.
Examples of available online documents are the Linux FAQ, a collection of frequently asked questions about Linux; the Linux HOWTO documents, each describing a specific aspect of the system—including the Installation HOWTO, the Printing HOWTO, and the Ethernet HOWTO; and the Linux META-FAQ, a list of other sources of Linux information on the Internet.
Most of these documents are also posted regularly to one or more Linux-related Usenet newsgroups; see Section 1.10.3 later in this chapter.
The Linux Documentation home page is available to web users at http://www.linuxdoc.org. This page contains many HOWTOs and other documents, as well as pointers to other sites of interest to Linux users, including the Linux Documentation Project manuals (see the following section).
The Bibliography at the end of this book points you to a wealth of sources that will help you use your system. There are a number of published works specifically about Linux. Most noteworthy are the books from the Linux Documentation Project (LDP), a project carried out over the Internet to write and distribute a bona fide set of "manuals" for Linux. These manuals are analogs to the documentation sets available with commercial versions of Unix: they cover everything from installing Linux to using and running the system, programming, networking, kernel development, and more.
Additional content appearing in this section has been removed.
Purchase this book now or read it online at Safari to get the whole thing!
Getting Help
You will undoubtedly require some degree of assistance during your adventures in the Linux world. Even the most wizardly of Unix wizards is occasionally stumped by some quirk or feature of Linux, and it's important to know how and where to find help when you need it.
The primary means of getting help in the Linux world are Internet mailing lists and Usenet newsgroups. If you don't have online access to these sources, you might be able to find comparable Linux discussion forums on other online services, such as on local BBSes, CompuServe, and so on.
A number of businesses provide commercial support for Linux. A "subscription fee" allows you to call consultants for help with your Linux problems. Several vendors provide commercial support. However, if you have access to Usenet and Internet mail, you may find the free support found there just as useful.
Keeping the following suggestions in mind should improve your experiences with Linux and guarantee you more success in finding help to your problems:
Consult all available documentation first.
The first thing to do when encountering a problem is consult the various sources of information listed in the previous section and Appendix A. These documents were laboriously written for people like you—people who need help with the Linux system. Even books written for Unix in general are applicable to Linux, and you should take advantage of them. Impossible as it might seem, more than likely you will find the answer to your problems somewhere in this documentation.
If you have access to the Web, Usenet news, or any of the Linux-related mailing lists, be sure to actually read the information there before posting for help with your problem. Many times, solutions to common problems are not easy to find in documentation and are instead well-covered in the newsgroups and mailing lists devoted to Linux. If you only post to these groups, and don't actually read them, you are asking for trouble.
Additional content appearing in this section has been removed.
Purchase this book now or read it online at Safari to get the whole thing!
Chapter 2: Preparing to Install Linux
This chapter represents your first step in installing Linux. We'll describe how to obtain the Linux software, in the form of one of the various prepackaged distributions, and how to prepare your system. We'll include ways to partition disks so that Linux can coexist with Windows, OS/2, or another operating system.
As we have mentioned, there is no single "official" distribution of the Linux software; there are, in fact, many distributions, each of which serves a particular purpose and set of goals. These distributions are available via anonymous FTP from the Internet, on BBS systems worldwide, and via mail on floppy, tape, and CD-ROM.
Because Linux is free software, no single organization or entity is responsible for releasing and distributing the software. Therefore, anyone is free to put together and distribute the Linux software, as long as the restrictions in the GPL are observed. The upshot of this is that there are many distributions of Linux, available via anonymous FTP or mail order.
You are now faced with the task of deciding on a particular distribution of Linux that suits your needs. Not all distributions are alike. Many of them come with just about all of the software you'd need to run a complete system—and then some. Other Linux distributions are "small" distributions intended for users without copious amounts of disk space. Many distributions contain only the core Linux software, and you are expected to install larger software packages, such as the X Window System, yourself. (In Chapter 5, we'll show you how.)
The Linux Distribution HOWTO contains a list of Linux distributions available via the Internet as well as mail order.
How can you decide among all of these distributions? If you have access to Usenet news, or another computer conferencing system, you might want to ask there for personal opinions from people who have installed Linux. Even better, if you know someone who has installed Linux, ask them for help and advice. In actuality, most of the popular Linux distributions contain roughly the same set of software, so the distribution you select is more or less arbitrary.
Additional content appearing in this section has been removed.
Purchase this book now or read it online at Safari to get the whole thing!
Distributions of Linux
Because Linux is free software, no single organization or entity is responsible for releasing and distributing the software. Therefore, anyone is free to put together and distribute the Linux software, as long as the restrictions in the GPL are observed. The upshot of this is that there are many distributions of Linux, available via anonymous FTP or mail order.
You are now faced with the task of deciding on a particular distribution of Linux that suits your needs. Not all distributions are alike. Many of them come with just about all of the software you'd need to run a complete system—and then some. Other Linux distributions are "small" distributions intended for users without copious amounts of disk space. Many distributions contain only the core Linux software, and you are expected to install larger software packages, such as the X Window System, yourself. (In Chapter 5, we'll show you how.)
The Linux Distribution HOWTO contains a list of Linux distributions available via the Internet as well as mail order.
How can you decide among all of these distributions? If you have access to Usenet news, or another computer conferencing system, you might want to ask there for personal opinions from people who have installed Linux. Even better, if you know someone who has installed Linux, ask them for help and advice. In actuality, most of the popular Linux distributions contain roughly the same set of software, so the distribution you select is more or less arbitrary.
If you don't have Internet or BBS access, you can get many Linux distributions via mail order on floppy, tape, or CD-ROM. Many distributors accept credit cards as well as international orders, so no matter where you live, you should be able to obtain Linux in this way.
Linux is free software, but distributors are allowed by the GPL to charge a fee for it. Therefore, ordering Linux via mail order might cost you between US $5 and US $150, depending on the distribution. However, if you know people who have already purchased or downloaded a release of Linux, you are free to borrow or copy their software for your own use. Linux distributors are not allowed to restrict the license or redistribution of the software in any way. If you are thinking about installing an entire lab of machines with Linux, for example, you need to purchase only a single copy of one of the distributions, which can be used to install all of the machines. There is one exception to this rule, though: in order to add value to their distribution, some vendors include commercial packages that you might not be allowed to install on several machines. If this is the cas, it should be explicitly stated on the package.
Additional content appearing in this section has been removed.
Purchase this book now or read it online at Safari to get the whole thing!
Preparing to Install Linux
After you have obtained a distribution of Linux, you're ready to prepare your system for installation. This takes a certain degree of planning, especially if you're already running other operating systems. In the following sections, we'll describe how to plan for the Linux installation.
While each release of Linux is different, in general the method used to install the software is as follows:
  1. Repartition your hard drive(s). If you have other operating systems already installed, you will need to repartition the drives in order to allocate space for Linux. This is discussed in Section 2.2.4 later in this chapter. In some distributions, this step is integrated into the installation procedure. Check the documentation of your distribution to see whether this is the case. Still, it won't hurt you to follow the steps given here and repartition your hard drive in advance.
  2. Boot the Linux installation media. Each distribution of Linux has some kind of installation media—usually a "boot floppy"—or a bootable CD-ROM that is used to install the software. Booting this media will either present you with some kind of installation program, which will step you through the Linux installation, or allow you to install the software by hand.
  3. Create Linux partitions. After repartitioning to allocate space for Linux, you create Linux partitions on that empty space. This is accomplished with the Linux fdisk program, covered in Section 3.1.3 in Chapter 3 or some other distribution-specific program like the Disk Druid that comes with Red Hat Linux.
  4. Create filesystems and swap space. At this point, you will create one or more filesystems, used to store files, on the newly created partitions. In addition, if you plan to use swap space, you will create the swap space on one of your Linux partitions. This is covered in Section 3.1.4 and Section 3.1.5, both in Chapter 3.
Additional content appearing in this section has been removed.
Purchase this book now or read it online at Safari to get the whole thing!
Chapter 3: Installation and Initial Configuration
At this point, you should have your Linux distribution and have disk space set aside for Linux. In this chapter, we present a general overview of the installation process. Each distribution has its own installation instructions, but armed with the concepts presented here, you should be able to feel your way through any installation. Appendix A lists sources of information for installation instructions and other help, if you're at a total loss.
Different Linux distributions store files in different locations, which can make it hard to describe how to administer Linux. For instance, the same files may be found on Red Hat, SuSE, and Debian systems, but they may be under the /etc directory on one system and the /sbin directory under another. Gradually, the vendors are standardizing the set of locations listed in a document called the Filesystem Hierarchy Standard, but in this book we'll just try to deal with lagging discrepancies by listing the locations of the most important files in the version of each major distribution that we checked.
After resizing your existing partitions to make space for Linux, you are ready to install the software. Here is a brief overview of the procedure:
  1. Boot the Linux installation media.
  2. Run fdisk under Linux to create Linux partitions.
  3. Run mke2fs and mkswap to create Linux filesystems and swap space.
  4. Install the Linux software and configure it.
  5. Finally, either install the LILO boot loader on your hard drive, or create a boot floppy in order to boot your new Linux system.
As we have said, one (or more) of these steps may be automated for you by the installation procedure, depending on the distribution of Linux you are using. Please consult your distribution's documentation for specific instructions.
Additional content appearing in this section has been removed.
Purchase this book now or read it online at Safari to get the whole thing!
Installing the Linux Software
After resizing your existing partitions to make space for Linux, you are ready to install the software. Here is a brief overview of the procedure:
  1. Boot the Linux installation media.
  2. Run fdisk under Linux to create Linux partitions.
  3. Run mke2fs and mkswap to create Linux filesystems and swap space.
  4. Install the Linux software and configure it.
  5. Finally, either install the LILO boot loader on your hard drive, or create a boot floppy in order to boot your new Linux system.
As we have said, one (or more) of these steps may be automated for you by the installation procedure, depending on the distribution of Linux you are using. Please consult your distribution's documentation for specific instructions.
The first step is to boot the Linux installation media. In most cases, this is either a boot floppy, which contains a small Linux system or a bootable CD-ROM. Upon booting the floppy or the CD-ROM, you are presented with an installation menu of some kind that leads you through the steps of installing the software. On other distributions, you are presented with a login prompt when booting this floppy. Here, you usually log in as root or install to begin the installation process.
The documentation that comes with your particular distribution will explain what is necessary to boot Linux from the installation media.
Most distributions of Linux use a boot floppy that allows you to enter hardware parameters at a boot prompt to force hardware detection of various devices. For example, if your SCSI controller is not detected when booting the floppy, you will need to reboot and specify the hardware parameters (such as I/O address and IRQ) at the boot prompt. Likewise, IBM PS/1, ThinkPad, and ValuePoint machines do not store drive geometry in the CMOS, so you must specify it at boot time.
Additional content appearing in this section has been removed.
Purchase this book now or read it online at Safari to get the whole thing!
Post-Installation Procedures
After you have completed installing the Linux software, you should be able to reboot the system, log in as root, and begin exploring the system. (Each distribution has a different method for doing this; follow the instructions given by the distribution.)
Before you strike out on your own, however, there are some tasks you should do now that may save you a lot of grief later. Some of these tasks are trivial if you have the right hardware and Linux distribution; others may involve a little research on your part, and you may decide to postpone them.
In order to start using your system, you need to create a user account for yourself. Eventually, if you plan to have other users on your system, you'll create user accounts for them as well. But before you begin to explore you need at least one account.
Why is this? Every Linux system has several preinstalled accounts, such as root. The root account, however, is intended exclusively for administrative purposes. As root you have all kinds of privileges and can access all files on your system.
However, using root can be dangerous, especially if you're new to Linux. Because there are no restrictions on what root can do, it's all too easy to mistype a command, inadvertently delete files, damage your filesystem, and so on. You should log in as root only when you need to perform system-administration tasks, such as fixing configuration files, installing new software, and so on. See Section 5.1 in Chapter 5 for details.
For normal usage, you should create a standard user account. Unix systems have built-in security that prevents users from deleting other users' files and corrupting important resources, such as system configuration files. As a regular user, you'll be protecting yourself from your own mistakes. This is especially true for users who don't have Unix system-administration experience.
Many Linux distributions provide tools for creating new accounts. These programs are usually called
Additional content appearing in this section has been removed.
Purchase this book now or read it online at Safari to get the whole thing!
Running Into Trouble
Almost everyone runs into some kind of snag or hangup when attempting to install Linux the first time. Most of the time, the problem is caused by a simple misunderstanding. Sometimes, however, it can be something more serious, such as an oversight by one of the developers or a bug.
This section will describe some of the most common installation problems and how to solve them. If your installation appears to be successful, but you received unexpected error messages during the installation, these are described here as well.
When attempting to boot the installation media for the first time, you may encounter a number of problems. Note that the following problems are not related to booting your newly installed Linux system. See Section 3.3.4 for information on these kinds of pitfalls.
Floppy or media error occurs when attempting to boot.
The most popular cause for this kind of problem is a corrupt boot floppy. Either the floppy is physically damaged, in which case you should recreate the disk with a brand new floppy, or the data on the floppy is bad, in which case you should verify that you downloaded and transferred the data to the floppy correctly. In many cases, simply recreating the boot floppy will solve your problems. Retrace your steps and try again.
If you received your boot floppy from a mail-order vendor or some other distributor, instead of downloading and creating it yourself, contact the distributor and ask for a new boot floppy—but only after verifying that this is indeed the problem.
System "hangs" during boot or after booting.
After the installation media boots, you see a number of messages from the kernel itself, indicating which devices were detected and configured. After this, you are usually presented with a login prompt, allowing you to proceed with installation (some distributions instead drop you right into an installation program of some kind). The system may appear to "hang" during several of these steps. Be patient; loading software from floppy is very slow. In many cases, the system has not hung at all, but is merely taking a long time. Verify that there is no drive or system activity for at least several minutes before assuming that system is hung.
Additional content appearing in this section has been removed.
Purchase this book now or read it online at Safari to get the whole thing!
Chapter 4: Basic Unix Commands and Concepts
If you've come to Linux from MS-DOS or another non-Unix operating system, you have a steep learning curve ahead of you. We might as well be candid on this point. Unix is a world all its own.
In this chapter, we're going to introduce the rudiments of Unix for those readers who have never had exposure to this operating system. If you are coming from MS-DOS, Microsoft Windows, or other environments, the information in this chapter will be absolutely vital to you. Unlike other operating systems, Unix is not at all intuitive. Many of the commands have seemingly odd names or syntax, the reasons for which usually date back many years to the early days of this system. And, although many of the commands may appear to be similar to their MS-DOS counterparts, there are important differences.
There are dozens of other books that cover basic Unix usage. You should be able to go to the computer section of any chain bookstore and find at least three or four of them on the shelf. (A few we like are listed in the Bibliography.) However, most of these books cover Unix from the point of view of someone sitting down at a workstation or terminal connected to a large mainframe, not someone who is running their own Unix system on a personal computer.
Also, these books often dwell upon the more mundane aspects of Unix: boring text-manipulation commands, such as awk, tr, and sed, most of which you will never need unless you get into doing some serious Unix trickery. In fact, many Unix books talk about the original ed line editor, which has long been made obsolete by vi and Emacs. Therefore, although many of the Unix books available today contain a great deal of useful information, many of them contain pages upon pages of humdrum material you couldn't probably care less about at this point.
Instead of getting into the dark mesh of text processing, shell syntax, and other issues, in this chapter we strive to cover the basic commands needed to get you up to speed with the system if you're coming from a non-Unix environment. This chapter is far from complete; a real beginner's Unix tutorial would take an entire book. It's our hope that this chapter will give you enough to keep you going in your adventures with Linux, and that you'll invest in one of the aforementioned Unix books once you have a need to do so. We'll give you enough Unix background to make your terminal usable, keep track of jobs, and enter essential commands.
Additional content appearing in this section has been removed.
Purchase this book now or read it online at Safari to get the whole thing!
Logging In
Let's assume that your installation went completely smoothly, and you are facing the following prompt on your screen:
Linux login:
Many Linux users are not so lucky; they have to perform some heavy tinkering when the system is still in a raw state or in single-user mode. But for now, we'll talk about logging into a functioning Linux system.
Logging in, of course, distinguishes one user from another. It lets several people work on the same system at once and makes sure that you are the only person to have access to your files.
You may have installed Linux at home and be thinking right now, "Big deal. No one else shares this system with me, and I'd just as soon not have to log in." But logging in under your personal account also provides a certain degree of protection: your account won't have the ability to destroy or remove important system files. The system administration account (covered in the next chapter) is used for such touchy matters.
[Caution: You can make a mistake in the following paragraph that disables or damages your system or is hard to recover from.]
If you connect your computer to the Internet, even via a modem, make sure you set non-trivial passwords on all of your accounts. Use punctuation and strings that don't represent real words or names.
You were probably asked to set up a login account for yourself when you installed Linux. If you have such an account, type the name you chose at the Linux login: prompt. If you don't have an account yet, type root because that account is certain to exist. Some distributions may also set up an account called install or some other name for fooling around when you first install the system.
After you choose your account, you see:
Password:
and you need to enter the correct password. The terminal turns off the normal echoing of characters you enter for this operation, so that nobody looking at the screen can read your password. If the prompt does not appear, you should add a password to protect yourself from other people's tampering; we'll go into this later.
Additional content appearing in this section has been removed.
Purchase this book now or read it online at Safari to get the whole thing!
Setting a Password
If you don't already have a password, we recommend you set one. Just enter the command passwd. The command will prompt you for a password and then ask you to enter it a second time to make sure you enter it without typos.
There are standard guidelines for choosing passwords so that they're hard for other people to guess. Some systems even check your password and reject any that don't meet the minimal criteria. For instance, it is often said that you should have at least six characters in the password. Furthermore, you should mix uppercase and lowercase characters or include characters other than letters and digits.
To change your password, just enter the passwd command again. It prompts you for your old password (to make sure you're you) and then lets you change it.
Additional content appearing in this section has been removed.
Purchase this book now or read it online at Safari to get the whole thing!
Virtual Consoles
As a multiprocessing system, Linux gives you a number of interesting ways to do several things at once. You can start a long software installation and then switch to reading mail or compiling a program simultaneously. This should be a major part of Linux's appeal to MS-DOS users (although the latest Microsoft Windows has finally come to grips with multiprocessing, too).
Most Linux users, when they want this asynchronous access, will employ the X Window System. But before you get X running, you can do something similar through virtual consoles. This feature appears on a few other versions of Unix, but is not universally available.
To try out virtual consoles, hold down the left Alt key and press one of the function keys, F1 through F8. As you press each function key, you see a totally new screen complete with a login prompt. You can log in to different virtual consoles just as if you were two different people, and you can switch between them to carry out different activities. You can even run a complete X session in each console. The X Window System will use the virtual console 7 by default. So if you start X and then switch to one of the text-based virtual consoles, you can go back again to X by typing Alt-F7. If you discover that the Alt + function key combination brings up an X menu or some other fuction instead of switching virtual consoles, use Ctrl + Alt + function key.
In earlier versions of Linux (until kernel 1.1.54), the number of available virtual consoles was fixed, but could be changed by patching, recompiling and reinstalling the kernel; the default was 8. Nowadays, the Linux kernel creates virtual consoles as needed on the fly. However, this does not mean that you can simply go to virtual console 13 and log in there. You can log in only on virtual consoles where a getty process is running (see the next chapter for more information on this).
Additional content appearing in this section has been removed.
Purchase this book now or read it online at Safari to get the whole thing!
Popular Commands
The number of commands on a typical Unix system is enough to fill a few hundred reference pages. And you can add new commands too. The commands we'll tell you about here are just enough to navigate and to see what you have on the system.
Like MS-DOS, and virtually every modern computer system, Unix files are organized into a hierarchical directory structure. Unix imposes no rules about where files have to be, but conventions have grown up over the years. Thus, on Linux you'll find a directory called /home where each user's files are placed. Each user has a subdirectory under /home. So if your login name is mdw, your personal files are located in /home/mdw. This is called your home directory. You can, of course, create more subdirectories under it.
As you can see, the components of a directory are separated by slashes. The term pathname is often used to refer to this slash-separated list.
What directory is /home in? The directory named / of course. This is called the root directory. We have already mentioned it when setting up file systems.
When you log in, the system puts you in your home directory. To verify this, use the "print working directory" or pwd command:
$ pwd 
/home/mdw
The system confirms that you're in /home/mdw.
You certainly won't have much fun if you have to stay in one directory all the time. Now try using another command, cd, to move to another directory:
$ cd /usr/bin 
$ pwd 
/usr/bin 
$ cd
            
Where are we now? A cd with no arguments returns us to our home directory. By the way, the home directory is often represented by a tilde (~). So the string ~/programs means that programs is located right under your home directory.
While we're thinking about it, let's make a directory called ~/programs. From your home directory, you can enter either:
Additional content appearing in this section has been removed.
Purchase this book now or read it online at Safari to get the whole thing!
Shells
As we said before, logging in to the system puts you into a shell (or a graphical interface if your system is configured to use a display manager). So does opening an xterm window in X. The shell interprets and executes all your commands. Let's look a bit at different shells before we keep going, because they're going to affect some of the material coming up.
If it seems confusing that Unix offers many different shells, just accept it as an effect of evolution. Believe us, you wouldn't want to be stuck using the very first shell developed for Unix, the Bourne shell. While it was a very powerful user interface for its day (the mid-1970s), it lacked a lot of useful features for interactive use—including the ones shown in this section. So other shells have been developed over time, and you can now choose the one that best suits your way of working.
Some of the shells available on Linux are:
bash
Bourne Again shell. The most commonly used (and most powerful) shell on Linux. POSIX-compliant, compatible with Bourne shell, created and distributed by the GNU project (Free Software Foundation). Offers command-line editing, history substitution, and Bourne Shell compatibility.
csh
C shell. Developed at Berkeley. Mostly compatible with the Bourne shell for interactive use, but has a very different interface for programming. Does not offer command-line editing, although it does have a sophisticated alternative called history substitution.
ksh
Korn shell. Perhaps the most popular on Unix systems generally, and the first to introduce modern shell techniques (including some borrowed from the C shell) into the Bourne shell. Compatible with Bourne shell. Offers command-line editing.
Additional content appearing in this section has been removed.
Purchase this book now or read it online at Safari to get the whole thing!
Useful Keys and How to Get Them to Work
When you type a command, pressing the Backspace key should remove the last character. Ctrl-U should delete the whole line. When you have finished entering a command, and it is executing, Ctrl-C should abort it, and Ctrl-Z should suspend it. (When you want to resume the program, enter fg for "foreground.")
If any of these keys fail to work, your terminal is not configured correctly for some reason. You can fix it through the stty command. Use the syntax:
stty function 
            key
         
where function is what you want to do, and key is the key that you press. Specify a control key by putting a circumflex (^) in front of the key.
Here is a set of sample commands to set up the functions described earlier:
$ stty erase ^H 
$ stty kill ^U 
$ stty intr ^C 
$ stty susp ^Z
         
The first control key shown, ^H, represents the ASCII code generated by the Backspace key.
By the way, you can generate a listing of your current terminal settings by entering stty -a. But that doesn't mean you can understand the output: stty is a complicated command with many uses, some of which require a lot of knowledge about terminals.
Additional content appearing in this section has been removed.
Purchase this book now or read it online at Safari to get the whole thing!
Typing Shortcuts
If you've been following along this tutorial at the terminal, you may be tired of typing the same things over and over again. It can be particularly annoying when you make a mistake and have to start over again. Here is where the shell really makes life easier. It doesn't make Unix as simple as a point-and-click interface, but it can help you work really fast in a command environment.
This section discusses command-line editing. The tips here work if your shell is bash, ksh, tcsh, or zsh. Command-line editing treats the last fifty or so lines you typed as a buffer in an editor. You can move around these lines and change them the way you'd edit a document. Every time you press the Return key, the shell executes the current line.
First, let's try something simple that can save you a lot of time. Type the following, without pressing the Return key:
$ cd /usr/inc
            
Now press the Tab key. The shell will add lude to complete the name of the directory /usr/include. Now you can press the Return key, and the command will execute.
The criteria for specifying a filename is "minimal completion." Type just enough characters to distinguish a name from all the other