UNIX Power Tools

Using the shell interactively is becoming a bit of a black art.
  • Authors: Jerry Peek, Tim O'Reilly and Mike Loukides

  • Publisher: O'Reilly & Associates

  • E-mail: info@oreilly.com

  • URL: http://www.oreilly.com/

  • Price: $59.95 US

  • ISBN: 1-56592-260-3

  • Reviewer: Samuel Ockman

The second edition of UNIX Power Tools is an impressive book by any measure. Numbering a hefty 1073 pages, it covers shells, editors and tools such as AWK, sed and RCS. The primary authors are Jerry Peek, Tim O'Reilly and Mike Loukides, but the book is made up of hundreds of individual articles by many different people, including UNIX luminaries Tom Christiansen and Simson Garfinkel.

UNIX Power Tools supplies many hints on how to save typing time by teaching you how to better use your shell interactively, how to take advantage of your editor and how to program scripts.

Using the shell interactively is becoming a bit of a black art. Luckily, UNIX Power Tools covers everything you need to know about this subject. Here are a few examples from the book to give you an idea of what it covers. First, here is how to edit three existing files: afile, bfile and cfile:

emacs [a-c]file

Many people already know how to do this; however, it works only if the files already exist. Lesser known is what to do if the files don't already exist. In this case, you edit all three at once by using:

emacs {a,b,c}file
With this information, it's easy to figure out how to make backup files:
cp filename{,.bak}
This command will copy the filename to filename.bak. Here's how to use this same idea to print six files or more:
lpr /usr3/hannah/training/{ed,vi,mail}/lab.{ms,out}
Are you confused by the find command? You won't have any problems after reading Chapter 17, which has 24 pages devoted to find. File permissions and processes are also covered in depth in their own chapters. Even wild cards get their own chapter. Whole chapters are also devoted to printing, terminal and serial line settings. (The book includes a great explanation of termcap and terminfo.)

vi is given two large chapters, while Emacs is relegated to being “the other editor” and given a scant ten pages. The vi coverage probably includes everything you'll ever need to know about it, while the Emacs section basically covers a few timesavers and the most essential commands, such as:

ESC-x psychoanalyze-pinhead

Missing from the book, though, is my favorite Emacs amusement:

ESC-9 ESC-x hanoi
The important thing to keep in mind is no matter what level of UNIX or Linux expertise you have now, you can learn much more. Some of the hints are beginner-oriented, but some may have even the most experienced user saying, “Hey, I never knew that...”

Here's a question for you. How do you run a program, while routing the standard error through a pipe to the mail program and leaving standard output on your screen under a Bourne shell? The answer is simple:

(program 3>&1 1>&2 2>&3 3>&-) | mail ockman &

Although bash and tcsh get special mention (as well as the more generic Bourne shell family and csh), the most powerful shell, zsh, is left out. Since so much of the book is devoted to shells, this is bothersome. Anyone who is really interested in having the most “power” will choose zsh. Still, since zsh is largely a superset of the other shells, almost all of the tips are still helpful.

sed is covered fairly extensively, and awk is covered sufficiently. Besides, in my opinion, all you need to know about sed and awk these days is that you use s2p and a2p respectively to translate your code to Perl. Speaking of Perl, the book has a few essays on why you should learn Perl, but offers no real help in doing so. It does offer the good recommendation of buying other O'Reilly books on the subject.

This book also does not cover networking or the X Window System, but that's good, because it leaves space for more important things. Nor, unfortunately, does it particularly make mention of Linux, although almost all information in the book holds true for Linux.

The book includes a CD-ROM of programs. Many of these programs are probably already installed on your Linux system, but you'll find quite a few others that will be useful. All of the programs are discussed in the text of the book. The CD includes source code and binaries for both Intel Linux and a handful of UNIX platforms. It does not make it clear which license the various programs fall under.

UNIX Power Tools is highly recommended. It's yet another amazing book from O'Reilly. After digesting all one thousand pages, you will be a wizard on the command line.

Samuel Ockman owns Penguin Computing (http://www.penguincomputing.com/). He spends all his free time rattling on about how great zsh is. His forthcoming book Super Advanced Programming in the Linux Environment is in the very early planning stages. You can e-mail him at ockman@penguincomputing.com.


One Click, Universal Protection: Implementing Centralized Security Policies on Linux Systems

As Linux continues to play an ever increasing role in corporate data centers and institutions, ensuring the integrity and protection of these systems must be a priority. With 60% of the world's websites and an increasing share of organization's mission-critical workloads running on Linux, failing to stop malware and other advanced threats on Linux can increasingly impact an organization's reputation and bottom line.

Learn More

Sponsored by Bit9

Linux Backup and Recovery Webinar

Most companies incorporate backup procedures for critical data, which can be restored quickly if a loss occurs. However, fewer companies are prepared for catastrophic system failures, in which they lose all data, the entire operating system, applications, settings, patches and more, reducing their system(s) to “bare metal.” After all, before data can be restored to a system, there must be a system to restore it to.

In this one hour webinar, learn how to enhance your existing backup strategies for better disaster recovery preparedness using Storix System Backup Administrator (SBAdmin), a highly flexible bare-metal recovery solution for UNIX and Linux systems.

Learn More

Sponsored by Storix