Back to 212 Main Page

Mobius strip

Fixing your PATH variable

If you try to run either emacs or make and you get the following (or similar) message:

bash: emacs: command not found

it means that the command you've tried cannot be found in any of the directories listed in your shell's PATH variable. (You get this same message if you try to run a.out when the current directory is not in your path.)

To check, type:

echo $PATH

You should see something like this:


You need to have /usr/uh/bin in your PATH to run emacs, /usr/ccs/bin to run make, and /opt/SUNWspro/bin to run CC.

Quick Fix

If you are running the bash shell (those of you who had me for 211 probably still are), you can just copy my .bashrc file again:

cd ~
cp ~ztomasze/.bashrc .

(The first command just makes sure you're in your home directory.) Login again after doing this and the problem should be fixed.

Long Way

If you're interested in seeing how these things work, you can edit your PATH variable yourself. First figure out what shell you're using based on what your prompt looks like when you first log in:

My prompt...ShellConfig file
$ sh (Bourne Shell).profile
(or something ending in a $)
bash (Bourne Again Shell) .bashrc
uhunix2:/home/27/ztomasze% csh (C Shell)
[The uhunix default]
uhunix2:/home/27/ztomasze% tcsh (An extended C shell).cshrc (or .tcshrc)

(If you can scroll up through your previous commands by using the up arrow, you're using either bash or tcsh.)

Open (using pico, emacs, or your favorite editor) the config file corresponding to your shell. Look for where a PATH variable is initialized. Add any extra paths you need. You will need to login in again in order for your changes to take effect.

SIDENOTE: Remember that the order is important--your shell will look for programs through the paths in the order specified. For this reason, you never want to put the current directory (./) first. (Some say it shouldn't be included at all.) If you list the current directory first, you can imagine a situation where you wander into a strange directory and do an ls to find out what is there. If the owner wrote a script (or program) named ls and left it in that directory, that version of ls would run first. This could be very bad for you if this strange version of ls contained the line rm -rf ~/*. (This would delete every file in your home directory and all subdirectories.) So, as always, just be careful you don't go around running strange programs (even accidently).

Finding the proper path for a program

In order to add the correct path to your PATH variable, you need to know where a certain program is located. You can use the find command. (See the man pages on find for more.)

Or, what I do on uhunix, is switch back to C shell, use the which command, and then exit back out of C shell:

which emacs

Here I learned that, in order to run emacs, I need to have /usr/uh/bin in my PATH. This method works because csh is the default shell on uhunix, and so the PATH is correctly configured for all the major programs. (Configuration files for other shells may not be optimally configured.) You can wander around on uhunix and find other programs that are not included in the PATH and add those to your PATH as well.

~ztomasze Index : TA Details : ICS212 : Emacs Path
Last Edited: 05 Nov 2005
©2005 by Z. Tomaszewski.