May 19, 2011, 8:01 p.m.
posted by juff
Now that you have figured out which general variety of UNIX you have, you must figure out one other vital consideration: which shell you’re using. You may say, “I don’t want to use any shell; I just want to get some work done,” but the shell is the only way to get to where you want to be.
The guts of UNIX are buried deep in the bowels of the computer. The guts don’t deign to deal with such insignificant details as determining what users may want to do. That nasty business is delegated to a category of programs known as shells. A shell is a program that waits for you to type a command and then executes it. From the UNIX point of view, a shell is nothing special, other than the first program UNIX runs after you log in. Because you can designate any old program to run when you log in, any fool can write a shell — indeed, many have done so. About a dozen UNIX shells are floating around, all slightly incompatible with each other (you probably guessed that).
Fortunately, all the popular shells fall into two groups: the Bourne (or Korn or BASH) shell and the C shell. If you can figure out which of the two categories your shell is in, you can get some work done. (You’re getting close!)
You can easily tell which kind of shell you’re using. If UNIX displays a $ after you log in, you have a Bourne-style shell; if UNIX displays a %, you’re using the C shell. Traditionally, System V systems use the Bourne shell, and BSD systems use the C shell. These days, however, because all versions of UNIX come with both shells, you get whichever one your system administrator likes better. Preferences in command languages are similar to preferences in underwear: People like what they like, so you get what you get, although these days most of the people we know like BASH, a souped-up Bourne-style shell.
Linux Linux systems usually come with the BASH shell, a Bourne-style shell.
After you determine whether you have a Bourne-style shell ($) or a C shell (%), note this fact on your Cheat Sheet in the front of this book.
Tip If you use a GUI (see Chapter 4), you see windows and icons, not a boring little UNIX prompt, after you log in. You still need to use a UNIX shell from time to time, however, usually to perform housekeeping tasks.
The most widely used UNIX shell is the Bourne shell, named after Steve Bourne, who originally wrote it. The Bourne shell is on all UNIX systems. It prompts you with $, after which you type a command and press Enter. Like all UNIX programs, the Bourne shell itself is a program, and its program name is sh. Clever, eh?
A few alternative versions of the original Bourne shell exist, most notably the Bourne Again shell (or BASH, whose program name is bash) from the GNU crowd. This version of the Bourne shell is used in many places because of its price — it’s free. Some people claim that it’s still overpriced, but we don’t get into that. BASH is enough like the original Bourne shell that anything we say about the Bourne shell applies also to BASH. The most notable advantage of BASH is that it has command editing, a fancy way of saying that you can press the arrow keys on your keyboard to correct your commands as you’re typing them, just as you can with DOS (oops, better not say that when any UNIX fans are listening).
After the Bourne shell was in common use for a couple of years, many people thought that the shell was so simple and coherent that a single person could understand all its features and use them all effectively. Fortunately, a guy named Dave Korn remedied this shameful situation, who added about a thousand new features to the Bourne shell and ended up with the Korn shell (called ksh). Because most of the new features are of interest only to people who write shell scripts (sequences of shell commands saved in a file), you can consider the Korn shell the same as the Bourne shell. Most versions of the Korn shell also have command editing.
No, the C shell wasn’t written by someone named C. It was written by Bill, the guy we mentioned earlier. (He sells C shells by the C shore? Probably.) We would discuss our opinion of the C shell at length, except that Bill is 6'4", in excellent physical shape, and knows where we live. The C shell’s program name is csh.
The most notable difference between the C shell and the other leading shell brands is that the C shell has many more magic characters (characters that do something special when you type them). Fortunately, unless you use a number of commands with names like ed!3x, these characters aren’t a problem.
Many versions of the C shell exist; most of them differ in which bugs are fixed and which are still there. You may run into programs called zsh and tcsh, two slightly extended C shells with command editing.