- 1 -

Introduction to Linux

by Kamran Husain

IN THIS CHAPTER

Welcome to Linux

This book is about Linux, a clone of the UNIX operating system that runs on Intel 80x86-based machines, where x is 3 or higher.

You'll find a CD-ROM at the back of the book that contains the Slackware 96 release of the Linux operating system. With this CD-ROM and this book, you should, I hope, be up and running with a UNIX-like operating system in a few hours.

Linux is also very portable and flexible because it has now been ported to DEC Alpha, PowerPC, and even Macintosh machines. Some of these ports are not complete as this book goes to print, but progress is being made daily by Linux enthusiasts all over the world to make this free operating system available to all the popular computing machines in use today. Because the source code for the entire Linux operating system is freely available, developers can spend time actually porting the code instead of wondering about whom to pay hefty licensing fees.

Documentation for the many parts of Linux is not very far away either. The Linux Documentation Project (LDP) is an effort put together by many dedicated and very smart individuals to provide up-to-date, technically valuable information. All of this LDP information can be found on the Internet at various Linux source repositories. Snapshots of the LDP and other Linux documentation files are also provided on the CD-ROM at the back of this book. Each "HOWTO" document for Linux is the result of effort from many Linux enthusiasts. The original authors of these documents are usually also the core Linux developers who have put in hours of time and effort while struggling with new features of Linux.

These individuals are the ones who deserve the credit and glory for the success of Linux as a viable, powerful operating system. This is the URL for the Linux Documentation Project:

http://sunsite.unc.edu/mdw/linux.html

About This Book

This first chapter will simply acquaint you with some of the features of Linux. This chapter doesn't go into a large amount of detail or cover any advanced topics. Instead, it is intended to give you, a new Linux user, an introduction to what Linux is about, the features you can expect from it, and the sources of information that are available.

Don't be afraid to experiment. The system won't bite you. You can't destroy anything by working on the system. Linux has some amount of security built in to prevent "normal" users (the role you will now assume) from damaging files that are essential to the system.

The worst thing that can happen is that you'll delete all of your files, and you'll have to go back and reinstall the system. So, at this point, you have nothing to lose--except, maybe, your time, which might be very important to you.

One note of caution when reading this chapter: At times I delve into topics that might seem very alien to you, especially if you are new to UNIX and Linux. Don't despair. As we go through this book, you will become more and more familiar with the topics introduced here. Linux is not an easy system to pick up in one day, so don't try to do it. There is no substitute for experience; relax and learn Linux at your own pace.

What This Book Is Not

This book makes several assumptions about you, the reader. I hope that we can safely assume that you have some working knowledge of PCs and Microsoft's Disk Operating System (MS-DOS). (In some Linux documentation, MS-DOS is also referred to as messy-dos, but I'll let you be the judge of that!) If you are not familiar with DOS or computers in general, now would be a good time to pick up a book for beginning with PCs. Still, you should be able to follow this book without needing any extra material.

Most readers of this book will probably be experienced UNIX users. Unfortunately, in the case of readers who are not familiar with UNIX, the ordering of chapters in this book might seem awkward. If you are new to UNIX, refer to the list of other reference books from Sams Publishing, found in Appendix A, "FTP Sites and Newsgroups." We will attempt to cover some of the basics of working with Linux as a user in Part II of this book, "Using Linux." Whatever small amount is left over you can get from these reference books, and from slugging it out with Linux.

One last item before we begin. Even though this book attempts to cover a lot of topics about Linux, we cannot guarantee that it will cover precisely all the topics you are looking for. This book will, however, give you an idea of where to look next, and it will provide you with a good starting point. After a little hand holding, you should be able to work with Linux on your own. Enough said.

Now, let's get started with Linux.

What Is Linux?

Linux is a free UNIX clone that supports a wide range of software such as TeX, X Window Systems, the GNU C/C++ compiler, and TCP/IP. It's a versatile, very UNIX-like implementation of UNIX, freely distributed by the terms of the GNU General Public License. (See Appendix E, "Copyright Information.") Linux is also very closely compliant with the POSIX.1 standard, so porting applications between Linux and UNIX systems is a snap.

New users of UNIX and Linux might be a bit intimidated by the size and apparent complexity of the system before them. Many good books on using UNIX and Linux are available, for all levels of expertise ranging from novice to expert.

Although 95 percent of using Linux is exactly like using other UNIX systems, the most straightforward way to get going on your new system is with a book tailored for Linux. This book will get you started. We could list the 5 percent of differences, but as it's stated in most of my textbooks (which bail out of a hard answer with a similar phrase): "This is so d--n obvious that we have left it as an exercise for the reader."

How to Pronounce Linux

Pronouncing the word Linux is one of the great mysteries of the Linux world. Americans pronounce the name Linux with a long i sound, as in style. Try LIE-nucks. However, because Linux was originally based on a small PC-based implementation of UNIX called Minix (pronounced with a short i), the actual pronunciation of Linux preserves this characteristic: it's LIH-nucks or sometimes even LEEH-nicks.

Linux Versus UNIX

Linux is not a trademark and has no connection to the trademark UNIX. UNIX is a trademark of whomever owned it last.

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, but 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.

UNIX is a multitasking, multiuser operating system. This means that many people can be using one computer at the same time, running many different applications. (This differs from MS-DOS, in which only one person can use the system at a time.)

Under UNIX, for users to identify themselves to the system, they must log in. Logging in entails two steps: entering your login name (the name by which the system identifies you) and entering your password, which is your secret key to logging into your account. Because only you know your password, no one else can log into the system under your user name.

In addition, each UNIX system has a host name assigned to it. It is this host name that gives your machine a name, and gives it character, class, and charm. The host name is used to identify individual machines on a network, but even if your machine isn't networked, it should have a host name. In Chapter 43, "Networking," we'll cover setting your system's host name.

Versions of UNIX exist for many systems, ranging from personal computers to supercomputers. Most versions of UNIX for personal computers are quite expensive and cumbersome. So where does Linux fit in? Well, Linux is free (which solves the expensive part). Linux is free because the programmers who put the code together did so from scratch and did not impose any requirements for payments. With a true altruistic spirit, they put their code in the shareware, public, or GNU's copyleft domains. The authors can get paid for it, and do retain authorship, but they let you use their product without cost. It is also very powerful, and it's easy to install and maintain by an individual (so much for the cumbersome part).

What Do I Get with a Linux System?

Linux is a freely available and distributable look-alike of UNIX developed primarily by Linus Torvalds at the University of Helsinki in Finland. Linux was further developed with the help of many UNIX programmers and wizards across the Internet, giving the ability to develop and change the system to anyone with enough know-how and gumption to hack a custom UNIX kernel.

UNIX and its clones have long been perceived as large, resource-hungry, disk-chomping systems. Linux is not such a beast. Linux is small, fast, and flexible.

Linux has been publicly available since about November 1991. Version 0.10 went out at that time, and version 0.11 followed in December 1991. There are very few small bugs now, and in its current state, Linux is most useful for people who are willing to port and write new code. When Linux was very close to a reliable/stable system, Linus decided that version 0.13 would be known as version 0.95. Believe it or not, the whole story started with two processes that printed AAAA... and BBBB... on a dumb terminal. Linus then expanded on this simple task-switching mechanism and, with the help of many avid supporters, developed and released a stable, working version of Linux.

So, what are some of the important features of Linux that make it unique? Here are a few:

In my opinion, the most important advantage of using Linux is that you get to work with a real kernel. All the kernel source code is available for Linux, and you have the ability to modify it to suit your needs. Looking at the kernel code is an educational experience in itself.

The development of Linux has been so rapid because of the availability of the source code. Also, with an ever-expanding group of hackers who want to get their hands dirty with their own system, Linux has grown steadily into the fully packed operating system that it is today.


NOTE: Linux uses the 386 chip protected-mode functions extensively and is a true 32-bit operating system. Linux simply does not run on an 8086, 8088, or 80286 computer.

So, how reliable is Linux? Surprisingly, Linux is a very stable operating system. I have used Linux on two commercial products and have found Linux to be a far more cost-effective solution than a high-priced workstation. The only real bugs are with alpha drivers (that's why they're alpha). For 99 percent of applications, however, Linux is very robust.

The Downside of Linux

Linux is a hacker's kernel. This hacker attitude can be a daunting experience for someone not familiar with UNIX.

As I stated earlier, the HOWTO documents in the LDP (in the docs directory of the CD-ROM at the back of the book) have loads of tips and answers to frequently asked questions (FAQ). If you are stuck, you can always look at the original files on the CD-ROM. Of course, if booting your machine is a problem, you might have to borrow some other computer to be able to read the CD-ROM.

So, live, human help is generally not available, nor is it a phone call away as with a commercial version of UNIX. You can get help from the Internet newsgroups and other members of the Linux community via e-mail. When it's midnight and your system just won't boot like the README file said it would, however, you do feel a sense of despair. So when using Linux, remember that it is truly a hacker's operating system, developed by and for UNIX hackers.

There is a huge distinction between commercial versions of UNIX and Linux: Commercial versions of UNIX are designed for customers and will work out of the box; Linux is not guaranteed to work at all on your system. You are indeed on your own. Chances are that the Linux version at the back of the book will work on your system, but no one can guarantee this.

If you want a solid guarantee that Linux will work on your system, get a version of Linux from a vendor who will explicitly spell out what systems they have tried Linux on. Of course, this purchase of Linux might cost you a little money (anywhere from U.S. $25 to about U.S. $100). The time spent in trying to debug your hardware setup will be less, however, if you have someone guaranteeing a known setup. If the no-name CD-ROM does not work on your system, you might be better off getting a CD-ROM that does work (by looking at the documentation that comes with Linux or via a vendor). Too often I get mail from readers of previous editions of this book telling about their VGA card or CD-ROM not working, only to find that they do not even know the model and name of the device.

Actually, the only problem for new users is a lack of basic UNIX system administrative knowledge. Setting up and running your own UNIX system is something that most UNIX users never get to do, even after years of experience. Yes, you get to do it yourself, but it isn't that easy. You might actually consider being nice to your local UNIX system administrator after installing Linux for the first time.

Here are some other aspects of Linux you should be warned about:

You develop a knack for fixing problems from experience. Only with experience, however, can you learn to recognize common problems and find or develop solutions.

Even with standard Linux distributions, sometimes little quirks need to be fixed by hand for everything to work correctly. If you have previous UNIX experience, it should be easy to find these problems. If you're new to UNIX, however, it would serve you well to read up on using and running a UNIX system before you dive in.

To reiterate, Linux isn't for everyone. Many users can get in over their heads when starting with Linux. To keep your head above water, I strongly encourage you to read a good book on UNIX system administration, such as UNIX System V, Release 4 Administration, Second Edition (Sams Publishing, 1991).

About Linuxs Copyright

Ah, yes, that old topic of copyrights. Compared to death and taxes, Linux copyrights are a mere annoyance. Linux is not public domain software.

Actually, Linux is copyrighted under the GNU General Public License, sometimes called the GPL or copyleft (instead of right). This copyleft license was developed by the Free Software Foundation to allow programmers to write "free software," with "free" referring to freedom, not just cost. The GPL provides for the protection of such free software in various ways:


NOTE: If you sell the software, you have to be able to provide at no cost the full source code so that others can modify the software and resell it if they so desire. You cannot hold back the source of your modifications.

The original authors of the Linux software may never see a dime of these revenues. This does not prevent authors from getting donations, though, nor does it prevent anyone from charging a fee for the time and effort to make copies for distribution. This is allowed by the GNU GPL because the point of free software isn't to make money. The GNU GPL is simply an understanding between the authors of the software and those who are using, distributing, or sel- ling it.

Another point is that all free software that is covered by the GNU GPL comes with absolutely no warranty. But individual vendors, such as Red Hat, can provide support for the software, which usually includes a warranty. Unless you explicitly purchase such support, however, the assumption is that the software comes with no such warranty. If you use a piece of software that is covered by the GPL, and that software goes haywire and wipes out everything on your system, neither the authors nor those who distributed the software to you are liable for any damage under any circumstances.

An item as covered by the GPL is not shareware, nor is it in the public domain. Neither of these two terms correctly describes what free software really is. The complete GNU GPL is included in Appendix E. To sum it all up, you can freely distribute Linux as much as you like, and you can even modify, copy, sell, and distribute your own version of Linux (and its associated files). But, in doing so, you can't take away any rights of others who want to copy and distribute it further, even if for money. This also applies to the HOWTO documents on the CD-ROM with this book. If you distribute any document, you must do so in its entirety (as it is found on the CD-ROM at the back of the book). The original authors of all Linux software and documentation will always hold copyrights to what they have done.


CAUTION: Note that there are absolutely no warranties with any of the software you get with Linux. If an application goes awry and wipes out your disk, you have no one's neck to wring. Unless someone explicitly gives you a warranty in writing for the software, do not assume any warranty whatsoever.

Hardware Requirements

Now that you know a little about the good and bad points of Linux, let's see what's required in terms of hardware. Keep the following statement in mind:

There are no guarantees that the version of Linux on the CD-ROM at the back of the book, or any free Linux version for that matter, will work with your system.

Due to the popularity of Linux, many hardware vendors can provide support for using their cards with Linux. Ask the manufacturers for help with Linux drivers, and ask whether they support X Window under Linux. "No-name" or generic hardware compatibility in Linux is still limited to the hardware that the developers themselves have access to. For instance, if none of the Linux developers has access to the WhizBang Slice-O-Matic T3222 Ethernet card from a no-name manufacturer, chances are that it isn't supported. Few Linux developers are motivated to support hardware that is not common.

Unlike some other versions of UNIX for the PC, Linux is very small. You can run an entire system from a single high-density 5[dieresis]-inch floppy. To run a complete Linux system, however, there are other hardware requirements. For example, you need device drivers to be able to use certain types of devices under Linux. Fortunately, there are many generic drivers for the IDE disk driver for Linux. These generic drivers should work with all IDE hard drives and adapters. Most internal tape drives are supported, but external tape drives that run off the parallel printer port are generally not supported.

A good place to look on the CD-ROM is in the /docs directory for the Hardware-HOWTO file. This file lists many of the supported hardware devices for Linux.

If your favorite peripheral isn't supported by Linux, all that's required is to write a kernel driver for it. This might be easy or difficult, depending on the hardware and the technical specifications that are available. For example, some hardware developers prefer to write their own drivers for MS-DOS and Windows, and not release specifications for third parties to write their own. Therefore, writing drivers for Linux can be difficult, if not impossible.

If after trying four or five different kernels, your CD-ROM, Ethernet card, or sound card does not work, look in the Hardware-HOWTO file to see whether your hardware is even supported. If your hardware is not listed, it might not be supported. Easiest solution: Get new hardware that is supported. Search the Internet for drivers. Do not try to jury-rig whatever software comes with the CD-ROM unless you know UNIX well enough to write your own drivers. For example, if your Phillips CD-ROM drive is not supported (it probably isn't), get another CD-ROM drive from the list in the Hardware-HOWTO. It's bound to save you time and prevent frustration in the future.

The best approach, in the case of incompatibility, is to stay with the most commonly used hardware and hope for the best. Chances are greater for your system to work with Linux. Plus, you will find yourself with more time to play with Linux!

The following bulleted list is a rough guideline of some hardware requirements for Linux. You do not have to follow the guidelines exactly, but this list should give you a general idea of what is required.


TIP: If you're in the market for a new system, you should heed the following recommendations.
If you don't have a math coprocessor, the Linux kernel emulates floating-point math for you. If you do have one, however, floating-point math is handled by the hardware, which is a real plus in speed for some applications.
The 386SX, the 486SX, the accelerated 486DX and 486DX2, and other clone chips are all reported to work without any problems.

NOTE: MicroChannel architecture (MCA) machines, such as the IBM PS/2 line, are still not supported.
Memory is speed, so if you have more physical RAM, you'll thank yourself for it later. If you're a "power user," 8MB should be more than enough for most applications. More than 8MB of RAM definitely speeds up some applications. In fact, if you want to use X Window with any hope of getting some work done, install at least 8MB of RAM.

NOTE: Linux uses the first 640KB for kernel text, data, and buffer caches. Your motherboard might also use up an additional 384KB because of the chip set. While Linux is running, it uses up memory for processes such as init/login, a shell, and possibly other background processes. Compiling programs takes up more memory in the system. Such requests for extra memory are satisfied by paging from a swap file on disk. A disk is much slower than memory. So if you don't have enough real memory, you have to resort to paging contents of memory to and from disk.

Disk Space Requirements

You need a hard drive with adequate space available for installing Linux. The amount of space required depends on the amount of software you're installing and how much free space you want to leave yourself to store your own data and programs.

If you install only a small amount of software, about 10MB is required. If, however, you install some optional software packages, including the X Window System, perhaps 100MB or more (including space for users) is required.

In addition, you probably want to set aside some amount of space on your drive as a swap partition, used for virtual memory.

In general, you should look for about 100MB of disk space for your use, and an additional 16MB or so of disk space for a swap space. The swap space is an area on the disk that is a repository in which Linux can store images of running programs when memory is tight. Usually, the amount of swap space is twice that of physical memory in the system. For example, if you have a 16MB system, you will probably want to have 32MB of swap space on your system. Again, having twice the size is a rule of thumb, nothing more.

Linux supports almost all hard drive/controller combinations that are register-compatible with a Western Digital WD1003 MFM disk controller. This controller was the original and most common PC-AT disk controller. Most AT MFM, RLL, ESDI, and IDE setups look like this. IDE and MFM drives seem to work with no problem. Linux also works for some ESDI drives, and for almost all SCSI devices, with no problems. As before, the Hardware-HOWTO file lists the latest compatible hardware. The Hardware-HOWTO file is located in the docs directory on the CD-ROM at the back of this book.

Generally, the rule is this: If you have the disk configured into the CMOS setup of your machine, it will work, because if your computer's BIOS is communicating with a WD 1003- compatible board, Linux will too.


CAUTION: During testing with Linux, I have found that mixing two different types of SIMMs (70ns and 100ns) caused the PC to behave very strangely, with crashes during the installation process. The solution was to use the same speed memory. These SIMMs were the 9-, not the 3-, chip version. Generally speaking, it's never a good idea to mix RAM chips of different speeds on a single motherboard.

You need a Hercules, CGA, EGA, VGA, or Super VGA video card and monitor. In general, if your video card and monitor work under MS-DOS or Microsoft Windows, Linux should be able to use them without any problem. If you're going to use the X Window System, however, certain hardware configurations are not yet supported. The list of such requirements can be found in the /docs/XFree86-HOWTO file on the CD-ROM.

Other Hardware Requirements

Linux also runs on various laptop machines. (Some laptops use certain software interrupts to power the memory, and Linux doesn't work well with these systems to date.) The best way to find out whether Linux will run on your hardware is to just try it. You can find a home page dedicated to this endeavor at

http://www.cs.utexas.edu/users/kharker/linux-laptop/

Other hardware drivers currently are under development for Linux. To use these drivers, however, you usually have to patch them into your kernel code, which assumes that you already have a running Linux system. A kind of chicken-and-egg problem if you haven't already installed Linux, isn't it? In such cases, you can install whatever Linux you happen to have, and then apply the patches with the Linux patch command.

The issue of tape drives for Linux also needs to be considered. There is a working QIC-02 device driver for Linux, supporting Everex/Wangtek cards. There are additional patches for the QIC-02 to support Archive SC402/499R. You can find them in the /pub/linux/alpha/qic-02 directory at the tsx-11.mit.edu FTP server. (Reports have been made of some bugs in the driver, but you can back up and restore.) In general, if a tape drive works under Windows or MS-DOS given a QC-102 specification, it will work with Linux.

Most of the newer tape drivers are for SCSI drives, so if you have a SCSI tape drive, chances are good that it is supported.

Special Requirements for X Window Systems

Your 4MB of RAM will make X run very slowly. You should have at least 8MB of RAM for running and compiling programs in X. You need another 6MB to 10MB of disk space for the GCC compiler, in addition to the X Window System.

Another important point with running X is the support for both color and monochrome Hercules and VGA cards. Most chip sets, such as et3000, et4000, GVGA, PVGA1, WD890c00, TRIDENT, CIRRUS, NCR, and COMPAQ, are supported. You can almost always run X on a monochrome VGA card.

As far as mice go, Linux supports both serial and bus varieties. For the serial mice, you can use Logitech, Microsoft, MouseSystems, or compatibles. For bus mice, Logitech, Microsoft, ATI_XL, and PS/2 are known to work.


NOTE: If you are unsure whether you have a bus mouse, check to see whether your mouse card has a selection for a sample rate switchable between 30Hz and 60Hz (or possibly 25/50Hz). If it does not, it's not a true bus mouse. Check the HOWTO for XFree86 for details on mice.

Before You Get Started

Assuming that you have hardware that's compatible with Linux, obtaining and installing the system is not difficult. But be prepared to be a bit frustrated if you are new to UNIX or Linux.

These are the two best defenses against frustration with using Linux:


TIP: Experience with my bad memory has forced me to keep an indexed log of all the bugs, quirks, and symptoms in Linux. I have a dog-eared notebook of all the weird features of Linux. As you work with Linux, you might want to keep a personal log of your misadventures with it.

The CD-ROM

The CD-ROM enclosed in this book has lots of useful documentation. Unfortunately, this is the classic chicken-and-egg problem. You need the documentation to install the Linux software, but you have to access the CD-ROM to get more information about how to install the software! The good part is that almost all the documentation on the CD-ROM at the back of this book is in plain text.

Right now, in this chapter, it's much too early to worry about reading the contents of the CD-ROM. The next two chapters will step you through the installation process. So don't worry if you do not yet know how to look for this documentation.


NOTE: If you are eager to get this information, you can borrow a DOS machine or UNIX workstation and look at the /doc directories from the root of the CD-ROM.

TIP: You can look at all the files and directories on the CD-ROM from an MS-DOS, UNIX, or Microsoft Windows machine.

In Chapter 2 we will cover some of the files you can look at in the CD-ROM after you have installed Linux. You can skip ahead to that chapter to see how to read the CD-ROM directory tree for the documentation.


NOTE: See Chapter 15, "Using the Linux Documentation," to find out where to get more information about Linux.

Summary

There you have it, a brief introduction to an operating system that could very well change the way you program. Now, it's time to get yourself ready for Linux.

In this chapter, you learned about Linux and some of its more prominent features. Here's a recap: