Linux Commands, Editors, & Shell Programming
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.
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.
/me secretly winks at author for placing the vim chapter first
http://zero-to-enterprise.blogspot.com/
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 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.
I thought zsh has now established itself as a popular alternative to the two shells in the book. Was it even mentioned in the book?
I have a water bottle on my desk. A telephone, that I never use, and a Fed Ex box.
So yea, I'm struggling here.
Thanks for the info Brian, I'll be sure to bring this up during your anual review.
-Charles
This sounds like a great book. I don't won't come across as being too negative but having been a Unix sys admin for nearly 10 years and having run Linux on a loptop as my sole OS for the past five years I think it's important for new folks to not rely too heavily on learning from books.
The great thing about Linux is that all the definitive documentation (including the source code) comes with the OS. It's good practice to get into the habit of using these docs.
Then again I appreciate that everyone has a different approach to learning.
vi is better
Are you...Are you some kind of genius?
No, ma'am, I'm just a regular Slashdot reader.
'cat' and 'echo' ought to be enough for anybody.
^D
... I wish I had the time and energy to learn all this, but I'd rather ask my linux geek (Obviously I am a geek too) friends to help me. How do I install the Mplayer plugin to firefox? (doing that crap always irritated me), istead of watching some good pr0n I had to unpack binaries, my balls and brain loathe you Linux (Not trying to be a troll, just kiddin')
public class null extends java applet { System.out.print ("Tabula Rasa"); }
I try to see people's point as to why they prefer books over technical docs, but I miss the point totally. You buy a book to learn about the computer you are using or the OS you are using? So where do you read it? In bed? I guess you could but it's not a story it's a book to teach you how to do something on the computer. So you'd be better off if you were in front of the computer while reading it. That way you can have hands on experience with the subject matter. If I'm sitting at the computer reading a book I may as well be reading the documentation or at least a PDF version of the book. Right?
Beer! It's what's for breakfast!
Did I miss anything?
no, i think that about sums it up.
also, i like the, er, pun in the title.
mrc
"Physics is like sex. Sure, it may give some practical results, but that's not why we do it." - R. Feynman
Oh my. That's what I call effective recycling of old material - or "How to create a book by copying and pasting from three of your previous books".
If the book is anything like some of the people I've tried to get help from it will contain one page with RTFM in giant bold letters and nothing else. People if you want Linux to grow you need to be more helpful to the less tech oriented people.
If you're a programmer who needs a tutorial to use an editor, the chances are good that the editor sucks. I love the Vi(m) vs Emacs arguments, because they are both highly unintuative editors that have an oddly steep learning curve where you really shouldn't need one. While I understand that many have some kind of strange love for these editors, I think it's misplaced. These editors were great when they were our only options for a powerful text editor, but they are outmoded by editors which do a far better job of doing what editors should do best: letting you edit text in an intuative and unconfusing manner.
BeauHD. Worst editor since kdawson.
What kind of namby-pamby shell scripting tutorial goes over BASH and TCSH scripting and leaves out Korn?
This has to be the longest slashdot article...ever.
Warning. This is NOT a Unix book. This is a Linux book. If you're looking for a quick reference on Unix commands, text editors and shell programming, so not make the mistake of getting this book.
It's only about Linux. It says so right in the title.
</sarcasm>
A Government Is a Body of People, Usually Notably Ungoverned
Presumably this book will tell me what console editor will edit OpenDocument files in a human-friendly way?
:v)
Won't it?
Vik
It was perfect for us because many of our users were using clunky old "textedit" on Sun boxes. The adaption time was instantaneous.
Under the GPL, it's also free, anyway you define it.
Congratulations on your Terrarium award, but the link on the Luna home page appears to be dead...
x
http://64.201.37.243/Terrarium/charts/default.asp
``Except that many modern systems that would like to call themselves Unix (or Unix-like) don't ship man pages. They ship info pages.''
You say that as if it is a bad thing. What's wrong with info manuals? The way I see it, info manuals offer useful extra features compared to manpages (hyperlinks!). I'd rather they shipped the docs as HTML and let me use my own browser instead of GNU info, but I don't see anything fundamentally wrong with info.
As far as the quality of info manuals is concerned (other posters have commented on that), I think that the info manuals for most GNU software easily beat the average manpage on that front.
Finally, I have to take issue with your statement that modern Unix systems ``don't ship man pages''. Every system I've worked with has manpages, and I rarely run into situations where I want to open a manpage and it doesn't exist. Seldom do I have to read any documentation besides the manpage to get the information I need, which attests to the quality of the pages.
Seriously, I don't see what you're complaining about.
Please correct me if I got my facts wrong.