Using the Unix shell

by Ed Hurley

Shell overview

There are a variety of Unix shells out there, and the debate over which is best is really mostly a religious issue. Unfortunately they all differ just enough in their features and built-in commands that switching between them can be painful. If you know a shell now and feel comfortable with it; stick with it. If you don't, I'm not going to tell you which shell to use since that will only cause someone to flame me for giving the wrong advice.

That said, we've tried to provide you with all the most commonly used shells so that you can use what you want. In particular we have:

We will provide zsh as well, but at the moment installing it has taken a back seat to other matters. If you care about zsh send email to hurley@lcs.mit.edu and I'll
  1. push it up on the stack
  2. inform you when it's installed

Basic commands

You can think of the Unix shell as an interpreter (because it is). You type a command, hit <Enter>, it prints out the result of evaluating the command. To get started, here are a handful of commands which are extremely useful:

You can learn how to use each of these commands and interpret their output by doing reading their man page. (See below)

Documentation

The traditional Unix documentation consists of man pages. (No, that's not a sexist thing, it's short for manual). Anyway, you can get what information there is on a command by invoking
   username@hostname:[dir]% man 
If you're new to the man facility you should probably spend 5 minutes reading the man page on the man command itself. There are a few options which are important. The most important things you need to be aware of is the value of your MANPATH environment variable and the concept of sections. The man command will only search the directories it's told to to find something. Most Unices put their system man pages in the /usr/man directory. Additional packages are (in our case) either installed in /usr/local/man or /opt/gnu/man. By default all of the above should be in your MANPATH environment variable.

If you're trying to read a man page in some other location, you can use the "-M" command line flag to explicitly specify where to look. Also, man will take the first man page matching the specified name. So the order of directories in your MANPATH becomes important. Sometimes user added packages (e.g. Tcl) have command names which are identical to a shell command or function name. In that case, you can use the "-M" option to override your MANPATH.

Finally, you should be aware of the concept of sections. If you look in /usr/man, for example, you'll find subdirectories with names like man1/, man3/, etc. The number corresponds to a section. There is a standard for deciding in which section to put a man page, which you learn about by reading the man page on man.



hurley@lcs.mit.edu
Add a comment | Add a link