Linux, Unix, /etc

Danger Will Robinson! You are now entering a condescending Unix user zone!
Sponsored links (requires javascript):

A Reading List for the Linux Newbie

2. More About Unix

While our first book contains a lot to guide you through the day to tday usage of your shiny new Linux installation, it really only scratches the surface. To understand Linux fully, you have to know that it's based on Unix. So, our next two books are the essential Unix books to have.

2.1. The Unix Programming Environment

This book was published in 1984, i.e. nearly 20 years ago. However, it remains the best single guide to the Unix idea.
What This Book Means To Me
This was the book that made me want to move to a Unix system — from Windows, OS/2, and, God help us, OS/400 in my case. Perhaps no-one who hasn't programmed extensively on other systems can realise just how programmer-friendly Unix really is. Try RPG on an AS/400 for size! Even without access to a Unix box, even just through reading this book, I knew that it was better than anything I'd been used to. Also, I wanted a command line, I've never liked GUIs; but COMMAND.COM just wasn't good enough.

What I read here convinced me that what I wanted was Unix. I chose Linux, a system not without differences from the Version 7 Unix described in this book, first published as it was in 1984, when Linux was still seven years in the future. The Unix Programming Environment was still relevant to me, the neophyte Linux user, in 1994; and it is just as relevant today, six years later. It is as useful for the Linux user as for any Unix user. There is still no better way of really understanding how to get the most from the tools available.

The Book in Outline
The book has 9 chapters, falling into four distinct sections: Unix, Shell, C, Document Preparation.
Unix
We begin, logically enough, with the chapter "Unix for Beginners". This packs a good amount of introductory knowledge into one longish chapter, and will repay several readings for the neophyte. Chapter 2 introduces the Unix file system: its basic structure, underlying concepts, and the commands that manipulate it. Outdated in parts, it remains a good general introduction.
Shell
Particularly useful are the shell chapters, 3-5. Here is the core of the Unix Philosophy, clearly and convincingly expressed. These three chapters provide a first-rate tutorial on effectively using and programming the shell. They need supplementing only by a good man page, and a bit of practice. The fourth chapter, on "Filters", is particularly impressive.
Filters
The concept of a filter is a key idea for anyone who wishes to use Unix effectively, but especially for the programmer. It is one that migrants from other operating systems may find new and unusual. So what is a filter? At the most basic level, a filter is a program that accepts input, transforms it, and outputs the transformed data. The idea of the filter is closely associated with several ideas that are central features of Unix: standard input and output, input/output redirection, and pipes.

Standard input and output refer to default places from which a program will take input and to which it will write output respectively. The standard input (STDIN) for a program running interactively at the command line is the keyboard; the standard output (STDOUT), the terminal screen.

With input/output redirection, a program can take input or send output someplace other than standard input or output — to a file, for instance. Redirection of STDIN is accomplished using the < symbol, redirection of STDOUT by >.

The pipe (|) is a junction that allows us to connect the standard output of one program with the standard input of another. A moment's thought should make the usefulness of this when combined with filters quite obvious. We can build quite complex programs, on the command line or in a shell script, simply by stringing filters together.

The combination of filters and pipes is very powerful, because it allows you a) to break down tasks and b) to pick the best tool for tackling each task. Many jobs that would have to be handled in a programming language (Perl, for example) in another computing environment, can be done under Unix by stringing together a few simple filters on the command line. Even when a programming language must be used for a particularly complicated filter, you are still saving a lot of development effort through doing as much as possible using existing tools.

Each tool on its own performs useful work. Used together, their power is magnified. By having several Unix tools cooperate, I've gained more control over my writing than I could possibly hope for using one monolithic program — such as any traditional word-processor. And that's what the Unix environment is all about.

The chapter is an excellent introduction to sed and awk in particular, but also covers the greps, sort, tr and others. A puzzling ommission is the m4 macro processor, surely the ultimate filter.

Some people find perl a panacea for this sort of "text-mangling", but to me it seems too big and complicated. I find I can remember how to do simple stuff in sed and awk more easily than I can with perl.

C
Two solid chapters on C programming, covering respectively using the Standard C library and Unix System calls, lead up to an excellent example of Unix C programming in practice. A complete system is developed, the hoc mathematical programming language, that also allows the authors to illustrate the usage of lex, yacc and make, all very useful Unix tools for programming development.

Someone who knows the basics can really pick up a lot of practical advice on developing solid C code from this part of the book. Certainly, I learned enough to fix minor problems with porting source to Linux: not much of an issue these days, but a few years ago it still happened quite often that a bit of tweaking was required even with source packages that had ostensibly been ported to Linux already.

Troff
The book shows its age most clearly in the last chapter, "Document Preparation", which is all about using troff, nroff, and their various macro packages. On the other hand, this chapter is invaluable simply for the clear and simple instructions on how to write a man page — anyone at the FSF reading?!
Reflections
Some things don't work quite the way they used to e.g. the little filters 2, 3 et al: but this is simple to fix. Someone changed $0 so it reports the whole path, not just the program name: 2 and co., given in the text as

pr -$0 -t -l1 $*

now look like this:

#!/bin/sh
pr -`basename $0` -t -l1 $*

Naturally, some modern tools are lacking. Perl hadn't been thought of back in 1984, for instance. The nearest we get to Internet tools is a bare mention of "bang paths" (the old UUCP-style method of addressing e-mail). And their idea of a "standard editor" is.... ed! No one could accuse me of being an MS-Word fan, but ed is a little too far in the other direction even for my taste. That said, a knowledge of The Standard Editor is a handy basis for using vi's ex mode; and even in this day and age, ed is the easiest editor to fit on a rescue disk.
Why This Book Is Important
For learning about Unix, there is no better guide. The book also has some more general lessons for us today. It hearkens back to a leaner, cleaner Unix. For example, we read: "All input and output is done by two system calls, read and write." Those were the days! Perhaps today's Unices are all too hairy: maybe the future lies in a brand-new system?

In conclusion, I must say that, despite being nearly 20 years old, an aeon in computing terms, this books retains much of its value for the present-day Unix user and programmer both. A must for any Linux book collection.

2.2. Unix Power Tools

While the rest of the world points and clicks in a scary little world of icons, all alike, we in the world of Unix get to use a good old-fashioned CLI, or command line interface. One reason why the command-line has remained so pervasive in Unix environments is that the implementation, the Unix shell in its various incarnations, is actually pretty damn good. However, one problem has always been getting enough information in suitable format to enable one to make the most of the shell's power and capabilities. Unix Power Tools admirably fills this gap. The book is an unparallelled source for the small everyday things that make using a command line interface so much easier — if you know them. And there's the rub: if you know them; but where to find them? Unix Power Tools is a compendium of this much-needed information, often culled from obscure sources. There are many gems from Usenet here — not a place one would go looking very often today for solid information of this kind.
What This Book Means To Me
I'd been running Linux for over a year before I bought this book. I fondly imagined I was pretty nifty with the old Unix Environment. Well, I learned different. The amount of stuff I picked up out of this book is incalculable. It is like an encyclopaedia for Unix users. I said "users", and that's important; you won't find any admin or networking stuff here. The former omission is only to be expected, but the latter is a pity— a brief tutorial on mail(1) wouldn't have gone amiss, for example. But, when you consider that the book runs to over a thousand pages as it is, you begin to understand. Every time I dip into this weighty tome, I seem to come up with something new. A case in point is pcal, which I discovered browsing one slow afternoon (when I should have been working on an article; but that's another story). Pcal is a program for generating Postscript calendars, with a rich command-language enabling the user to describe repeating events, one-offs, etc.
Outline of the Book
The TOC is too big to type up. There are nine main parts, each crammed with informative chapters. This is a browser's book, meant for dipping into; highly-structured, so that it bursts at the seams with cross references. Interesting "sidebars" take a closer look at syntax or point to other areas for exploration, including more technical details that might not be immediately apparent. It is also one big, heavy book, running to well over a thousand pages and 53 chapters. And yet, rather than the size being a hindrance, one wonders rather only how they managed to compress so much information into so small a compass. For there is no padding here. In a review of this length, I can't hope to do more than focus on a few areas that particularly impressed me.

The chapter on Regular Expressions is a superb introduction to this intricate field. It really tells you most everything you will likely need to know. The only place to go afterwards is Jeffrey Friedl's Mastering Regular Expressions.

The two chapters on vi are a mini-book in themselves: 50 pages of everything but the basics. For that reason, they aren't complete in themselves; but complement them with a useful tutorial [link] and you have all you need to know about vi, and then some.

In a way, the whole book is about the shell. But there are a couple of chapters dedicated to shell programming. These are very useful both for the beginner or the more advanced student.

The tail-end of the book has all the stuff they couldn't fit anyplace else! It's a rag-bag, but a useful one.

A CD-ROM is bundled with the book, containing all of the scripts and aliases described in the text, in addition to perl, GNU emacs, netpbm (graphics manipulation utilities), ispell, screen, the sc spreadsheet, and about 60 other PD and free software programs. In addition to the source code, binaries are provided for Sun4, Digital UNIX, IBM AIX, HP/UX, Red Hat Linux, Solaris, and SCO UNIX.

Why This Book Is Important
This is almost like a distillation of the knowledge a whole generation of Unix users. A lot of the material originated in Usenet posts (yes, there was a time when it was good for something). Everyone who has contributed in some way gets name-checked in the preface — the list runs to 38 names, including some O'Reilly well-knowns.

In a way, O'Reilly didn't do themselves any favours with "Unix Power Tools". I mean, you learn all you need to know about vi, sed and awk, to name but three, from this book — no need, therefore, to pick up copies of O'Reilly's tomes dedicated to just these tools — "Learning the vi Editor" and "sed and awk" respectively.

The book I know and love is the 1st edition. A 2nd edition came out in 1997. This brought some updated material: the blend of options and commands is slanted more toward the POSIX utilities, including the GNU versions; the bash and tcsh shells are given greater coverage (why they kept the C shell coverage at all is a mystery to me); and, Perl is given greater emphasis at the expense of awk (wrongly, in my opinion). One great lack in the 2nd edition is that it's printed in one colour, as opposed to the blue and black of the 1st edition. The latter looked really well, and it was a mistake to change it — I suppose the budget dictated otherwise, as it will. On balance, the 2nd edition is well worth buying new, but if you can get the 1st edition second-hand, that's just as good.

Another thing that's missing from this second edition is any mention of yours truly, despite that fact that I made two (count 'em!) contributions via bookquestions@ora.com. Hmm, perhaps they were crap. Oh, well. At leest I can rite reel gud.

From the user's point of view, for a more up-to-date and compendious approach than that of The Unix Programming Environment, Unix Power Tools can't be beaten. It's huge, and crammed full of helpful hints and tips. It has run to three editions, and unlike many computer books, any one of them is very useful. This sort of stuff just doesn't age. If you buy only one book about Unix this year, or ever, make it this one.

How To Get This Book
Title: Unix Power Tools
Author: Jerry Peek, Tim O'Reilly & Mike Loukides
Publisher: O'Reilly
ISBN: 0-679-79073-X; 1-56592-260-3
Price: £49.95; $59.95
Pages: 1129; 1073
Date: 1993; 1997
(details for both editions are given, 1st ed. first)

[back to Linux, Unix, /etc]



Copyright © 1995-2007 Paul Dunne,

Sponsored links (requires javascript):