To change the "default" search path used every time you log in,
line in your
line in your
absolute pathname (
of the directory to the path.
You have a choice:
You can put the directory at the end of your path.
(I think that's the best idea unless you know exactly what you're doing.)
Then, commands in the directories you add will be used only if they have
that aren't found anywhere else in the path.
You can check that with a command like
If you put the pathname close to the start of the path, before
standard system directories
, then commands in the directory you add
will be used instead of system commands with the same name.
That lets you replace commands that don't work the way
you want with your own version.
For instance, if you had the
script that marks today's date (
it would be used instead of the
If you set your path this way, you should
be especially careful not to
accidentally give some random program the same name as a system command - article
explains how to check for that.
Also, be sure to make the directory unwritable by other users
)-so they can't add malicious programs with
the same names as system utilities.
Installing your own version of standard system commands (like
) at the front of your path has a serious consequence.
Many system programs and shell scripts will call a program like
and expect it to work just like the default system version of that program.
If you install a version at the front of your search path that behaves
differently, that can cause serious problems for an unsuspecting program.
For example, you might install a version of
that writes messages
to standard output like "Do you want to remove this file?" and reads
your answer from standard input.
The standard system
command won't prompt if its standard input
isn't a terminal.
If your custom
doesn't work the same way as the system
other programs that call
can mysteriously lock up while
they wait (forever) for your private
to get an answer to its prompt.
If you want to replace a system command, it's better to give your
version a different name.
When you log in, as your shell starts, before your setup files are read,
your system probably has already set a default search path for you.
Your system administrator can change that path.
If your system has a default path, you should think about using it as part of
your path - ask your administrator.
To do that, include the variable
as you set
For example, to add your
directory at the end of the system
path, use one of the following lines:
set path=($path ~/bin)
For Bourne-type shells, load the updated
by typing a command like:
For the C shell, type one of these commands, depending on which file you changed:
As you work, you might need to add a directory to your path temporarily.
For example, when I develop new versions of existing programs, I put them
in a separate directory named something like
I don't usually want to run the alpha-test commands - but when I do, I
directory to the front of my path temporarily.
(It's handy to set the new path in a
so it won't change the path in my other shell.)
Use the same path setting command you'd use in a shell setup file:
set path=(~/xxx/alpha-test $path)
shows another way to change your path:
command-by-command instead of directory-by-directory.