5. Support of the shell

5.1. What is a shell?

A shell is the interface between you and the computer's operating system. Essentially, it's a program which executes any commands you input and prompts you again when it's done. The DOS prompt you see on most PCs is an example of a shell. Unix shells also function as a high-level programming language, which can be used by more advanced users. There are many different types of Unix shells (sh, csh, bash, ksh, tcsh...), but the nuances between them are generally only important to advanced users.

5.2. What does that 'Ding' thing mean?

Like any other clock, the shell clock dings every hour, if you have it configured to do that. By default it's not going to ding.

5.3. What are some of the commands I can use to navigate?

ls, ll and la give you different listings of your files, cd works like in DOS.

In entering filenames and paths, there's a shortcut you can use. The [TAB] key will help. For example, the following key sequences are the same:

  • cp /usr/local/bin/xwin-povray /tmp/
  • cp /u[tab]loc[tab]bi[tab]x[tab] /tmp
As you can see (practice helps), the shell checks to see what files/directories you're most likely to be typing, and completes the path for you.

5.4. How do I see who's online?

Type "finger | more" or "w -f" or "users". Each is a differently formatted list of users online, pick one that suits your personal preference.

5.5. How can I write a batch file, or set up an "autoexec.bat" for my account?

UNIX handles 'batch files' a little differently than DOS, starting by the name - they're called shell scripts here. Basically, any text file containing a list of commands is a script like in DOS, with a few subtle differences. First, the first line of the script must be "#!/bin/sh" Also, you must make the file executable by typing "chmod 755 scriptname"

To run the script, you must type in the path as well as the filename. The easiest way to do this if the script is in your current directory is "./scriptname" or if it's in your home directory and you're somewhere else, "~/scriptname" will do the trick.

To make your script excecute whenever you log in, create a file (with PICO or whatever) called ".cshrc" (Unless you've changed your shell, in which case you're smart enough to figure this out yourself) and on the first line put "./scriptname"

You can have the script output certain variables as well, for example:
echo "Hello, there, $USER"
will say hello to you. For a list of variables and such, type in "setenv".

If you plan on having a number of executable files, it would make good organizational sense to put them in a ~/bin direcotry, and add that directory to your personal path.

5.6. How do I add a directory to my path so I can execute the files in it?

Say you wanted to add your own bin directory to the path: in your .cshrc file, add the line "set path = ($path ~/bin)" and save it. Then, to make the change take effect, type "source .cshrc" or log out and log back in again.

5.7. What is my home directory?

When you login to your account via SSH (or programs like WinSCP) you end up in your home directory by default. It is likely /home/users/username and is sometimes abbreviated as ~ or $HOME.

The tilde can be used in commands like "cd ~" which will take you back to your home directory. The $HOME version can be used in scripts like "cp $HOME/public_html/* $HOME/backup". You can print the path to your home directory by running "echo $HOME".

5.8. Whare are environment variables?

The shell automatically sets up some variables whenever you login. For example, the $HOME variable is set to be the path to your home directory. Environment variables can be accessed through scripts by prepending them with a dollar sign and they can be modified by assigning new values to them. The following example changes your path to include a personal bin directory:

The following is how you'd print the current PATH:

   echo $PATH