Saturday, January 21, 2012

A Book Review of The Linux Command Line: A Complete Introduction

Author: William E. Shotts Jr.
Format: Paperback, 480 pages
Publisher: No Starch Press; 1st edition (January 14, 2012)
ISBN-10: 1593273894
ISBN-13: 978-1593273897

Linux has been struggling to become a "desktop darling" of the home and small office user for years and has yet to succeed. I don't know if it will ever succeed. One of the biggest hurdles Linux has to cross is its reputation as being command-line driven. Most people fear the command line and if you're old enough, you remember (with dread) the arcane DOS interface or struggling to remember what command syntax to use with the now ancient Apple IIe. Users love Windows because the GUI is easy.

Ubuntu, of all the Linux distros, is about the best in terms of a user-friendly GUI, and yet even when Windows users abandon the Microsoft "mothership", they almost always turn to a Mac and not to Ubuntu (or any other flavor of Linux). Face it. Linux may never succeed as a desktop operating system and may have to "settle" for being the king of the server and embedded device markets.

But is that such a bad thing?

Ironically, the power of a Windows machine is on the command-line, but unless you're a system admin or network guru, that doesn't even occur to you. And absolutely, the power of Linux is in the command-line shell. Why fight the nature of what Linux is? Instead of trying to avoid shell commands, embrace them. That's where The Linux Command Line: A Complete Introduction comes in.

The hardcopy of this book should be on its way to me for my review right now, but I couldn't wait. The publisher kindly allowed me to also download a PDF version of the Shotts book, so here I am, tearing into it (metaphorically speaking) and getting ready to devour its contents. What secrets does it hold and for whom shall they be revealed?

Scrolling through the beginning of the PDF, I discovered the "Who Should Read This Book" section. According to the author, this book is for the rank beginner in the Linux world who is likely a Windows "power user" and who, for whatever reason, must learn Linux management skills. That's a rather amazing statement since, having scanned the table of contents on my way down to page 29, I discovered a rather impressive list of skills to be learned. Among them were "A Gentile Introduction to Vi" (my favorite editor), "Package Management", "Regular Expressions", "Compiling Programs", and "Writing Shell Scripts". Any one of these topics is worthy if its own book (and they're out there) and certainly they will be intimidating to the Linux novice.

But first things first.

The end of the introduction to the book gives rather brief instructions for how to install Linux on a computer or how to use a live CD, so the reader is presumed not to even use Linux on a regular basis (or at all). On the other hand, there are no links or instructions as to where to find a Linux ISO file for download or how to burn a bootable CD or DVD, so I guess the reader is expected to know something. Oh, in case you're wondering, I'm using Ubuntu 11.04 (Natty Narwhal) to write this review and practicing commands in the default bash shell.

The first section of the book is called "Learning the Shell", which is pretty basic. The first chapter, "What is the Shell" offers the reader a little bit of a history lesson on the shell and how to use very basic commands, such as "date", "cal", and "df". It's a very short chapter and fortunately gets the reader into opening and using the shell right away. It's a gentle beginning. When does the book get "rough?"

Technically, the hardcopy of the book is only 480 pages long, so it's not an encyclopaedia (remember them?). Yet, for not being a massive tome, the Shotts book probably best works not only as a linear tutorial but as a reference. After all, even veteran shell users don't remember everything and I've seen Linux developers with decades of experience still have to look up commands they don't use very often (although they almost always do so using Google rather than grabbing a handy book).

I called this book "a linear tutorial" because the first section is written in just that manner. One skill set builds on the previous ones presented and the more the reader goes through and practices what they're reading, the better they should get at navigating the directory tree, copying and moving files, locating files, and using man pages.

Although there are no exercises or labs at the end of each chapter, there are notes encouraging the reader to pause and to practice what they've learned as well as experimenting and adapting on commands they've been using. The reader is also encouraged to refer back to the help and man documentation on commands, which is a further exercise in using the shell, since these tools are the first ones a system admin or programmer turn to when they're trying to recall that rarely used command switch.

Actually, the book doesn't really need a separate section for exercises since each page in the chapters directs the reader to try out various commands. This is a book that needs to be opened alongside a Linux machine where the reader is simultaneously working in the shell.

It would take too long to review the content in each chapter and section, but there are a few notable mentions. In Chapter 12 "A Gentile Introduction to Vi", the reader is treated to a Vi primer (sorry, Emacs users). It's probably just about as much as a new user will need to edit files on a Linux machine and if need be, books such as Learning the vi and Vim Editors by Robbins, Hannah, and Lamb are always available.

I did wonder about introducing the reader to Regular Expressions in Chapter 19. For the average computer user, even the average Linux computer user, Regular Expressions can be a real "migraine maker". This may be your first clue that not everyone who will use this book will use all of it, at least not right away. Although this is a great skill to acquire, not everyone may be up to the challenge. When reading this book, assess whether or not you want or need to learn everything it has to offer.

Chapter 23: "Compiling Programs" is another chapter that may not always be useful to all readers. The content goes quickly from "What is Compiling" to downloading source code from the web (specifically ftp.gnu.org), examining the source tree, and building a program. Note that the reader isn't expected to know how to actually write a program, so the general purpose of this chapter is to introduce the power of compiling in the shell and, like vi and Regular Expressions skills, is something that can be built upon using other resources if the reader so desires.

All of the fourth and last section of the book is devoted to "Writing Shell Scripts". If the hypothetical reader of this book is someone who wants or needs to learn Linux server management skills, everything presented in the book up to this point is not only useful, but required. Certainly writing shell scripts (and again, there are entire books available on this subject), is a necessary skill set for the Linux systems admin or even for people who just like to "get under the hood" a little.

After a brief introduction, the reader is lead through the "rudimentaries" of their first shell script which is about as basic as echo 'Hello World!' The reader must dig back into what they've learned before about using vi or vim, creating a file in the desired directory, making it executable, and saving it (none of these instructions are presented again in the shell script chapter). The last bit in the chapter gives the reader a tip on how to configure vim for shell scripting by turning on syntax highlighting, highlighting search results, and using auto indent. The rest of the section takes the reader through building a scripting project and pulls together previously learned skills to develop more complex scripts, including teaching the use of loops and arrays.

The final note in the final chapter addresses the reader, "Well, we have completed our journey. The only thing left to do now is practice, practice, practice. Even though we've covered a lot of ground in our trek, we barely scratched the surface as far as the command line goes."

I can agree with that. There's a reason why the book's subtitle is "A Complete Introduction." That's not a contradiction in terms, it's the literal truth. Part of the power of the shell is in its almost infinite potential, which most shell users never master, but if you buy and then use The Linux Command Line: A Complete Introduction to its fullest extent, your "introduction" to the shell will be very impressive.

4 comments:

  1. "Linux may never succeed as a desktop operating system..." I beg to differ. According to http://www.w3schools.com/browsers/browsers_os.asp Linux accounts for about 5% of all operating systems in use, Ubuntu being the fourth most widely used OS in the world. That's hardly "never succeeding". If you think in terms of actual users that means according to this http://www.npr.org/programs/specials/poll/technology/ 81% of all American use a computer. If there are 307 million Americans that's about 248 million Americans that use a computer of which 12 million use Linux. 12 million people... hardly succeeding???

    ReplyDelete
  2. I hardly meant that Linux was a complete desktop flop, but it has only the smallest share of the desktop market in terms of the "big picture. It is much more widely used in servers and embedded systems.

    In any event, I only used that statement as the means to introduce other aspects of Linux, primarily the functionality of the shell, in order to proceed into my book review.

    ReplyDelete
  3. I was interested in reading this but your theme and color scheme make it just too hard.

    ReplyDelete
  4. Sorry. Made things a bit darker. Does that help?

    ReplyDelete

Please make comments.