April 22, 2012, 11:35 AM — Having used Unix for nearly 30 years and taught it for more than 10, I am all too familiar with the glaze that comes over new users’ eyes when they are introduced to the all-powerful Unix command line. Many, in fact, find it quite difficult to understand why the command line is needed at all on modern operating systems. Others take weeks to appreciate concepts like pipes and redirection. And still others, who manage to get past these two learning obstacles, have trouble distinguishing commands that work with file descriptions (i.e., metadata) from those that work with file content. It’s as if they’ve entered a new world in which all of the rules are new and nothing that they’ve done before is of any use in navigating this new OS terrain.
The problem with most introductions to Unix is that they cover too much too quickly. Even just the most important 20 or 30 commands, crisply covered in a table with examples, can be overwhelming. Until the key Unix concepts begin to gel in a new users’ minds, nothing’s going to sink in very deeply. Example commands look like gibberish and the syntactical descriptions that top man pages resemble hieroglyphics. There is a better way.
The Linux Command Line: A Complete Introduction is the better way. Instead of overwhelming Unix neophytes with a brand new way of thinking, it gets off the ground with some very basic operations. Open a terminal window, it says, type some random characters, and watch the system respond with “command not found”. Let that sink in. The basic lesson taught in this interaction goes a long way. Neophytes see that the shell is trying to interpret whatever they’ve just typed and, when it has exhausted its resources, it says the equivalent of “I give up” in the characteristically Unix way — “command not found”.
This interactions helps students to understand that, whenever they see “command not found”, it’s very likely that they’ve typed something incorrectly. Understanding what Unix cannot do is a great first step toward understanding what it can do.
Throughout the 36 chapters of this book, the nature of Unix is built up a few commands and concepts at a time. Interspersed with practical examples, the explanations are both clear and concise. Simple commands, navigating around the file system, experiencing different types of links, grasping relative and absolute paths, looking at portions of files with the less command, understanding key directories, using wildcards, pipes, and filters … Each lesson is a small step forward with good command examples and just enough explanation to hold the new material together.
Then, in Chapter 7 (Seeing the World as the Shell Sees It), the book steps back and covers the various types of expansion, quoting and escapes. The nature of the Linux command line begins to show itself in increasing dimension.
The book then moves through permissions, identities, the concept of privilege, processes, and performance. It explains the use of ctrl-C, background and foreground tasks, the kill command, and what signals are and how they are used.
By the time readers get through Chapter 10, a great foundation for making sense of the command line has been built up one concept at a time.
By Part 2, readers are ready to move up a level. This part of the book discusses the shell environment and explains important files like .bashrc. Readers soon move to learning vi and customizing their command prompts.
Part 3 ups the ante quite a bit with package management, storage media, networking basics, searching for files, archiving files and making back ups. By this point in the book, our neophyte users are jumping ahead into serious Unix administration.
Readers get to Chapter 19 before hitting regular expressions, the grep command, and anchors. This is the kind of material that, presented too early, intimidates new Unix users. By Chapter 20, the book has moved to text processing — sorting, pasting, joining and changing text with the likes of cut. Readers are looking at file commonalities and differences with commands like comm and diff. They are using sed and spell checking with aspell. They are formatting output, numbering lines, printing and compiling simple programs.
Part 4 has readers finally writing scripts, adding comments, setting permissions, and using indentation to enhance readability. By this point, the chmod command and the importance of the $PATH variable make total sense. Readers are introduced to good programming techniques, the value of comments, the use of variables and constants. The book suggests good design tactics, explains the basics of flow control with the if command, and demonstrates use of the exit status.
The book continues through string expressions, the use of [] and (()), the logic of and ||, reading keyboard input, looping with while, until, and for. The book offers good advice for troubleshooting, shows readers how to create effective case statements and make use of positional parameters. It contrasts the manipulation of strings and numbers.
Chapter 35 covers arrays with examples that are both clear and extremely useful for building, assigning values to, accessing, sorting and deleting arrays.
The book ends with Chapter 36. Entitled “exotica”, this chapter covers topics such as grouping commands within braces and parentheses, subshells, traps and named pipes. As you can see, readers have moved into fairly advanced material by the time the book ends.
The Linux Command Line provides a very logical progression of topics with just the right mix of example and explanation at each level. Each topic builds on the previous material without ever slapping the student upside the head with “here’s a pile of commands you need to swallow”. Anyone who reads this book and makes use of the examples provided will not be able to avoid becoming a Unix command line pro by the time they’ve hit the end of the book. It provides an excellent introduction to the command line that takes students from knowing nearly nothing to using impressively sophisticated commands. And for anyone who learned Unix by being tossed into it and figuring things out a little at a time, it might even fill some important holes that leave them saying “Oh, I get it now!”.
The Linux Command Line is easily the best introduction to Unix or Linux that I have come across to date.