Become a fan of Slashdot on Facebook

 



Forgot your password?
typodupeerror
×

Linux Commands, Editors, & Shell Programming 118

norburym writes "Mark G. Sobell is well known for several comprehensive and well-written volumes: A Practical Guide to Solaris; A Practical Guide to Red Hat Linux: Fedora Core and Red Hat Enterprise Linux (2nd ed.); and A Practical Guide to the Unix System (3rd ed.). It seems only natural for the author to follow these exceptional examples with yet another excellent book entitled A Practical Guide to Linux Commands, Editors, and Shell Programming . Read on for Norburyms' review.
A Practical Guide to Linux Commands, Editors, and Shell Programming
author Mark G. Sobell
pages 1008
publisher Prentice Hall PTR
rating 9
reviewer Mary Norbury-Glaser
ISBN 0131478230
summary Linux Commands, Editors, & Shell Programming


While the author has covered some aspects of this material in A Practical Guide to Red Hat Linux: Fedora Core and Red Hat Enterprise Linux, there is more than enough here (in-depth coverage of the vim and emacs editors; tcsh; sed and gawk; and the command reference section that comprises Part V) to make this a new and exhaustive volume that should take top dog in anyone's Linux library.

Sobell splits the book into six parts with Chapter 1 acting as a preface to the rest of the book. It gives a history and an overview of Linux and discusses distinctive aspects of the operating system that make it different from others. We've all heard and read the arguments before: Linux is superior to Windows, TCO is lower with Linux, Linux is not proprietary, etc. but Sobell avoids this display of arrogance and superiority by treating the origins and features of Linux as an evolution of best practices and common sense. As such, we're not left with a suspicion that the author has blinders on. To the contrary, the reader can proceed with an open mind to learning the intricacies of Linux and the command line.

Part I isn't geared for experienced users of Unix or Linux but it does serve as a good skimming point for those sysadmins who may need to brush up. For the beginner or the novice, however, these four chapters give a compact and succinct introduction to using Linux and set the stage for the sections to follow. Chapter 2 begins with logging in from a Terminal, including emulation, ssh and telnet. The author explains how to tell which shell the user is running; how to work with the shell; and how to use help, man and info. Chapter 3 is a catalog of basic utilities with all the usual suspects: ls, cat, rm, cp, mv, grep, hostname, head, tail, sort, echo, date, etc.; compressing and archiving tools: bzip2, bunzip2, gzip, tar; locating commands: which, whereis, apropos, slocate; commands used to get user and system information: who, finger, w; and commands used for communication: write, mesg. Sobell gives each utility a brief but thorough description of its function, appropriate syntax and practical uses. Chapter 4 is a complete treatment of the Linux hierarchical filesystem: directory and ordinary files; absolute and relative pathnames; how to work with directories; hard and symbolic links; and access permissions. Chapter 5 is where the reader gets a closer look at the shell. Sobell covers command line syntax (command name, arguments and options), processing and executing the command line, standard input and output (including pipes and a really nice explanation of device files), redirecting standard input and output, running a program in the background and aborting it using kill, generating filenames and expanding pathnames using wildcards/special characters, and utilities built into the shell like echo (and how to list bash and tcsh builtins).

Part I is a comfortable read. It moves along quickly and with quite a bit of information but not so much to overwhelm. By the conclusion of Chapter 5, the beginner or novice can feel pretty competent with the CLI.

Part II is dedicated to the vim editor and the emacs editor, both enjoying a chapter to themselves. Sobell happily avoids adding fuel to the already flaming fire of which editor is "the best." Chapter 6, "The vim Editor," and Chapter 7, "The emacs Editor," both use a tutorial approach to demonstrate the use of each text editor. The author includes a brief history of the development of the editor before giving a fairly complete lesson on creating and editing files within that particular editor. Some highlights of Chapter 6 include: vi clones; details of vim commands like join, yank and put; and advanced editing techniques like using markers and creating macros. Chapter 7 features: an explanation of emacs key notation and key sequences; incremental and nonincremental searches; advanced editing techniques like using the buffer to undo changes; using Mark and establishing a Region; yanking killed text; and manipulating windows (splitting and adjusting, for example).

Learning at least one editor to a level of competency is an absolute must. Sobell provides excellent instruction on both vim and emacs and along with the tutorials and the exercises at the conclusion of each chapter the reader will be sufficiently proficient in both to choose a favorite.

Part III, "The Shells," discusses the Bourne Again Shell (bash) and the TC (tcsh) shell with careful detail to each interpreter/language. The author stresses that bash, rather than tcsh, should be the shell of choice for programming and this is reflected in the instruction set forth in each of these two chapters.

Chapter 8 concentrates on bash: shell basics (startup files, redirecting standard error, simple shell scripts, separating and grouping commands, job control, directory stacks); parameters and variables (shell and user-created variables, variable attributes, keyword variables, special characters); processes (structure, identification); history mechanisms (reexecuting and editing commands, referencing events using !, use of the Readline Library); using aliases; shell functions; controlling bash features and options (using command line options and the set and shopt builtins); and a description of how bash processes the command line (command line expansion).

The TC Shell (tcsh) gets equal attention in Chapter 9. The author aims to show how tcsh differs from bash while providing a broad overview of the shell: shell scripts; entering and leaving tcsh; tcsh startup files; features common to bash and tcsh (and how tcsh implements them in a different manner) including command line expansion (tcsh calls it "substitution"), history, aliases, job control, filename and command substitution, and directory stack manipulation; redirecting standard error using >&; command line (word completion, command line editing, spell correction); variables (substitution, string variables, arrays, numeric variables, using braces, shell variables); control structures (if and goto, interrupt handling using onintr, if...then...else, foreach, while, break and continue, switch); and tcsh builtins.

Part IV, "Programming Tools," is the logical progression from the previous discussions of editors and shell basics. Sobell splits this part over four topics: programming tools, programming bash, gawk and sed.

The focus of Chapter 10 is programming tools. In particular, attention is given to writing and compiling C programs. Sobell shows how to check for your GNU gcc compiler and then gives a C programming example with a simple C program that converts tabs to spaces while maintaining columns. He takes this a step further by compiling his example C program to create an executable file. He also addresses shared libraries, fixing broken binaries, using GNU make to resolve dependencies, debugging techniques, threads, and system calls for filesystem operations and for processes control. I especially like the inclusion of the make utility. Sobell provides a nice graph that shows dependency relationships and uses an example makefile to illustrate dependency lines and construction commands. The rest of the chapter deals with source code management and using the CVS (concurrent versions system) utility and TkCVS (a Tcl/Tk-based GUI to CVS).

The next chapter is a return to bash with more detail to shell programming. The author uses this section to cover control flow contructs (if...then, if...then...else, etc.); file descriptors; more detail on parameters and variables (array variables, locality of variables, special parameters like $$ and $?, positional parameters like $#, $0 and $1-$n); expanding null and unset variables; bash builtin commands (type, read, exec, kill, etc.); and expressions (including a table of bash operators). The chapter concludes with the creation of two example shell programs: a recursive shell script that illustrates recursive operations and a "quiz" shell script which presents questions with multiple choice answers. The author walks through both of these step-by-step and points out potential pitfalls as he creates and executes a working design. Sobell should be congratulated for putting together a well-balanced and complete chapter. The exercises are thoughtfully constructed.

The Gnu awk (gawk) utility and the sed (stream editor) utility complete the final two chapters of the book. Both chapters include syntax, arguments, options and a fair number of examples.

Part V is the command reference section and this constitutes a volume in itself. This is, essentially, a printed version of man pages of utilities and shell builtins. Sobell gives us a bonus above Linux man pages, though: he includes extremely useful and pithy examples with each entry along with interesting discussion and notes sections. I would love to see the "Command Reference" as an electronic, searchable version! Perhaps as a CD included with the book in future, instead of in print.

The Appendixes make up Part VI. Regular expressions used by gawk, sed, vim, emacs, etc. are described in Appendix A. Help options, including Web sites for documentation on Linux systems (GNOME, GNU, KDE, etc.), Linux newsgroups and mailing lists, software packages (CVS, Freshmeat, Sourceforge, Tucows-Linux, etc.), Office suites (AbiWord, KOffice, OpenOffice, etc.), and how to specify a Terminal make up Appendix B. The last appendix shouldn't be ignored or overlooked: Keeping the System Up-To-Date. This section describes yum, Apt and BitTorrent. Kudos to the author for reminding readers to maintain their systems and providing good instructions on how to do so.

A Glossary of terms and the Index conclude the book.

The layout of the book is well designed: the typography is comfortable to read and, although physically hefty, the dimensions of the book give the reader a nicely balanced paperback. Nothing fancy but excellent quality and eminently readable with delineated examples and good font choices.

Every chapter begins with a brief introduction and ends with a chapter summary, exercises, and advanced exercises where appropriate. The exercises are a highlight of the book: Sobell has obviously given these a lot of thought and they are exemplary of the chapter topics that they reference. Answers to even numbered problems can be found at the author's Web site.

Overall, it's hard to find anything to complain about here that wouldn't sound inconsequential and trifling. No mistake, this is a big book: Part V alone (command reference) is a volume in itself. But I can't see anything extraneous or non-essential here. The author combines all the important features and tools together with the appropriate and necessary references.

Sobell has compiled an extensive volume that both newcomers to Linux and experienced users will find extremely useful. Once in hand, A Practical Guide to Linux Commands, Editors, and Shell Programming becomes not only a complete tutorial but also an invaluable resource that will be referenced time and again. This is as close to a textbook as you can get without being tormented by dry sterile language; Mark G. Sobell clearly has a command of his subject and he exudes a passion that infuses his writing and clearly elevates this book above any mere manual. This will become a standard and as such, a "must have" for anyone serious about learning command line scripting.


You can purchase A Practical Guide to Linux Commands, Editors, and Shell Programming from bn.com. Slashdot welcomes readers' book reviews -- to see your own review here, read the book review guidelines, then visit the submission page.
This discussion has been archived. No new comments can be posted.

Linux Commands, Editors, & Shell Programming

Comments Filter:
  • by SlashdotMirrorer ( 669639 ) on Wednesday October 26, 2005 @03:24PM (#13883334)
    Any bearded terminal hacker will tell you, when asked about the book they learned from, that while they went from one book to another in their early days, the most productive thing they ever did was learn how to read the documentation already available to them. This includes man pages, changelogs, posts to dailydave, and source code. A lot of people completely neglect these wonderful sources, and even go so far as to reinvent the wheel writing their own guides (see early Mandrake and Redhat releases).

    Someone should write documentation on how to read documentation (especially source!)!
  • Why buy the book? (Score:2, Insightful)

    by MLopat ( 848735 ) on Wednesday October 26, 2005 @03:30PM (#13883380) Homepage
    Why would anyone spend the money on this book?

    The information presented in it is freely available all over the web, often with more insightful examples, tutorials, etc. I just don't see the justification in spending x dollars on a book when a simple google search will yield a better result for free.
  • by hildaur ( 86126 ) on Wednesday October 26, 2005 @03:41PM (#13883475) Homepage
    Google searches (and online documentation found by other means) are great for finding details about stuff you already know exists. They stink at helping you discover really useful tools it never occurred to you might exist.

  • by MyIS ( 834233 ) on Wednesday October 26, 2005 @03:43PM (#13883490) Homepage

    I know a lot of people that would prefer a physical book over online docs anytime. The key difference between the manpages and a guide like this is how the latter places everything into some sort of context. That is, a novice would get a much more useful "bird's eye" view of the available toolset by reading a guide on Unix user management as opposed to directly researching manpages for adduser, passwd, finger, etc. Mind you, I love reading manpages, but I think I could have saved a lot of my own learning time back in the day, if there was a nice tutorial nearby and I wasn't so stubborn to do things the hard way.

    Of course, manpages are impossible to avoid in day-to-day work, but a good guide is invaluable as a kick-start.

  • by clintp ( 5169 ) on Wednesday October 26, 2005 @03:52PM (#13883555)
    Any bearded terminal hacker will tell you
    Except that many modern systems that would like to call themselves Unix (or Unix-like) don't ship man pages. They ship info pages.

    Garbage. Blasphemy of the highest order.

    Shaved the beard in '98, but have been hacking Unix since '85.
  • by DonVino ( 925697 ) on Wednesday October 26, 2005 @03:54PM (#13883572)
    Because sometimes I like it to read about something ordered and structured. And maybe there are things in this book, that you don't google that fast or maybe you find a tool, that you wouldn't have found with google - or maybe just not that fast.

    - often with more insightful examples, tutorials, etc -
    I you need more insightful examples, you can still google for it, but for a first impression this should be enough.
  • by Shadow Wrought ( 586631 ) <shadow.wroughtNO@SPAMgmail.com> on Wednesday October 26, 2005 @03:58PM (#13883604) Homepage Journal
    I'm considering it because I'm new to Linux and my home computer is not hooked up to the internet. Using Google means either running back and forth to the other computer or finding answers during lunch. Sitting down with an actual book is still a handy thing, and will continue to be so, regardless of how helpful google can be.
  • by $RANDOMLUSER ( 804576 ) on Wednesday October 26, 2005 @03:59PM (#13883613)
    I do have an answer for this. I have two 3-inch binders full of man pages for the shell, awk, lvm, ioscan, etc, etc. Every single hardware-related thing, no matter how arcane, and every commonly used thing I can't remember all the arguments to. Normally they sit at my desk, but they always go with me for my bi-annual trip to the off-site disaster recovery center. One of the lessons I learned a long time ago is you have to have a machine running to use the on-line help. When the box is casters-up, you're on your own.
  • by sumdumass ( 711423 ) on Wednesday October 26, 2005 @04:07PM (#13883679) Journal
    I would buy it. If nothing else then a reference when the internet os dopwn and i cannot quite remeber/figure somethign out. Saveing web docs and then viewing or p[rinting them to be viewed elsewere sometimes doesn't cut it.

    I remeber a time not so long ago when i was trying to script a simple "run after this happens " dialog to search the logfile and determin if it was a simple restart a service or if something needing more attention and then email different people based on the responce. I was on a production server without internet acess and it turned i just spelled a couple commands wrong and threw a couple switches in an incorect order. A reference book like this would have made it real easy to figure out. This is especialy true when after thinking about it, i remember having to sit and and think about the commands i had problems with for a while before i eventualy used them.

    Learning from the internet is fine. Having a book in type that doesn't hurt your eyes for reference and refresher reading is worth a couple $. I would say that it might be even worth a couple hundred $, (if it is spread out over several books.).
  • by myvirtualid ( 851756 ) <pwwnow@nOsPaM.gmail.com> on Wednesday October 26, 2005 @04:11PM (#13883707) Journal

    The parent makes two points: 1) that us terminal hackers went from book to book while they learned, and 2) that the documentation already available was where they learned the most.

    Re #2: No argument there, the information that comes with a well-documented UNIX is the best way to achieve wizard or guru knowledge levels. Not quite so well suited for getting as far novice, though: A lot of the man pages - at least back in the day - were written by experts who assumed the reader was close to expert, or at least was a C coding system hacker. Like it or not, not all of us were. C coder? Yes. Sysadmin? Eventually? Kernel hacker? Nope. Library hacker? Only at gunpoint. Shell hacker? Oh, yes, please anytime.

    How does one climb from naive to novice to comfortable to proto-admin, how does one get to the point that some of the denser available material starts to be beneficial, rather than a poor imitation of nethack? You are in a twisty maze of man pages, without doors or windows, and your dog has died....

    Context, and clear and lucid introductory material. That's the starting point. That brings us to...

    ...point #1: Bounce from book to book? Not so, this terminal hacker. When a job change took me from system 370, where I could hack REXX and JCL with the best of them, to UNIX, where I do better than hold my own in sh and sed, with a little awk/nawk/gawk thrown in, I sat down with one book. Just one. Sobell's Practical Guide to the Unix System. That's all it took: Three days of working through SunOS (3.?) and HP-UX (6.5, yikes) with that on my lap, and I had found my home! UNIX, beloved UNIX.

    After Sobell, I was ready to tackle the man pages and get some value.

    So am I going to buy this new tome? Well, let's think about that description: tome. Why is the Linux Sobell so much fatter than the UNIX Sobell was?

    Beware, flamebait: Possibly because some much of the information available with most distributions is so poor! Man pages that refer to info, and info pages that repeat the man pages word for word, save for the reference to info! Laughable, absolutely laughable.

    And, yes, as others have pointed out, there is much information available on the web. Where to start? And how to tell wheat from chaff? Context....

    Which brings us back to the Sobell Linux tome: Yes, I will more than likely by it, and I'll bet I'll recommend that others do, because my guess is that it will provide the one thing that all us Linux-proto-admins and Linux-proto-hackers need to get started and to start making sense of what's out there: Context.

    By the looks of the review, Sobell's provided plenty.

    Mr. S, hats off for doing it again, and thanks.

  • Re:vim vs emacs? (Score:5, Insightful)

    by VolciMaster ( 821873 ) on Wednesday October 26, 2005 @04:29PM (#13883880) Homepage
    apparently he doesn't believe in listing alphabetically, then :)

    Yes, I'm an emacs user. I can also use pico when nothing else is available.

    As religious as the emacs v. vim wars get, the real point is whether or not you can get the task done with a tool. I've met people who were really, really good at using pico, equal to my level of comfortability with emacs. I've met vim users who are really efficient. And I know lots of people, like myself, who are quite productive in emacs.

    Whatever tool you use, if you can be productive, ie get the job done in the specified time-frame, I honestly don't care what editor you use. That's the cool thing about having lots of editors to choose from, you can pick the one that fits how you think.

    I think in emacs. One of my best friends thinks in vim. We're equally productive in our environments, which is what really counts.

  • by wuice ( 71668 ) on Wednesday October 26, 2005 @04:31PM (#13883889) Homepage
    Please get off your high horse. A book puts stuff together in a way that someone with no prior experience to a subject (who doesn't really know what to "google" for, and would like a comprehensive guide to a subject instead of trolling for a dozen links.

    What I hate about comments like these is that they're almost always bragging in a thinly-veiled way... "*I* figured it out on my own, why can't time-strapped IT professionals do the same?" The answer is the time it would take to compile such a comprehensive resource is worth MORE to some people than the price of the book. Books also tend to have a more comprehensive goal in mind (ie, you build on what you learned in the last chapter), whereas most websites and HOWTOs are atrocious resources except for the individual task the websites is dedicated to. Also, books tend to be written by professionals, editied by professional editors, as opposed to random people spewing on the net. My experience is that googled examples tend to be much less insightful, more likely to be contradictory, tutorials thrown together, etc.. In the OSS world especially, so populated by hackers, documentation that makes sense to non-hackers is very low on the list of priorities.

    If you learned this stuff with nothing but google and loads of spare time, congratulations, give yourself a gold star.
  • by John Whitley ( 6067 ) on Wednesday October 26, 2005 @04:39PM (#13883955) Homepage
    In all fairness, this isn't the *nix distributions that are at fault: it's the upstream software developers. Aside from a few valiant distro package maintainers, all docs seem to come from upstream these days. I totally agree that info pages used to suck rocks, mostly because they seemed to be an excuse for really sparse documentation encased in really bad hypertext. Fortunately, the quality of the documentation (and the hypertext organization) has improved considerably over the years...

  • by mrogers ( 85392 ) on Wednesday October 26, 2005 @04:45PM (#13883995)
    Most man pages are references, not tutorials - reading the bash manual page is a horrible way to learn shell scripting.
  • by Cheapy ( 809643 ) on Wednesday October 26, 2005 @04:47PM (#13884018)
    What about us people who don't know what commands do what? Man pages are fairly useless if you don't know which command to ask for.
  • No Korn? (Score:3, Insightful)

    by hal2814 ( 725639 ) on Wednesday October 26, 2005 @04:51PM (#13884055)
    What kind of namby-pamby shell scripting tutorial goes over BASH and TCSH scripting and leaves out Korn?
  • Re:Tutorial? (Score:3, Insightful)

    by Breakfast Pants ( 323698 ) on Wednesday October 26, 2005 @05:37PM (#13884408) Journal
    Programmers use these editors almost every day of the year. On some days their very existance is manifested in the context of the editor for the entire day. To say that a shallow learning curve is the most important features a programming editor can have is flat out insane.
  • by Anonymous Coward on Wednesday October 26, 2005 @06:04PM (#13884622)
    Oh christ, someone needs to drag info out back and shoot it. I tend to forego documentation in favour of trial and error rather than struggle to remember how to navigate that awful heap of junk.
  • by IntlHarvester ( 11985 ) on Wednesday October 26, 2005 @10:35PM (#13886318) Journal
    I don't understand this argument at all. You pay RedHat and SUSE good money for packaging. If something about the packaging sucks (docs are an inconsistent mix of info, man, html, and text), you expect them to fix it and not shrug their shoulders and point upstream.
  • Re:Tutorial? (Score:3, Insightful)

    by drinkypoo ( 153816 ) <drink@hyperlogos.org> on Thursday October 27, 2005 @12:21AM (#13886835) Homepage Journal
    Last time I looked (I try not to mind you) emacs did have the kitchen sink. Regardless emacs and vi both have purposes. First of all, emacs is not an editor. If you were expecting an editor, and you ran emacs, you did not get what you wanted at all. Emacs is a common LISP environment. Second, vi is old and fast. More importantly vi came from ed, and ed is a sort of cross between sed and an editor. The creator of vi has gone on record saying that if he knew vi would become so popular, he would never had written the thing, but personally I love vi because it is both fast and powerful. Also, if you need integration of some sort with vi, vim has a quite healthy scripting interface.

    If you want an editor, get an editor. Incidentally vim can be run in a stupid mode where it doesn't use standard vi style modality. You edit, and if you want to issue a command, you hit escape and type it. Most any vi these days will work with arrow keys, too. Finally, vim has a GUI version (gvim) which lets you do pretty much everything from a menu, but shows the keyboard shortcut in the menu, which can help you learn to use vim's more esoteric features. vim is my favorite editor on any system, I use it in braindead mode on windows using gvim and I get all the pretty-printing etc that I want, while using a purely GUI-style app.

New York... when civilization falls apart, remember, we were way ahead of you. - David Letterman

Working...