[wplug] $PATH variables

John Harrold harrold at sage.che.pitt.edu
Sun Oct 14 13:39:00 EDT 2001


hey doug.

in unix you use a shell. typically bash on linux. there are a series of
variables called environment variables. when you login these variables are
set by reading a series of files like ~/.bash_profile, /etc/bash_profile,
ETC. these tell bash and otherprograms you execute certain things like your
default printer, your editor of choice, your display. if you goto the
prompt and type 'export' with no argument it should list your environment
variables.  if you want to set an environtment variable you can do so in
the following
manner:

$export GOATNAME="bob"

now anyplace you put $GOATNAME the shell will substitute 'bob'.

so now you can type

$echo "my goats name is $GOATNAME";

there are some environment variables that are "special". they dont wear
helmets, but they are important. one of these is PATH. when you type a
command like 'ls', you dont want your shell to search through every
directory on the computer looking for a binary called 'ls'. so the shell
looks at the "PATH" environment variable for a list of directories in which
to look for 'ls'. PATH is a string of directories which are separated by a
colon. for example mine looks like:

PATH="/home/bin:~/bin:/usr/sbin/:/sbin:/home/bin:/home/bin:~/bin:/usr/kerberos/bin:/bin:/usr/bin:/usr/X11R6/bin:/usr/local/bin"  

the path is "built" using the rcfiles mentioned above. this allows the
system to set system specifc paths and the user to add its (politically
correct gender neutral) own paths. to add a directory to the path you can
add a line in the ~./bash_profile that looks like:


export PATH="$PATH:/my/new/path"

this will add /my/new/path to the end of the search path. somepeople think
"hey i'll add . to my path so i can execute commands in the current
directory". this is not a good idea because someone could put a file called
'ls' in the tmp directory which is a shell script that contains 'rm -rf ~'
or somesuch. so becareful.


Reply-To: wplug at wplug.org
To: wplug at wplug.org
Subject: [wplug] $PATH variables:

-- 
john
-dirt it's what we die for.






More information about the wplug mailing list