Monday, February 13, 2012

Book Review: The Linux Command Line

What if you had a book that took you from the very beginning of the Linux command line options, and it took you through progressively interesting and relevant topics so that you really could develop a mastery of the shell? Oh, and what if it were written in a fun style that was less wonkish and easier to embrace and follow along with? Less tech, mode dude. William E. Shotts, Jr.'s “The Linux Command Line” manages to do that.


Let’s face it, learning the entirely of the Linux command line can take years. It’s unlikely most will walk through the book page by page and work through each example, but with this book, it feel like you could do exactly that and not get bored.


The first part of the book walks the user through the many commands that are relevant to all systems and all shells; the navigation options through directories, showing files, getting your head around terminals, finding and opening files, moving files and directories around, links (both literal and symbolic), learning about commands and how to learn more about them. All of this, as well as redirection, using pipelines, creating filters, expansions, and so on. A wonderful metaphor and explanation made in this section is that Windows is like a GameBoy, and Linux is like the world’s biggest Erector Set. While Windows is nice and shiny and makes for pretty applications, it’s difficult (relatively speaking) to roll your own applications without a fair bit of knowledge and packaged tools. Linux, on the other hand, right off the bat gives you all the tools you need to build just about anything in just about any conceivable way you might want to build it. 


Part 2 covers configuration of the shell and the environment variables that it keeps track of. Shell variables like DISPLAY, EDITOR, LANG, PS1, TERM and many others are explained and we get to see how simple shell scripts are implemented allow us to access and modify these values. We also get introduced to a variety of test editors, but with an emphasis on vi (and a mellow focus at that). The section is rounded out by learning how to modify the command prompt that we see and make it show us more details (directories, colors, etc.). 


Part 3 is a grab bag of all sorts of things that we often look at separately, but when taken together, make a lot of sense. We start with package management and making sure systems are up to date. Next we cover understanding file systems and the variety of commands that helps to mount disks, examine file systems, check and repair systems, get online and check the network for connectivity, copying files over a network and connecting via secure shell, performing archive and backup steps. The section end with a broad discussion on regular expressions, text formatting and processing and, finally, printing out files and compiling applications. 


Part 4 ties it all into the true big bad voodoo of the command line, the ability to write shell scripts. The section starts out with a fairly basic script formatting and then moves on to create a program that displays system information in HTML format. Along the way, we get to see how to use the shell and all of its properties and the huge toolkit of Linux commands to structure our work, and get an introduction to “top down design”. Subsequent chapters carry us through common development topics such as reading input from the command line, strings, numbers, variables and constants, and the variety of flow control ranging from simple branches to looping and case statements and arrays. The section ends with a grab bag of interesting topics including subshells, traps and error handling, asynchronous execution and named pipes.


Each section starts with the commands it will cover, walks through careful and thorough examples of each command, and then wraps with a simple explanation of the section covered, with sidebars aplenty. Seeing as this is a command line book, you bet that you are seeing a lot of the actual commands, and how they interact, how to apply permissions, manipulate text and manage processes. If you want practice with these things and not their graphical counterparts (and really, what “command line” book worth its salt wouldn’t make that its prime focus), well, you get your wish! 


Bottom Line: 


There are a lot of books that talk about the various Linux Shells, but you’d be hard pressed to find one that does so this entertainingly. Again, it’s the less tech (but not so much that the meat of the matter isn’t covered well) and more “dude” (but not to the point of being embarrassing or insulting) that makes this book a joy and a treasure. If you’re a novice Linux player, or just want to get beyond the pretty graphical wrapper of your MacBook, put this book at the top of your list.

No comments: