Configuring A Unix Working Environment


Table of Contents

1. Introduction To The Unix Environment
2. Altering Environment Variables
2.1. CSH
2.2. SH
3. Installing Software
3.1. Installing From A Pre-packaged Medium
3.2. Installing From Sources

When a Unix system starts up a series of scripts are run which set the operating system up, eventually the user will be presented with the familiar login prompt or equivalent. Upon logging in some script(s) are executed which set up the working environment. The particular script(s) executed will depend on the default shell.

A Unix shell is an interface for controlling a Unix system. There are quite a few different shells out there, some of them have similar syntax', some of them vary in their syntax'. The most commonly used Unix shells are SH(Bourne SHell), CSH(C SHell), RSH(Restricted SHell) and KSH(Korn SHell). It is very likely that at least one of these shells will be available on the Unix system you are using. There are also a number of other shells available to the Unix user such as BASH(Bourne Again SHell), TCSH(Enhanced C SHell) and ZSH(Z SHell).

I am not going to go into depth about the various merits of using one shell over another, this is already covered in detail at http://www.nscp.umd.edu/shells.html or alternatively in the FAQ posted to the newsgroup comp.unix.shell monthly, also a place where you can discuss the idiosyncrasies of Unix shellism to your hearts content.

You can find out what shell you are using by issuing the commands

echo $SHELL

. If you are using CSH or some variant the scripts executed at login will be .login and .cshrc these are situated in the users home directory described by the HOME environment variable which will be explained later. If you are using SH or some variant the script executed at login will be .profile. Any settings in this/these file(s) will effect the user whom owns them. The file(s) is/are used to setup the working environment for the user who owns them. If you start a new shell from within another shell, the new shells startup files will be executed. In addition, if you are using CSH .cshrc will be executed every time a further instance of CSH is invoked.

The environment contains variables called environment variables which contain information that is useful or essential for the Unix operating system to function as the user expects it to. An example environment variable is the PATH environment variable which contains a colon separated list of directories indicating where the Unix operating system expects executable programs to be found. When a command is typed into the shell, the Unix operating system will search through the directories listed in the PATH environment variable in the order they occur until it either finds an executable matching the command typed or fails to find a match. A few other examples of environment variables found on the Unix operating system are listed below:

  • EDITOR: Specifies the default editor.

  • PWD: Specifies the current working directory.

  • USER: Specifies the current user.

  • SHELL: Specifies the default shell.

  • RANDOM: Contains a random integer which changes each time the variable is referenced.

[Note]Note

TCSH uses the configuration file .tcshrc instead of .cshrc

There are generally two ways of installing software on Unix:

RPM (RPM Package Manager) is an easy to use package management system under the GPL license. The homepage is http://www.rpm.org/. An RPM search engine can be found at http://rpmfind.net/. It is only necessary to know a few simple commands to use RPM:

rpm -i somepackage.rpm

Installs the package specified.

rpm -e somepackage

Removes the package specified.

rpm -i ftp://blah/blah/blah/somepackage.rpm

Installs an RPM from some URL.

rpm --help

Displays the builtin help.

Additional help for installing RPMs can be found at http://www.rpm.org/RPM-HOWTO/. If you are using FreeBSD, you can benefit from using the ports system, explained at http://www.freebsd.org/ports/index.html.