Donation?

Harley Hahn
Home Page

Send a Message
to Harley


A Personal Note
from Harley Hahn

Unix Book
Home Page

SEARCH

List of Chapters

Table of Contents

List of Figures

Chapters...
   1   2   3
   4   5   6
   7   8   9
  10  11  12
  13  14  15
  16  17  18
  19  20  21
  22  23  24
  25  26

Glossary

Appendixes...
  A  B  C
  D  E  F
  G  H

Command
Summary...

• Alphabetical
• By category

Unix-Linux
Timeline

Internet
Resources

Errors and
Corrections

Endorsements


INSTRUCTOR
AND STUDENT
MATERIAL...

Home Page
& Overview

Exercises
& Answers

The Unix Model
Curriculum &
Course Outlines

PowerPoint Files
for Teachers

Chapter 2...

What Is Unix? What Is Linux?

What is Unix and what is Linux? The short answer is Unix is a type of computer system, and Linux is the name of a particular family of Unix systems.

That answer should be good enough if your grandmother happens to ask "What is all this Unix stuff you are learning?" For practical purposes, however, you need to know more.

In this chapter, I'm going to explain the most important ideas that underlie Unix in general and Linux in particular, and I'm going to do it for two reasons. First, I think you will find the discussion interesting. To me, Unix is the most wonderful computer system ever invented, and I'd like you to share that feeling.

Second, once you have a basic understanding of Unix, you'll have a context for what I will be teaching in this book. In that way, when we get into the heavy-duty technical stuff, you'll find it a lot easier to remember the details.

By the end of the chapter, I will have given you a good, serviceable definition of both Unix and Linux. However, before I can do that, I'm going to have to explain a number of important concepts. To lay the groundwork, I'm going to start with a discussion of the fundamental component of any computer system: the operating system.

Jump to top of page

What Is an Operating System?

Computers perform tasks automatically by following instructions. A list of instructions is called a PROGRAM. As the computer follows the instructions, we say that it RUNS or EXECUTES the program. In general, programs are referred to as SOFTWARE, while the physical components of the computer are referred to as HARDWARE. The hardware includes the system board, disk drives, keyboard, mouse, display, screen, printers, and so on.

An OPERATING SYSTEM (which is software) is the complex master control program that runs the computer. The principal function of an operating system is to make efficient use of the hardware. To do so, the operating system acts as the primary interface to the hardware, both for you as you are working, and for your programs as they are executing.

Whenever your computer is up and running, the operating system is there, waiting to serve you and to manage the resources of your computer.

For example, say you type a command to display the names of your files. It is the operating system that handles the details of finding the names and displaying them on your screen. When you are running a program that needs to open a new file, it is the operating system that sets aside the storage space and handles all the details.

More precisely, the most important functions of an operating system are to:

• Take control of the computer and initialize itself each time the machine starts or restarts. This initialization is part of the BOOTING process.

• Support the interface (text or graphical) that you use to interact with the computer.

• Provide an interface for programs as they need to use the computer's resources (disk space, file allocation, processing time, memory, and so on).

• Manage the computer's memory.

• Maintain and manage a file system.

• Schedule work to be done.

• Provide accounting and security services.

In addition, all operating systems are packaged with a large variety of programs for you to use. For example, there are programs to help you create, modify and manage files; to manage your work environment; to communicate with other people; to use the Internet; to write programs; and on and on. Unix comes with more than a thousand such programs, each of which is a tool to perform one specific job.

As a family, Unix operating systems all share two important characteristics: they are multitasking and multiuser. MULTITASKING means that a Unix system can run more than one program at a time. MULTIUSER means that Unix can support more than one user at a time. (Microsoft Windows, by the way, is a multitasking, single-user operating system.)

What's in a Name?

Booting


The term "booting" is short for bootstrapping, which refers to the old saying "pulling yourself up by the bootstraps". For example, "After Bartholomew lost all his money, he was poor for a long time. However, by working hard, he was able to pull himself up by the bootstraps and become a successful groatcakes merchant."

Obviously, it is physically impossible to pull yourself up by straps that are attached to your own boots. The idea is that a difficult, complex goal can often be accomplished by starting with one small action and then, using that as a foundation, building one step at a time until the desired goal is reached.

A computer system starts in just this way. When you turn on the power (or restart the computer) a single, small program is run automatically. That program starts another, more elaborate program, and so on. Eventually, the operating system (a very complex program) takes control and finishes the initialization.

Thus, we refer to the entire process as bootstrapping, or booting the computer.

Jump to top of page

What Is the Kernel?

When a computer is started, it goes through a sequence of actions that comprise the booting process. The final act in this process is to start a very complex program called the KERNEL.

The job of the kernel is to take control of the computer and to act as the core of the operating system. As such, the kernel is always running. Indeed, it does not stop until you shut down the system. In this way, the kernel is constantly available to provide essential services as they are needed.

The kernel, being the heart of the operating system, is very important, so I want to take a moment to tell you a few details. I'm going to get a bit technical, so if you are at all confused, just nod your head wisely and pretend you understand.

Although the nature of a kernel can vary from one operating system to another, the essential services it provides are pretty much the same from one system to another. They are:

• Memory management (virtual memory management, including paging)

• Process management (process creation, termination, scheduling)

• Interprocess communication (local, network)

• Input/output (via DEVICE DRIVERS, programs that perform the actual communications with physical devices)

• File management

• Security and access control

• Network access (such as TCP/IP)

If these technical terms mean something to you, fine. If not, don't worry about it. Only the most nerd-like programmers actually care about the internal details of a kernel. For people like you and me, the crucial thing is to appreciate that the kernel is the most important part of the operating system. In fact, as we will see later, the main difference between Linux and other types of Unix is that Linux uses a particular kernel that is different from other Unix kernels.

There are a variety of different types of kernels, but basically they can be divided into large ones called MONOLITHIC KERNELS and small ones called MICROKERNELS.

A monolithic kernel consists of one very large program that does everything by itself. A microkernel is a much smaller program that can carry out only the most basic tasks. To perform the rest of its functions, a microkernel calls upon a set of other programs called SERVERS.

The advantage of a monolithic kernel is that it is fast: everything is done within a single program, which is efficient. The disadvantage is that monolithic kernels are large and unwieldy, which makes them difficult to design and maintain.

A microkernel is slower, because it must call upon servers to do most of its work, which is less efficient. However, because of the modular design, microkernels are a lot easier for programmers to understand, and they can be modified to work on new systems relatively quickly. Microkernels also have the advantage in that they are easier to customize than are monolithic kernels.

For example, say you are creating an operating system for a mobile phone or a robot. Storage space is at a premium, so a small kernel is better than a large one. Moreover, with a special purpose device, you may not need all the functionality of a monolithic kernel. In this case, a microkernel with a carefully selected set of servers may be the best bet.

When a new operating system is being created, the designers have a choice. They can use either a single large monolithic kernel, or a small minimal microkernel with servers. Most Unix systems use some type of monolithic kernel. However, as we will see, some Unixes, such as the Macintosh Unix (called OS X), use a microkernel.

What's in a Name?

Kernel


Imagine a pistachio nut. The outside is a hard shell. The inside is a soft, edible seed which, in biology, is called the kernel. Thus, if we want to be precise, we can say that, when we eat pistachio nuts, we crack open the shell in order to eat the kernel.

If we think of Unix as a nut, the inside would be the kernel, and the outside would be the shell; and indeed, that is the case.

The kernel, which we just discussed, is what we call the core of the operating system. The SHELL (which we will discuss in Chapter 11) is the name we give to a special type of program (a command processor) that "surrounds" the kernel and acts as our personal interface into the system.

Jump to top of page

Unix = Kernel + Utilities

I have explained that the kernel is the central part of the operating system. The kernel is always running, and its job is to perform the essential tasks.

But what about everything else?

With Unix, "everything else" consists of a large number of auxiliary programs that are included as part of the Unix package. These programs fall into a number of different categories.

The most important programs are the ones that provide an interface for you to use the computer. They are the shells and GUIs. A shell is a program that provides a text-based interface: you type commands, one after another; the shell reads your commands and does what is necessary to carry them out. A GUI (graphical user interface) is a more elaborate program, which provides a graphical interface with windows, a mouse pointer, icons, and so on. We will talk about shells and GUIs in Chapters 5 and 6, and shells in detail in Chapter 11 so, for now, all I will do is mention that they exist.

The other programs are called the Unix UTILITIES, of which there are hundreds. Each utility (that is, each program) is a separate tool. All Unix systems come with hundreds of such tools as part of the operating system. Some of these are for programmers, but many of them are useful to anyone, even casual users. Moreover, as we will discuss in Chapter 15, Unix provides ways to combine existing tools to solve new problems as they arise. This wealth of tools, which is part of every Unix system, is the main reason why Unix is so powerful.

Unix utilities work pretty much the same on every Unix system. This means that, for practical purposes, if you know how to use one type of Unix, you know how to use them all. Indeed, most of this book is devoted to teaching you how to use the most important Unix utilities. My goal is that, by the time you have finished this book, you will be familiar with the most important tools, which means you will feel comfortable using Unix on a day-by-day basis.

So, what is Unix?

A good answer would be that Unix is a type of operating system that uses a Unix kernel and comes with the Unix utilities and a Unix shell. In fact, most (but not all) Unixes come with a selection of shells and at least one GUI.

In informal speech, we often use the term "utilities" to include the shell, so at this point, we can define Unix as follows:

Unix = a Unix kernel + the Unix utilities

Jump to top of page

"Unix" Used to Be a Specific Name

In Chapter 1, I described how the first primitive Unix system was developed in 1969 by a single programmer, Ken Thompson. The work was done at Bell Labs, the research arm of AT&T. Since then, a large number of people have developed Unix into a modern family of operating systems. But who owns the actual name "Unix"?

For years, it was owned by AT&T, which insisted that Unix must always be spelled with capital letters: UNIX. More precisely, the AT&T lawyers specified that "The trademark UNIX must always appear in a form that is typographically distinct."

In addition, the lawyers decreed that you could not talk about UNIX in its own right. You had to talk about UNIX operating systems. ("The trademark UNIX may not be used as a noun, but must always be used as an adjective modifying a common noun as in 'UNIX operating system.'")

For many years, Bell Labs remained one of the centers of Unix development, and the silliness continued. In 1990, AT&T formed a new organization, called Unix Systems Laboratory (USL) to take over Unix. In June 1993, AT&T sold USL to Novell Corporation. In October 1993, Novell transferred the rights to the name "UNIX" to an international standards organization called X/Open. Finally, in 1996, X/Open merged with the Open Software Foundation (a consortium of computer companies) to form The Open Group. Thus, the UNIX trademark is now owned by The Open Group.

So what does The Open Group say that UNIX means? They say that "UNIX" is a brand that refers to any operating system that has been certified by them as complying with their so-called "Single UNIX Specification".

The details are horrible, so let's move on.

Jump to top of page

"Unix" is Now a Generic Name

The desires of The Open Group (and AT&T and USL and Novell and X/Open) notwithstanding, the word "Unix" has, for years, been used informally to refer to any operating system that is Unix-like. In this sense, there are many, many different types of Unix, with more being developed every year.

However, all of this begs the question, what does it mean to be Unix-like?

There are two answers, neither of which is exact. The first answer is that an operating system is Unix if (1) it consists of a Unix kernel and the Unix utilities and, (2) it can run Unix programs that run on other Unix systems.

The second answer is that an operating system is Unix if people who understand Unix say that it is Unix.

I realize that to a purist — such as Socrates or an Orthodox Rabbi — such an informal definition is not satisfying. However, in the real world (the place we live when we are not in school), it is not always possible to be completely precise.

Consider, for example, the United States Supreme Court case of Jacobellis v. Ohio, 378 U.S. 184 (1964). This case involved an appeal by the manager of a movie theater who was convicted of showing an obscene film. In the official written judgment, Mr. Justice Potter Stewart discusses the question of obscenity. What, in fact, is it?

He writes, "I shall not today attempt further to define the kinds of [hard-core pornography] material I understand to be embraced within that shorthand description; and perhaps I could never succeed in intelligibly doing so. But I know it when I see it, and the motion picture involved in this case is not that."

So, I know I am in good company if I tell you the truth: If you want to get really technical, I can't tell you what Unix is — perhaps no one can — but I know it when I see it. (And, one day, you will too.)

Jump to top of page

The Free Software Foundation

Now that you know what Unix is, I'd like to answer the next question: What is Linux? To do so, I need to start by talking about the Free Software Foundation and the idea of open source software.

Imagine you enjoy this book so much that you would like all your friends to have a copy. How could you do so? You could buy a whole set of books and give them out to your friends (which isn't a bad idea, especially if you are trying to impress everyone you know). Of course, that would cost a lot of money. However, each person would receive an actual printed book, and at least you would feel you were getting something for your money.

Alternatively, you could make copies of the book. For example, you could photocopy, say, 30 copies of the book and give away the copies. This would save you some money but, compared to the original, the copies would be far from perfect. Moreover, it would take a lot of time and effort to photocopy, collate, bind and distribute the copies, and when your friends received them, they would know they were getting an inferior product. Even worse, if a friend wanted to make copies of his own, the quality would be worse because a photocopy of a photocopy is not nearly as good as the original.

Now, suppose you were reading an electronic version of this book, and you wanted to share the book with your friends. All you would have to do is copy some files and email them to your friends or burn them onto a CD and give it away. Not only would it be cheap to do so (maybe even free), but the copies would be identical to the original. Furthermore, your friends could easily make copies of the copies.

To be sure, it would be illegal to make such copies, but forget legal for a moment. Morally, is it right or wrong to copy and distribute electronic data (books, software, music, videos, and so on)?

There is no easy answer here. It all depends on your point of view, and there are good arguments on each side. One thing I can tell you: because electronic copying is so cheap and reliable, we tend to devalue anything that is in electronic format. For example, think of what you paid for this book. Would you feel comfortable paying the same amount of money for a CD that contained the book? Or for access to a Web site where you could read the book online?

Because it is so easy to copy (or steal) electronic data, people tend to feel that electronic data isn't worth much. For this reason, software companies have traditionally been wary about releasing programs without strict license agreements that prohibit copying and modification.

However, what if you could convince a lot of talented programmers to distribute their software in such a way that it encouraged copying? Would it change the world for the better? In the early 1980s, a visionary named Richard Stallman asked himself that question.

Stallman had been working in the MIT Artificial Intelligence (AI) Lab since 1971. The AI Lab had a long history of sharing software with anyone, not only inside the lab, but in other organizations. In 1981, however, conditions changed, and many of the AI Lab people left to join a startup company. The main computer was changed and the operating system was replaced with a proprietary system. Stallman now found himself working in an environment in which he and his coworkers had lost the right to look inside the operating system and modify it.

It happened that Stallman was more than an expert programmer. He was also a thoughtful social critic, who saw the change to a proprietary operating system as a restriction on his social rights as a creator. In his words, a "proprietary-software social system, in which you are not allowed to share or change software", was not only "antisocial", it was "unethical" and "wrong". Such systems, he observed, create unhealthy power struggles between programmers and software companies.

The solution was to create a large body of well-written, useful software that, from the beginning, was designed to be freely distributed.

In January 1984, Stallman quit his job to devote himself to the project. Within a short time, he had attracted a small number of other programmers and, in 1985, they started an organization called the FREE SOFTWARE FOUNDATION or FSF. Stallman's guiding principle was "Computer users should be free to modify programs to fit their needs, and free to share software, because helping other people is the basis of society." Stallman believed that programmers, by their nature, like to share their work and, when they do, everyone benefits.

It is important to understand that when Stallman talked about "free software", he was not referring to cost; he was referring to freedom. FREE SOFTWARE can be examined, modified, shared and distributed by anyone. However, according to Stallman, it is fine if someone charges for their services or makes other people pay for software distribution. The way Stallman explained it is to think in terms of "free speech, not free beer".

Since the word "free" can refer to both freedom and cost, there is some ambiguity. So, to avoid any possible confusion, free software is now called OPEN SOURCE SOFTWARE.

(The name comes from a programming term. When a programmer creates a program, the actual instructions he writes are called the SOURCE CODE or, more simply, the SOURCE or the CODE.

(For example, let's say that you are talking to the Queen of England, and she is complaining that the program she uses to rip music from CDs keeps crashing. "If I only had the code", she says, "I could get Charles to fix the bug." "Don't worry," you answer. "I know where to get the source. I'll email Chuck the URL.")

Since the heart of any computer is the operating system, Stallman's first major goal for the FSF was to create an operating system that could be shared freely and modified by anyone. In order for the new operating system to be freely distributable, Stallman realized that it would have to be written from scratch.

Stallman wanted the FSF's products to fit smoothly into the prevailing programming culture, so he decided that the new operating system should be compatible with Unix in the sense that it should look just like Unix and should be able to run Unix programs. In the tradition of the programming community in which he worked, Stallman chose a whimsical name for the as-yet unbuilt operating system. He called it GNU.

What's in a Name?

GNU


GNU is the name Richard Stallman chose to describe the Free Software Foundation's project to develop a full Unix-like operating system. The name itself is an acronym meaning "GNU's Not Unix" and is pronounced "ga-new". (It rhymes with the sound that you make when you sneeze.)

Notice that, within the expression "GNU's Not Unix", the word GNU can be expanded indefinitely:

    GNU
   (GNU's Not Unix)
  ((GNU's Not Unix) Not Unix)
 (((GNU's Not Unix) Not Unix) Not Unix)
((((GNU's Not Unix) Not Unix) Not Unix) Not Unix)

and so on. Thus, GNU is actually a recursive acronym. (RECURSIVE refers to something that is defined in terms of itself.)

Jump to top of page

Excerpts from the GNU Manifesto

As I mentioned in the last section, Richard Stallman, the founder of the Free Software Foundation, was more than a programmer. He was an educated social critic, and his vision of the future was to have an enormous impact on the world.

Shortly after founding the FSF, Stallman wrote a short essay in which he explained his reasons for promoting the idea of free software. He called the essay the GNU MANIFESTO.

His basic idea — that all software should be shared freely — is, at best, naive. However, with the rise of the Internet, the development and distribution of open source software (what Stallman called "free software") has become an important economic and social force in our world. There are literally tens of thousands of programs available for free, and their contribution to the world at large (and to the happiness of their programmers) is beyond measure.

We will discuss this idea more in the next section. Before we do, I'd like to take a moment to show you a few passages from the original 1985 essay.

As a philosopher, Stallman was not a heavyweight. His public declaration was not as sophisticated as other well-known manifestos, such as 95 Theses (Martin Luther, 1517), Manifesto of the Communist Party (Karl Marx and Frederick Engels, 1848), or The Playboy Philosophy (Hugh Hefner, 1962-1966). Still, the work of the Free Software Foundation was very important and, to this day, it continues to make an important contribution to our culture. For this reason, you may be interested in reading a few excerpts from Stallman's 1985 essay.

(Quick aside: When Stallman was working at MIT, he created the Emacs text editor. If you have access to a GNU version of Emacs, which is the case if you use Linux, you can display information about the GNU Project by starting Emacs and entering the command <Ctrl-H> <Ctrl-P>.)

Excerpts from the GNU Manifesto

"I consider that the golden rule requires that if I like a program I must share it with other people who like it. Software sellers want to divide the users and conquer them, making each user agree not to share with others. I refuse to break solidarity with other users in this way. I cannot in good conscience sign a nondisclosure agreement or a software license agreement. For years I worked within the [MIT] Artificial Intelligence Lab to resist such tendencies and other inhospitalities, but eventually they had gone too far: I could not remain in an institution where such things are done for me against my will.

"So that I can continue to use computers without dishonor, I have decided to put together a sufficient body of free software so that I will be able to get along without any software that is not free. I have resigned from the AI lab to deny MIT any legal excuse to prevent me from giving GNU away...

"Many programmers are unhappy about the commercialization of system software. It may enable them to make more money, but it requires them to feel in conflict with other programmers in general rather than feel as comrades. The fundamental act of friendship among programmers is the sharing of programs; marketing arrangements now typically used essentially forbid programmers to treat others as friends. The purchaser of software must choose between friendship and obeying the law. Naturally, many decide that friendship is more important. But those who believe in law often do not feel at ease with either choice. They become cynical and think that programming is just a way of making money...

"Copying all or parts of a program is as natural to a programmer as breathing, and as productive. It ought to be as free...

"In the long run, making programs free is a step toward the post-scarcity world, where nobody will have to work very hard just to make a living. People will be free to devote themselves to activities that are fun, such as programming, after spending the necessary ten hours a week on required tasks such as legislation, family counseling, robot repair and asteroid prospecting. There will be no need to be able to make a living from programming..."

Jump to top of page

The GPL and Open Source Software

Over the years, Stallman and the many other programmers who supported the Free Software Foundation worked hard to create a huge body of open source software. In fact, as I mentioned, Stallman was the original author of the Emacs text editor.

Today, the FSF is not the only organization to promote open source software; indeed, there are many. However, the FSF has always been one of the leaders, not only with Emacs, but with a C compiler (gcc), a C++ compiler (g++), a powerful debugger (gdb), a Unix shell (Bash), and many, many other tools. All of this software — which is part of the GNU project — is used around the world and is considered to be of the highest quality.

In the late 1980s, Stallman had some experiences that showed him if he was going to create a large body of free software, he was going to need an appropriate license under which he could distribute that software. For this purpose, he invented the idea of the COPYLEFT. (The name came from a friend of Stallman's who, in the mid-1980s, sent Stallman a letter in which several witty sayings were written on the envelope. Among these was "Copyleft — all rights reversed.")

Within the software community, traditional copyrights were used to restrict the use of the software. The purpose of the copyleft was to do the opposite. In Stallman's words, "The central idea of copyleft is that we give everyone permission to run the program, copy the program, modify the program, and distribute modified versions — but not permission to add restrictions of their own."

To implement the idea of copyleft, Stallman wrote the GENERAL PUBLIC LICENSE or GPL, which he released in 1989. The GPL itself is rather complicated, so I won't go into the details. Basically, when applied to software, the GPL says that anyone may distribute the software, view the source code, modify it, and distribute the changes. Furthermore — and this is the crucial part — no one who redistributes the software, including modified versions, can take away any of the freedoms or add any restrictions of his own.

The GPL ensures that, whenever anyone uses free software to create a new product, the new product cannot be distributed except under the GPL. In practical terms, this means that if someone starts with free software, changes it, and redistributes it, he must also release the source code.

The GPL became popular and, over the years, a variety of similar licenses have been developed. Indeed, the combination of copyleft licenses and the Internet (allowing programmers around the world to share and to work together) has led to an enormous flourishing of shared creativity, the so-called OPEN SOURCE MOVEMENT.

The open source movement is so important that it would be difficult to overstate its impact within the world of programming and on the world at large. By way of illustration, if all open source software were to vanish, the Internet as we know it would disappear in an instant. (For example, most of the Web servers in the world are run by an open source program called Apache.)

In the world of Unix, the effects of the open source movement have been momentous. There are many reasons for this, not least of which is that if it hadn't have been for the FSF and the GPL, and the changes they made in the programming culture, you and I probably would never have heard of Linux.

Jump to top of page

Unix in the 1970s:
From Bell Labs to Berkeley

At the beginning of Chapter 1, I explained that the first version of Unix was developed at AT&T's Bell Labs, in New Jersey, in 1969. In the early 1970s, Unix was rewritten and enhanced by a handful of people, all from Bell Labs.

In 1973, a Unix development support group was formed and, later that year, Ken Thompson (one of the two principal Unix developers) delivered the very first paper on Unix at a conference of computer professionals. This sparked an interest in Unix, and within six months, the number of sites running Unix increased from 16 to 48.

In July 1974, Thompson and Dennis Ritchie (the other principal Unix developer) published a paper, "The UNIX Time-Sharing System", in Communications of the ACM(*), the most widely read computer science journal in the world. It was the first time that Unix was described to the world at large, and the world at large began to respond. Academics at universities and researchers inside companies requested copies of Unix and began running it on their own computers. In some cases, they PORTED Unix (that is, they adapted it) to run on new types of hardware.

* Footnote

One month later, in August 1974, the same journal published my first technical paper. At the time, I was an undergraduate student at the University of Waterloo, in Canada, and I had won the ACM's George E. Forsythe Student Paper Competition. The name of the paper was "A New Technique for Compression and Storage of Data".

(In case you are wondering, the ACM is the principal professional association for computer scientists. The name, which dates back to 1947, stands for Association for Computing Machinery.)

Here is something interesting. If you check out the back copies of the CACM (as the journal is usually called), you will find that the July 1974 issue with the original UNIX paper is often missing, no doubt the result of overenthusiastic souvenir hunters. The August 1974 issue, (the one with my paper), however is always available.

Outside Bell Labs, the most important nexus of Unix development was the Computer Science Department at the University of California at Berkeley. In 1974, a professor at Berkeley, Bob Fabry, procured a copy of AT&T's UNIX version 4, and Berkeley students started making major enhancements. In 1975, Ken Thompson went to Berkeley for a one-year sabbatical, which acted as a catalyst for Berkeley's Unix development.

In the same year, AT&T formally started licensing UNIX to universities. (As you will remember, AT&T insisted that "UNIX" must always be spelled in capital letters, and I will do just that when I am referring specifically to AT&T UNIX.)

Around this time, Bill Joy, a Berkeley graduate student, became very interested in Unix. Although no one knew it at the time, Joy's work was to have far-reaching effects.

What Joy was doing set the stage for Berkeley to become a major player in the Unix world, creating and distributing their own version of Unix. Indeed, several of today's important Unixes are direct descendents of Berkeley Unix and the work of Bill Joy.

In addition, Joy was a skillful and prolific programmer who, over the course of a few years, single-handedly created a great deal of important software. Even today, there exists no Unix system in the world that is not significantly influenced by the work Joy did in Berkeley from 1975 to 1982. In 1982, Joy became one of the cofounders of Sun Microsystems which, in its time, was one of the most important Unix companies in the world.

Perhaps I can illustrate the importance of Joy's work in this way. It has been more than 20 years since Joy worked at Berkeley, and yet, there are several chapters of this book in which we discuss programs that Joy developed at that time: the vi editor (Chapter 22) which was written in 1976, and the C-Shell (Chapters 11-14) which was written in 1978.

(While I am musing, let me mention the startling fact that the two most popular Unix text editors, still in wide use today, were both written a very long time ago: vi by Bill Joy in 1976, and Emacs by Richard Stallman in 1975.)

In 1977, Bill Joy shipped the first version of Berkeley's Unix. This was the same year in which I started using Unix. (At the time, I was a computer science graduate student at U.C. San Diego.)

The system that Bill Joy shipped was referred to as the Berkeley Software Distribution, later abbreviated as BSD. In all, Joy ended up shipping about 30 copies to users outside of Berkeley. Although this seems like a small number, it was considered a success, and in mid-1978, Joy shipped the next version, 2BSD.

In 1979, AT&T finally acknowledged the potential of UNIX and announced that they were going to start selling it as a commercial product. The first commercial version was called UNIX System III ("System Three"). In time, it was replaced by UNIX System V ("System Five").

By 1979, all BSD users were required to buy a license from AT&T and, every year, AT&T increased the price of that license. More and more, the BSD programmers were chafing under the yoke of the AT&T restrictions.

Jump to top of page

Unix in the 1980s: BSD and System V

The first version of Linux was developed in 1991, and we'll get to it in a moment. However, to understand how Linux fits into the overall picture, we need to look at what happened to Unix in the 1980s. In particular, I want to explain how it came to pass that, by the end of the 1980s, there were two principal branches of Unix: BSD and SYSTEM V.

By 1980, there was a dichotomy between East Coast Unix (AT&T UNIX) and West Coast Unix (BSD), and it was growing quickly.

The Berkeley programmers and BSD users resented having to pay money to AT&T just to install BSD. AT&T, on the other hand, was determined to make UNIX a successful commercial product, one that was oriented towards the needs of companies who were willing to pay a lot of money for a license.

In 1980, Bob Fabry, the Berkeley professor I mentioned earlier, received a large contract from DARPA (the U.S. Defense Advanced Research Projects Agency) to develop Unix. DARPA had set up a nationwide computer network connecting all their major research centers. As such, they wanted an operating system that could run on different types of hardware. The purpose of the Berkeley grant was to develop Unix for this purpose.

(Quick aside: DARPA was the same agency that from 1965 through 1988 funded the research that led to the creation of the Internet. Before 1972, the name of the agency was ARPA. Thus, the ancestor of the Internet was called the Arpanet, a name you may have heard. The Arpanet as a separate entity was shut down in 1989.)

Once Fabry got the DARPA contract, he set up an organization called the Computer Systems Research Group or CSRG. Although Fabry couldn't have known it at the time, the CSRG was to last until 1994 and, during those years, was to have a major influence on BSD and on the growth of Unix throughout the world.

In 1980, however, all Fabry cared about was developing BSD, and that was the task to which the CSRG devoted itself. Over the years, they released a number of versions, all of which were highly regarded within the academic and research communities. The number of BSD users began to grow. By 1982, 4.1BSD supported TCP/IP, the system which was to become the basis of the Internet. In 1983, 4.2BSD was released and was considered very popular, being used in almost 1,000 installations around the world.

In the commercial world, AT&T was pushing in a different direction. AT&T's goal was to market UNIX as a commercial product. In 1982, they released UNIX System III, the first public release of UNIX outside of Bell Labs. In 1983, they released System V, the first version that came with official support. At the same time, AT&T combined three internal groups to create the UNIX System Development Lab.

By the end of the year, System V had an installed base of 45,000. In 1984, when System V Release 2 (SVR2) was introduced, there were 100,000 UNIX installations.

Thus, by 1985, there were two main Unix streams of consciousness. To be sure there were other forms of Unix, but all of them were derived from either BSD or System V.(*)

* Footnote

Indeed, this situation was to last well into the 1990s, until the growing influence of Linux and the open source movement was to change the world of Unix permanently.

For example, in the first two editions of this book (1993 and 1996), I taught that Unix had basically two variations: BSD and System V.

In the world of Unix, the late 1980s was characterized by two phenomena: the growth of Unix in general, and the proliferation of different types of Unix.

Figure 2-1 shows the most important commercial Unixes that were used during the 1980s and beyond. (A few of these operating systems are still being sold today.) Every one of these Unixes, without exception, was based on either BSD or System V or both.

Figure 2-1: The most important types of commercial Unix

Name Company BSD or System V?
AIXIBMBSD + System V
AOSIBMBSD
A/UXAppleBSD + System V
BSD/OSBerkeley Software DesignBSD
CoherentMark Williams CompanySystem V
DynixSequentBSD
HP-UXHewlett-PackardSystem V
IrixSilicon GraphicsBSD + System V
MachTenTenon IntersystemsBSD
NextstepNext SoftwareBSD
OSF/1Digital Equipment CorpSystem V
SCO UnixSanta Cruz Operation (SCO)System V
SolarisSun MicrosystemsBSD + System V
SunOSSun MicrosystemsBSD
UltrixDigital Equipment CorpBSD + System V
UnicosCray ResearchSystem V
UNIXAT&TSystem V
UnixwareNovellSystem V
XenixMicrosoft/SCO/Altos/TandySystem V

Although all the important Unixes were derived from either BSD or System V, there came to be many different versions and, for several years, there was enormous infighting and contention.

During the last half of the 1980s, I was a writer and a consultant, and I remember the intrigue and the confusion. The world of Unix was characterized by the various companies making alliances, breaking alliances, forming consortiums, disbanding consortiums, and offering one technical proposal after another, all in an attempt to "standardize" Unix and dominate the market.

In the meantime, in the universities and research institutions, Unix users were growing restless. Many of them were using some variant of BSD, and they were not happy that AT&T had partial control over what they were doing. The solution was to rewrite, from scratch, the parts of BSD that were based on AT&T UNIX.

It took a long time, but the Berkeley programmers worked diligently, replacing the UNIX parts of BSD one component at a time. Creating a completely independent version of BSD was a noble goal, but it was not to happen until 1992.

Jump to top of page

Unix in 1991: Waiting for...

By 1991, PCs had been around for 10 years. Still, there was no PC operating system that was attractive to hackers, the type of programmers who like to take things apart and modify them just for fun. DOS (for PCs) was simple and unsatisfying. The Apple Macintosh operating system was better, but the machine itself was too expensive for hobbyists.

Unix would have been fine. After all, some of the best hackers in the world had been working on it for years. However, BSD (as yet) didn't run on a PC, and commercial versions of Unix were prohibitively expensive.

Computer science professors had a similar problem. AT&T UNIX would be a good tool to use for teaching operating systems courses except that, in 1979, AT&T changed their policy. Starting with what they called UNIX Seventh Edition, no one outside AT&T was allowed to look at the UNIX source code.

AT&T's new policy meant that, unfortunately, UNIX could no longer be used for teaching, because operating systems students need to be able to look at the source code to see how the system works.

What computer science professors needed was a free, readily available operating system, one that was suitable for teaching and for which source code was readily available.

One such professor was Andrew Tanenbaum, who taught at the Vrije Universiteit in Amsterdam. He bought an IBM PC and set out to build his own operating system from scratch. The new operating system was a lot like Unix, but was much smaller, so Tanenbaum called it Minix ("minimal Unix").

Minix contained no AT&T source code whatsoever, which meant that Tanenbaum could distribute the new operating system as he wished. The first version of Minix, released in 1987, was designed to be compatible with UNIX Seventh Edition. It was used primarily for teaching and, as teaching tools go, it was a good one (but not perfect).

For several years, Minix was the best tool available for programmers who wanted to learn about operating systems and to experiment. People around the world began to use it, especially in universities. At the same time, a great number of enthusiastic volunteers began to modify Minix on their own.

Still, Minix did not meet people's expectations. A lot of programmers liked it and wanted to enhance the official version, but the copyright was held by Tanenbaum who vetoed most of the requests. Minix, he insisted, should remain a simple operating system, suitable for teaching.

Minix users were disgruntled. When Richard Stallman had founded the Free Software Foundation in 1985, he had inspired programmers around the world, and they yearned for a robust, free operating system on which they could vent their collective energy.

Now, Stallman had planned a free, Unix-compatible operating system as his first major project. He even had a name for it, GNU. By 1991, Stallman and the FSF had created a great deal of high-quality, free software, but GNU itself was nowhere near ready.

As we discussed earlier, there are two types of programs that make up Unix: the kernel and everything else, which we called the "utilities". By the end of the 1980s, the FSF had programmed a lot of the important utilities, including a shell. However, they did not have a finished kernel (the core of the operating system).

Stallman and the FSF programmers had been working for some time, but the GNU kernel, which he called HURD, was far from ready. In fact, work on HURD had really only started in 1990 and, for years, programmers around the world had been crying themselves to sleep every night, plaintively singing, "Someday, my HURD will come..."

So to put it all together: By 1991, PCs had been available for 10 years, and thousands of programmers, students and computer scientists shared a strong desire for an open-source, Unix-like operating system.

AT&T, however, had commercialized UNIX up the wazoo. BSD was available, but it was encumbered by the AT&T license. Minix was okay, but far from perfect. Although the source code was readily available, it still required a license and it couldn't be shared freely. GNU, on the other hand, was distributed under the auspices of the GPL copyleft, which was great. However, the kernel — the most important part of the operating system — was a long way from being finished.

As fate would have it, a young student in Finland named Linus Torvalds had just started a project: just for fun, he decided to write his own operating system kernel.

Little did Torvalds know that, within a decade, his personal operating system would grow into the most important open source undertaking in history, an innovative project that, in the fullness of time, would engage hundreds of thousands of programmers and, literally, change the world.

What's in a Name?

Hurd


In our discussion of kernels, I explained that most operating systems use either a monolithic kernel (a single large program) or a microkernel combined with a number of smaller programs called servers. For GNU, Richard Stallman chose to use a microkernel called Mach, combined with a group of servers which he called "the Hurd". (The name was coined by Thomas Bushnell, the main kernel programmer.)

Strictly speaking, the GNU kernel should be described as the Hurd (servers) running on top of Mach. However, in common usage, the entire kernel is usually referred to as Hurd.

You already know that when Stallman chose a name for the Free Software Foundation's version of Unix, he decided to call it GNU: a recursive acronym for "GNU's not Unix". When it came to naming the kernel, Stallman one-upped himself.

The name Hurd stands for "HIRD of Unix-Replacing Daemons". (In Unix, a "daemon" is a program that runs by itself in the background.) The name HIRD stands for "HURD of Interfaces Representing Depth".

Thus, Hurd is an indirectly recursive acronym. (Hopefully, the only one you will ever meet in your life).

Jump to top of page

...Mr. Right, Linus Torvalds

Linus Torvalds is the quintessential right guy with the right idea in the right place at the right time.

In 1991, Linus (pronounced "Lee'-nus") was a second-year computer science student at the University of Helsinki. Like tens of thousands of other programming students who loved to tinker, Linus had read Andrew Tanenbaum's book Operating Systems: Design and Implementation, which explained the principles behind the design of Minix. As an appendix to the book, Tanenbaum had included the 12,000 lines of source code that comprised the operating system, and Linus spent hours studying the details. (At this point, you may want to take a moment to think about what it would take to read through 12,000 lines of code, and compare that to the type of information you find in the appendices of this book.)

Like many other programmers, Linus wanted a free (open source) version of Unix. Unlike the other programmers, Linus didn't want to wait.

On August 25, 1991, Linus sent a message to the Usenet discussion group that was used as a Minix forum (comp.os.minix). In retrospect, this short message is considered to be one of the historical documents in the world of Unix, so I will show it to you in its entirety. When you read it, remember that English was Linus's second language, and that he was writing informally.

Linus Torvalds announcing his new project...

From: torvalds@klaava.Helsinki.FI (Linus Benedict
  Torvalds)
Newsgroups: comp.os.minix
Subject: What would you like to see most in minix?
Summary: small poll for my new operating system
Date: 25 Aug 91 20:57:08 GMT
Organization: University of Helsinki

Hello everybody out there using minix -
I'm doing a (free) operating system (just a hobby,
won't be big and professional like gnu) for
386(486) AT clones. This has been brewing since
april, and is starting to get ready. I'd like any
feedback on things people like/dislike in minix,
as my OS resembles it somewhat (same physical
layout of the file-system (due to practical
reasons) among other things).

I've currently ported bash(1.08) and gcc(1.40),
and things seem to work. This implies that I'll
get something practical within a few months, and
I'd like to know what features most people would
want. Any suggestions are welcome, but I won't
promise I'll implement them :-)

Linus (torvalds@kruuna.helsinki.fi)

PS. Yes - it's free of any minix code, and it has
a multi-threaded fs [file system]. It is NOT
protable (uses 386 task switching etc), and it
probably never will support anything other than
AT-harddisks, as that's all I have :-(.

Clearly, Linus was just trying to have fun by building his own operating system. He recognized that his main job would be to write a kernel because, for the most part, the utilities were already available from the Free Software Foundation in a form that he could adapt for his own use when the time came.

In September 1991, Linus released the first version of his kernel, which he called LINUX. Linux was distributed over the Internet, and within a short time, Linus began to release one new version after another. Programmers around the world began to join Linus: first by the tens, then by the hundreds, and, eventually, by the hundreds of thousands.

Interesting note: Linus chose to design Linux using a monolithic kernel. Minix, written by Andrew Tanenbaum, used a microkernel. Soon after Linux began to attract attention, Tanenbaum (a well-known professor) publicly excoriated Linus (a more-or-less unknown student) for that design decision. Even today, after the Linux kernel has become the basis for the most successful form of Unix in history, Tanenbaum still criticizes Linus for using a monolithic kernel. (Personally, I have read Tanenbaum's arguments, and I think he is wrong.)

Eventually, Linux became so popular as to run on every type of computer: not only PCs, but everything from handheld devices with their small built-in processors, to massively parallel supercomputing clusters, the fastest, most powerful systems in the world. Indeed, by 2005, virtually every niche in the world of computing would come to be occupied by machines running some type of Linux, and Linux would be the most popular operating system in the world. (Windows is more widespread, but Linux is more popular.)

Why was Linux so successful? There are four reasons, and they all have to do with Linus himself.

First, Linus Torvalds was an extremely skillful and knowledgeable programmer. He was a fast worker, and he loved to program. In other words, he was exactly the type of guy whose idea of fun would be writing his own operating system kernel.

Second, Linus was an endless perfectionist. He was dedicated to his work and, when a problem fell into his lap, Linus would not rest until he had come up with a solution. In the early days of Linux, it was not unusual for Linus to make modifications so quickly that he would sometimes release a new kernel more than once a day!

Third, Linus had a pleasing personality. People describe him as a low-key, unassuming fellow: a genuinely nice guy (see Figure  2-2). In person or online, Linus pretty much gets along with everyone because he is so easygoing. As he once observed in an interview, "Unlike Richard Stallman, I really don't have a message."

Fourth — and most important — Linus had a genius for using the Internet to tap into a wellspring of programming talent: the thousands and thousands of people who would volunteer their efforts to modify and extend the Linux kernel.

Figure 2-2: Linus Torvalds

Linus Torvalds. In 1991, Linus founded a project to create a new operating system kernel, which we now call the Linux kernel. The Linux kernel is the basis for the various Linux operating systems, making Linus' undertaking one of the most important software projects in history. As you can see from the photo, Linus does not take himself too seriously.

How large is Linux? Today, the Linux kernel in its entirety consists of well over 17,000 files and millions of lines of code. Every day, volunteer programmers submit hundreds of patches (changes or corrections). (It is interesting to compare this to the very first kernel, version 0.01, which consisted of 83 files. In all, there were a bit fewer than 9,000 lines of code.)

Having so many people on the job also gave Linus unusual opportunities because he had the brain power to handle any new problem that came along. When a new piece of hardware came out, for example, there was always somebody somewhere who was knowledgeable enough to write the code to make the new device work under Linux.

Early on, Linus made a strategic decision to release the Linux kernel under the auspices of the GNU GPL. This decision proved to be crucial, as it encouraged programmers to volunteer their time. They knew that everything they worked on would be shared freely with the rest of the world. Moreover, the GPL ensured that any operating system that ultimately used the Linux kernel would itself fall under the auspices of the GPL and, hence, would be freely distributable.

From the start, Linus released new versions of the kernel as often as he could. Normally, programmers like to hold onto new software, so they can test it thoroughly and fix as many bugs as possible before the program is released to the public.

Where Linus's genius came in is in realizing that, since he was releasing software to a vast audience, he would have so many people testing and reading the new code, that no bug could hide for long. This idea is embodied in what is now called LINUS'S LAW: "Given enough eyeballs, all bugs are shallow."

Linus released new versions of the kernel far more often than anyone had ever done before, and bugs were identified and fixed quickly, often within hours. The result was that work on Linux progressed faster and better than any major software project in the history of the world.

What's in a Name?

Linux


The proper way to pronounce Linux is to rhyme with "Bin'-ex".

From the beginning, Linus Torvalds used the name Linux informally, "Linux" being a contraction of "Linus's Minix". However, he actually planned to use the name Freax ("free Unix") when he released the first public version of the kernel.

As it happened, another programmer, Ari Lemmke, had convinced Linus to upload the files to a server Lemmke ran, so they could be accessed easily via a system called "anonymous FTP". Lemmke was not happy with the name Freax, so when he set up a directory to hold the files, he called the directory linux, and the name stuck.

Jump to top of page

Linux Distributions

Strictly speaking, what Linus Torvalds and the Linux project created was a kernel, not a complete operating system (and this is still the case). When the kernel was first released, you needed to be a Unix expert in order to use it because you had to find all the necessary bits and pieces and put them together to form an operating system.

Within 5 months of Linus's first kernel release, however, other people were offering free operating systems that were based on the Linux kernel. Such an offering is called a Linux DISTRIBUTION (sometimes shortened to DISTRO).

As you can imagine, the first few distributions were welcomed by the Linux community but, unfortunately, they were not well-maintained. In July 1993, however, a programmer named Patrick Volkerding announced a new distribution he called SLACKWARE. The name comes from the word "slack", referring to the feeling of exhilaration and satisfaction that comes from achieving your personal goals. (For more information, look up the Church of the SubGenius.)

Slackware was a success because, over the years, Volkerding has always managed to maintain it. Today, it is the oldest Linux distribution still being actively developed. In fact, Slackware is so popular that it has spawned an entire family of distributions and supporting groups of its own.

Today's modern Linux distributions offer a complete product: the kernel, the utilities, programming tools, and at least one GUI. As I write this, there are literally hundreds of such distributions. (If you want, once you become proficient at Unix, you can make a Linux distribution of our own.)

Before we leave this section, I want to make sure you understand that the word "Linux" has two meanings: First, "Linux" refers to a kernel, the product of the countless programmers who work on the Linux project.

Second, "Linux" is the name of any operating system that is based upon the Linux kernel. This is the way most people use the word when they talk, and that is how we will use it in this book.

Most Linux distributions use the GNU UTILITIES from the Free Software Foundation. For this reason, the FSF insists that Linux-based operating systems should actually be called GNU/Linux. I don't know anyone who does this, but you might remember it in case you are hanging out at a Unix bar and you happen to run into Richard Stallman.

Jump to top of page

BSD Distributions

As we discussed earlier, BSD was one of the two main streams of Unix during the 1980s. (The other was System V.) BSD was developed within the Computer Science Department at U.C. Berkeley and, since 1980, the development had been managed by the CSRG (Computer Science Research Group).

By the end of the 1980s, BSD aficionados had become disgruntled over AT&T's commercialization of Unix. Because BSD contained certain proprietary elements from AT&T UNIX, and because the CSRG released source code with the operating system, every BSD user was forced to buy an expensive source code license from AT&T.

For this reason, the CSRG set a goal for themselves: to completely rewrite all the AT&T-based parts of BSD. Doing so would free BSD from the clutches of the AT&T lawyers (and the AT&T marketing department) once and for all.

In 1989, the CSRG offered the first totally open source BSD distribution called Networking Release 1 (more formally, 4.3BSD NET/1). NET/1, however, consisted mostly of networking tools — which were independent of AT&T UNIX — and not the full BSD operating system.

To create a truly independent version of BSD would require rewriting hundreds of AT&T utilities and programming tools, but it had to be done. Using the Internet, the CSRG solicited help from outside programmers and, within a year and a half, all the AT&T utilities had been replaced with brand new programs.

A careful check of the code showed that everything in BSD was fine except for six kernel files. Rewriting these six files would have been a big job so, in 1991, the CSRG released a new version of BSD that was almost UNIX-free. They called it NET/2.

In 1992, a programmer named Bill Jolitz rewrote the last six problematic files and used them to create a version of BSD for PCs. He called this operating system 386/BSD and began to distribute it over the Internet.

This was a huge achievement. After all these years, the holy grail of Berkeley -- an operating system that was independent of AT&T Unix -- existed. Finally, BSD could be distributed freely as open source software to anyone in the world.

This was important because BSD contained some of the best Unix software ever written. To this day, there are very few Unixes in the world that don't contain BSD code. Indeed, most Linux distributions use a large number of BSD utilities. For this reason, the creation of 386/BSD is one of the milestones in the history of Unix.

Within a short time, 386/BSD became popular and an ever-increasing number of people began to maintain it. Jolitz, however, had a full-time job, and he was not able to keep up with all the incoming patches and enhancements. For this reason, a group of volunteers was formed to take over the job. The first thing the group did was to rename the operating system FreeBSD.

Initially, FreeBSD ran only on PC hardware, which was fine with most of the users. Some, however, wanted to run BSD on other types of machines, so a new group was formed, with the goal of porting FreeBSD to as many other types of computers as possible. The version offered by the new group was called NetBSD.

In the mid-1990s, the NetBSD group spawned yet another group that wanted to focus on security and cryptography. Their operating system was called OpenBSD.

As you can see, the world of BSD, which has only three main distributions (FreeBSD, NetBSD and OpenBSD), is a lot different from the world of Linux, where there are literally hundreds of different distributions.

By now, you are probably wondering, if FreeBSD is completely open source and is distributed for free over the Internet, how is it that Linux was the version of Unix that grew so popular?

There are two reasons. First, Linux was distributed under the auspices of the GNU GPL, which encourages sharing. Since the GPL prohibits anyone from using Linux to create and distribute a proprietary system, anything done with Linux belongs to the world at large.

The BSD license is far less restrictive than the GPL. Under the BSD license, it is allowable to use parts of BSD to create a new product without having to share it. When this happens, the world at large does not get the benefit of being able to use and modify the new product. For this reason, many programmers prefer to work with Linux.

(On the other hand, because the BSD license is so flexible, FreeBSD has been used widely in a large variety of machines and devices, as well as a great many Web servers around the world.)

The second reason Linux was more successful than FreeBSD had to do with timing. In retrospect, it was clear that, by the end of the 1980s, programmers around the world had a strong need for a completely open source version of Unix. Since Linus Torvalds released the Linux kernel in 1991, and 386/BSD was not released until 1992, Linux got a head start. As a result, Linus was able to attract a large number of programmers, who were just waiting to work on the world's first free version of Unix.

Now you know why this book is called Harley Hahn's Guide to Unix and Linux, not Harley Hahn's Guide to Unix and FreeBSD.

(And now you also know why I described Linus Torvalds as the right guy with the right idea in the right place at the right time.)

Jump to top of page

What Type of Unix Should You Use?

With all the different types of Unix, the questions arises, what type of Unix should you use?

The answers (there are several) are actually rather simple. However, before I proceed, let me tell you that, for practical purposes, basic Unix is basic Unix: if you know how to use one type of Unix, you know how to use them all. In particular, as you read this book, it really doesn't matter what type of Unix you are using (as long as you don't read with your mouth full).

I first used Unix in 1977 and everything I learned then still works the same way. If you had used Unix in 1977 and you fell into a time warp, emerging in 2005 in front of a Linux or FreeBSD computer, how would you feel? You would have to learn how to use some new tools, including a new, sophisticated GUI (graphical user interface). However, you wouldn't feel like you had woken up in a brand new world. Unix is Unix.

That said, here is my advice.

In many cases, you don't have choice as to what type of Unix you must use. For example, you may work for a company that uses a commercial Unix such as AIX (from IBM) or Solaris (from Sun); or you may be taking a class where everyone has to use the same type of Linux; or you might be hacking with your grandmother, who insists on using FreeBSD because it reminds her of all the fun she had in Berkeley in the '70s.

If this is the case, just go with the flow and don't worry. Unix is Unix.

If you are choosing your own Unix, here is how to decide:

1. If you are using Unix because you want to learn how it works, how to customize your environment, how to program, or you just want to have fun, use Linux.

To help you with your choices, Figure 2-3 shows the most important Linux distributions. All of these are readily available on the Internet. Most of the distributions can be downloaded at no cost.

If you are not sure which one to use, use Ubuntu.

Figure 2-3: The most important Linux distributions

Name
Debian
Fedora Core
Gentoo
Knoppix
Mandriva (used to be Mandrake)
MEPIS
Red Hat
Slackware
SuSE
Ubuntu
Xandros

2. FreeBSD is very stable and reliable, and tends to work just out of the box. So, if you are working at a company, and you are looking for a system that needs as little attention as possible, use FreeBSD. Similarly, if you are working at home and want to run a server (such as a Web server), use FreeBSD.

If your system is not supported by FreeBSD, use NetBSD. If you are very interested in security, use OpenBSD.

For completeness, Figure 2-4 shows the most important BSD distributions.

Figure 2-4: The most important BSD distributions

Name
FreeBSD
OpenBSD
NetBSD

3. If you want to run Unix under Microsoft Windows, you can use a free product called Cygwin. Once Cygwin is installed, all you have to do is open a Cygwin window and, within that window, everything looks like Linux.

I love Cygwin. Even though I have several Unix computers, I use Windows a lot and, with Cygwin, I can access my favorite Unix programs whenever I want.

4. Finally, if you want Unix, but you want it to look like Windows, get a Macintosh and run OS X.

OS X is the Macintosh operating system. Although it has a Mac-like look and feel, it is actually Unix under the hood. Specifically, OS X uses a microkernel based on Mach, the FreeBSD utilities, and a proprietary GUI named Aqua.

To access Unix directly under OS X, just open a Terminal window. (You will find Terminal in your Applications/Utilities folder.)

What's in a Name?

OS X


OS X (the Macintosh operating system) is pronounced "O-S-ten". The name is a pun.

The previous Mac operating system — which was not based on Unix — was called OS 9. Thus, the "X" stands for the Roman numeral 10, but it also makes you think of Unix.

Jump to top of page

How Do You Get Linux or FreeBSD?

Most of the time, Unix is installed from one or more CDs. To install Linux or FreeBSD, all you need to do is find a free downloading site (which is easy), download the files, burn the CDs, and then use the CDs to install the operating system.

Better yet, if you ask around, you may find someone who already has the CDs. Since both Linux and FreeBSD are free software, there is no problem borrowing CDs or even making your own copies to share with other people.

When you install Linux or FreeBSD in this way, the operating system resides on your hard disk. If your Unix system is the only operating system on your computer, the situation is simple. Whenever you turn on the computer, Unix will boot automatically.

Alternatively, you can install more than one operating system on your computer. You might, for example, want both Windows and Unix, which allows you to switch back and forth as you wish. However, you can only run one operating system at a time and, to switch from one to the other, you need to reboot. Such a setup is called a DUAL BOOT system.

When you use a dual boot system, you make use of a special program called a BOOT LOADER. The boot loader takes control every time you start or restart your computer. Its job is to show you a list of available operating systems, so you can choose the one you want. The boot manager then transfers control to the appropriate kernel, and the kernel starts the rest of the operating system. (As a general rule, if your PC takes a minute to boot, about 15 seconds is used by the boot loader, and about 45 seconds is used to load the operating system.)

The most common Linux boot loaders are GRUB (Grand Unified Bootloader) and LILO (Linux Loader). LILO was developed a long time ago as part of the Linux distribution, and it has been well maintained over the years. GRUB is newer and was developed as a part of GNU. Both boot loaders are fine but if you have a choice, use GRUB because it is more powerful and more flexible.

To set up your machine as a dual boot system, you must divide your hard disk into parts called PARTITIONS. To do so, you use what is called a PARTITION MANAGER. Each operating system must be installed using its own partition (or partitions, if more than one is required).

The most common type of dual boot system is one in which Windows coexists with some type of Unix. However, there is no reason why you can't partition your disk to use more than two operating systems on the same computer. For example, you might have Windows, Fedora Core Linux and FreeBSD. The boot loader will then offer you three choices, rather than two. In such cases, we would say that you have a MULTI-BOOT system.

A second way to run Unix is not to install it onto your hard disk. Instead, you can boot from a special CD called a LIVE CD.

A live CD is a CD-ROM that has been made bootable, and that contains everything necessary to run a full operating system: the kernel, the utilities, and so on. When you boot from a live CD, you bypass the hard disk. This allows you to use a second (or third or fourth) operating system whenever you want, without having to install anything on your disk.

For example, if you are a Windows user, you can experiment with Linux or FreeBSD without having to repartition and install a whole new operating system. Similarly, if you are a Linux user, you can try out, say, FreeBSD, without having to make changes to your system. Some people who don't know what type of Linux they want to use permanently will use live CDs to try out different distributions.

Live CDs are also useful when you are using a PC that does not belong to you. For example, if you work for a company that forces you to use Windows, you can use a live Linux CD to run Unix when no one is watching. Or, if you are fixing a friend's computer, you can boot your own operating system with your favorite tools without changing your friend's computer in any way.

To create a live CD, just pick the one you want, download the files, and burn the CD. You might even make several live CDs to experiment with different systems.

There are many different live CDs available on the Internet for free. To help you, Figure 2-5 lists the most important ones. If you are not sure which one to use, use Knoppix (pronounced "Nop'-pix").

Figure 2-5: The most important Linux live CDs: Linux and FreeBSD

Name
Damn Small Linux
FreeBSD
Kanofix
Knoppix
MEPIS
PCLinuxOS
SLAX
SuSE
Ubuntu

— hint —

If your computer boots from the hard disk even when you have a CD in the drive, check the BIOS settings.

You may have to modify a setting to tell the computer to look for a bootable CD before looking for a bootable hard disk.

How do you choose between a full hard disk installation and a live CD?

A full installation is a commitment as it requires you to make lasting changes to your hard disk. (Of course, you can undo these changes if you want.) The advantage of a full installation is that the operating system is on your disk permanently. Not only is this convenient, but you can customize your system and store files permanently.

With a live CD, there is less of a commitment. However, unless you set aside a special disk partition for the live CD to use for its data, you can't make permanent modifications or save Unix data files.

Moreover, running Unix from a live CD will decrease the performance of your computer a bit. Not only is it slower to boot off a CD than a hard disk, a live CD system will have to create a RAM disk to hold the files that would normally be on your hard disk. This will use up some of your memory. (A RAM disk is a part of memory that is used to simulate a real disk.)

A nice compromise is to install Unix to some type of removable storage device, such as a USB key drive (sometimes called a USB flash drive). This is a very small, portable device that plugs into a USB port and acts like a tiny hard disk.

Once you have installed Unix to a key drive, all you have to do is insert it into a USB port, turn on (or restart) the computer, and Unix will boot automatically. (You may need to change your computer's BIOS settings to tell it to boot from the key drive before the hard disk.)

By installing to a key drive, you get most of the benefits of a permanent Unix system without having to modify your hard disk. For example, when you boot from a key drive, you can modify your system, you can save files, and so on. Unlike a CD-ROM, which is only readable, a key drive is read/writeable. And whenever you want to use the operating system on your hard disk, all you have to do is remove the key drive and reboot.

Still, once you decide to use an operating system permanently, you will find it faster and more practical to install it on your hard disk. Flexibility is nice but, in the long run, as with most areas of life, commitment works better.

— hint —

Downloading and installing any type of Unix will take longer than you anticipate, so don't do it when you are in a hurry.

For example, if it is your honeymoon night, and you have a half hour to kill while your wife changes her clothes and freshens up, starting a brand new Linux installation would be a bad idea.

Jump to top of page

What Is Unix? What Is Linux?

Before we leave this chapter, I'd like to summarize our discussion by, once again, answering the questions: What is Unix? and What is Linux?

Unix is a multiuser, multitasking operating system that consists of a Unix-like kernel, Unix-like utilities and a Unix-like shell. Linux is the name given to any Unix that uses the Linux kernel. (As we discussed, there is no good definition of the term "Unix-like". You just have to know it when you see it.)

However, there is another way to look at Unix.

Over the years, a great many very, very smart people have worked on Unix to build themselves the very best tools they could. As Unix users, you and I get to reap the benefits of that work.

To me, Unix is an an abstract idea: an actual applied philosophy that dictates a particular approach to problem solving. In using Unix, you will learn to approach and solve problems the Unix way. For example, you will learn how to combine simple tools, like building blocks, into elegant structures to solve complex problems; you will learn how to be self-reliant, teaching yourself most of what you need to know; and you will learn how to organize your thoughts and actions in a logical way that makes the best use of your time and effort.

As you do so, you will be following in the footsteps of giants, and your mind will be changed for the better. This may be hard to understand right now, but don't worry. Just stick with Unix long enough, and you will see for yourself.

For this reason, let me give you another definition of Unix. This is the best definition of Unix I know, and it is the one I would like you to remember as you read this book.

I'll give it to you in the form of a hint:

— hint —

Unix is a set of tools for smart people.

Jump to top of page



Exercises

Review Question #1:

What is an operating system?

Review Question #2:

What is the kernel? Name four tasks performed by the kernel.

Review Question #3:

What is open source software? Why is it important?

Review Question #4:

What is Linux?

When was the first version of Linux released? By whom?

For Further Thought #1:

Would the Internet have been possible without Unix?

Would Linux have been possible without the Internet?

For Further Thought #2:

When Richard Stallman founded the Free Software Foundation in 1985, he was able to tap into the energy of many programmers around the world who wanted to work on a free operating system. Later, in the early 1990s, Linu Torvalds was also able to find programmers to help him, in this case, to develop the Linux kernel.

Why are so many programmers willing to work a long time on a difficult project and then give away the fruits of their labor for free? Is this more common with young programmers than old programmers? If so, why?

For Further Thought #3:

Traditionally, lawyers are expected to offer a certain amount of work free as a public service, such work being described as pro bono publico (Latin: "for the public good"). Should the programming profession have a similar expectation of its members? If so, why? If not, why not?

Jump to top of page