RI About the Ingredients AL PART I CHAPTER 3: Variables MA CHAPTER 2: Getting Started TE CHAPTER 1: The History of Unix, GNU, and Linux TE D CHAPTER 4: Wildcard Expansion GH CHAPTER 5: Conditional Execution CHAPTER 6: Flow Control Using Loops RI CHAPTER 7: Variables Continued PY CHAPTER 8: Functions and Libraries CO CHAPTER 9: Arrays CHAPTER 10: Processes CHAPTER 11: Choosing and Using Shells
1 The History of Unix, GNU, and Linux The Unix tradition has a long history, and Linux comes from the Unix tradition, so to understand Linux one must understand Unix and to understand Unix one must understand its history. Before Unix, a developer would submit a stack of punched cards, each card representing a command, or part of a command. These cards would be read and executed sequentially by the computer. The developer would receive the generated output after the job had completed.
❘ CHAPTER 1 THE HISTORY OF UNIX, GNU, AND LINUX An early feature of Unix was the introduction of pipes — something that Doug McIlroy had been thinking about for a few years and was implemented in Unix by Ken Thompson. Again, it took the same notion of streamed serial data, but pipes introduced the idea of having stdin and stdout, through which the data would flow. Similar things had been done before, and the concept is fairly simple: One process creates output, which becomes input to another command.
Unix ❘ 5 Also this system means that you do not have to learn how each individual utility implements its “word count” feature. There are a few defacto standard switches; -q typically means Quiet, -v typically means Verbose, and so on, but if who -c meant “count the number of entries,” then cut -c , which means “cut the fi rst n characters,” would be inconsistent. It is better that each tool does its own job, and that wc do the counting for all of them.
❘ CHAPTER 1 THE HISTORY OF UNIX, GNU, AND LINUX This code uses the cat facility, which simply outputs a fi le, and the tac tool, which does the same but reverses it. (The name is therefore quite a literal interpretation of what the tool does, and quite a typical example of Unix humor.) The variable $0 is a special variable, defi ned by the system, and contains the name of the currently running program, as it was called.
GNU ❘ 7 GNU As mentioned previously, the GNU project was started in 1983 as a response to the closed source software that was by then being distributed by most computer manufacturers along with their hardware. Previously, there had generally been a community that would share source code among users, such that if anyone felt that an improvement could be made, they were free to fi x the code to work as they would like.
❘ CHAPTER 1 THE HISTORY OF UNIX, GNU, AND LINUX GNU stands for “GNU’s Not Unix,” which is a recursive acronym; if you expand the acronym “IBM,” you get “International Business Machines,” and you’re done. If you expand “GNU,” you get “GNU’s Not Unix’s Not Unix.” Expand that, and you get “GNU’s Not Unix’s Not Unix’s Not Unix” and so on. This is an example of “hacker humor,” which is usually quite a dry sense of humor, with something a little bit clever or out of the ordinary about it.
GNU numbers, a crashproof file system, filename completion perhaps, terminal-independent display support, and eventually a Lisp-based window system through which several Lisp programs and ordinary Unix programs can share a screen. Both C and Lisp will be available as system programming languages. We will have network software based on MIT’s chaosnet protocol, far superior to UUCP. We may also have something compatible with UUCP.
❘ CHAPTER 1 THE HISTORY OF UNIX, GNU, AND LINUX Unix already existed, was quite mature, and was nicely modular. So the GNU project was started with the goal of replacing the userland tools of Unix with Free Software equivalents. The kernel was another part of the overall goal, although one can’t have a kernel in isolation — the kernel needs an editor, a compiler, and a linker to be built, and some kind of initialization process in order to boot.
Linux ❘ 11 LINUX Linus Torvalds, a Finnish university student, was using Minix, a simple Unix clone written by Vrije Universiteit (Amsterdam) lecturer Andrew Tanenbaum, but Torvalds was frustrated by its lack of features and the fact that it did not make full use of the (still relatively new) Intel 80386 processor, and in particular its “protected mode,” which allows for much better separation between the kernel and userspace.
❘ CHAPTER 1 THE HISTORY OF UNIX, GNU, AND LINUX are GNU tools. As such, some people prefer to use the phrase “GNU/Linux” to describe the combination of GNU userspace plus Linux kernel. For the purposes of this book, the goal is to be technically accurate while avoiding overly political zeal. RedHat Linux is what RedHat calls its distribution, so it is referred to as RedHat Linux. Debian GNU/Linux prefers to acknowledge the GNU content so we will, too, when referring specifically to Debian.
Summary ❘ 13 in multiple browsers on multiple platforms, a certain amount of testing is required to write solid crossplatform shell scripts. Even when writing for a typical Linux distribution, it is useful to know what is where, and how it came to be there. Is there an /etc/sysconfig? Are init scripts in /etc/rc.d/init.d or /etc/ init.