Many users regard the UNIX operating system as dull and boring, but to systems programmers it is rich in arcane lore . Although much of this faded as UNIX moved from academia and research labs to corporate machine rooms, enough remains for an astute user to discern the attitude, humour, and occasional bizarre behaviour which characterize its origins and set it apart from committee-designed mainframe operating systems. I will demonstrate these characteristics with programming examples and reference key publications which helped shape UNIX culture.

UNIX was written in a computer language called C and most UNIX systems programming is still done in C. C and UNIX are ideally matched; both are compact, obtuse, fast and dangerous. Even after being tamed by the American National Standards Institute (ANSI C), C is still unpredictable. ANSI C defines statements which are legal but have undefined behaviour. For example, the statement a = a++j, while a bit silly, may either increment the variable a by 1 or leave it unchanged. Both interpretations are standard! In practice, its value will be compiler dependent which leads to problems when porting code between computers. Even the simple concept of an array is unclear in C. Anderson and Anderson, in their book Advanced C Tips and Techniques (Hayden Books, 1988), have a heading There's No Such Thing as an Array Reference. Here they illustrate this with an array a being referenced by an integer i. a then refers to the i-th element of the array a. However, C also requires the apparently inconsistent statement i. [a] to refer to the same entity. C's reputation for obtuseness has become legendary, leading to the annual Usenet Obfuscated C Contest. A typical entry, submitted by Applin and Heckendorn in 1985, contains the statement "( !!C) [*cl&&(v—I I—c&&execlp(*c,*c,c[!!cl+!!c,!c» ;" in a program which prints "Hello World."

Recall that UNIX includes at least one shell, a program which interprets users' commands. It should come as no surprise that shells are generally written in C. which may account for their peculiarities. The standard shell is called the Bourne shell, after its author David Bourne. However, some hackers prefer the C shell, written by Bill Joy, because of its C-like features. The C shell's many quirks led Tom Christiansen to post the Usenet article Csh Programming Considered Harmful. The title is itself a spoof on the earlier paper Goto Considered Harmful, written by the famous computer scientist Edsger Dijkstra (Communications of the ACM, 1968). Mr. Christiansen discusses and illustrates shortcomings and bizarre behaviour of the C shell. For example, he contends that the command time | echo, "while nonsensical, shouldn't give me this message: Reset tty pgrp from 9341 to 26678." Many people have attempted to improve on the Bourne and C shells. In particular, the Bourne Again Shell has acquired a loyal following. Although there is a possible standard emerging in the Korn shell, written by David Korn, ma y hackers shun it as a bondage-and-discipline shell suitable only for mainframe users.

Although user s can often bypass the system shells, they must still contend with the standard UNIX commands. Knowledgeable hackers like these commands, not jus t for their power and flexibility, but because their cryptic nature endows the hacker with an almost magical aura. The soubriquets guru, wizard, master, and god are often sought by hackers because of the implied mastery of the operating system. A side effect of the commands' nature is to in crease the probability of error. This, combined with the underlying UNIX philosophy of putting power in the users' hands, can be dangerous. When run from the root account, the command rm -rf /tmp/* will delete the contents of the /tmp directory while rm -rf / tmp/ * will delete the entire contents of the file system including the operating system itself, and may attempt to destroy files on networked computers. The only difference between the commands is the latter's additional space after the first /. System administrators who spend a lot of time working from the root account occasionally crack under the constant stress imposed by this environment and developed elusions of grandeur. Should this happen, it is best that users maintain a low profile until these pass, especially if the administrator has been seen reading the BOFH (Bastard Operator From Hell) series. Written by Simon Travaglia, these depict a sadistic operator with supervisor privileges doing nasty things to users. Although crude, reading these can provide a safe way for frustrated system administrators to blow off steam at the end of the day.

UNIX commands generally have a common format, with arguments specified following a dash as in Is -1. The commands are usually short, often having only two characters. Common commands include Is (list files), rm (remove files), and cd (change directories). Some commands defy the norm and reflect their author's individuality. The dd command's arguments are in the form if= and of=. Rumour has it these are a spoof on a particular mainframe's operating system. Some arguments are unexpected as in the -k (kidding) option to shutdown in some older implementations. When it is specified shutdown prints dire warnings about an impending system shutdown, but doesn't actually shut down the system. The -P option is common with network interface commands to control the interface's promiscuous mode. The spell command has a -b option to invoke the British dictionary. However, some man pages list as a bug the fact that the British dictionary was implemented by an American. These are but a few of the cultural artifacts left over from UNIX's origins.

I hope I have given you a taste of UNIX and its lore. Those interested in learning more can find most of the articles mentioned here on the WWW. Csh Programming Considered Harmful is also reproduced in UNIX Power Tools by Peek, O'Reilly, and Loukides (O' Reilly & Associates, Inc.) along with a large number of UNIX tricks and tips. For serious hackers I highly recommend the lexicon The New Hacker's Dictionary, edited by Raymond (MIT Press). Starving students and techno-geeks with Internet access can get it for free as the Jargon File but will miss Guy L. Steele Jr's Crunchly cartoons. These alone make the book worth its cost.



Share This Column