Your controls what directories - and in what order - the shell searches for commands. You can set a search path that takes effect every time you log in by editing your shell . You might also want to change the path temporarily.
Add theof 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 unique names 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 like /bin, 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 thein , 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
chmod go-w)-so they can't add malicious programs with
the same names as system utilities.
CAUTION: Installing your own version of standard system commands (like ls or rm) at the front of your path has a serious consequence. Many system programs and shell scripts will call a program like ls 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 rm that writes messages to standard output like "Do you want to remove this file?" and reads your answer from standard input. The standard system rm command won't prompt if its standard input isn't a terminal. If your custom rm doesn't work the same way as the system rm, other programs that call rm can mysteriously lock up while they wait (forever) for your private rm 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
$path as you set
For example, to add your bin directory at the end of the system
path, use one of the following lines:
 There's a small problem with this if you set your path in your .cshrc or ksh ENV file. Each time you start a, your bin directory will be added to the path again. That won't cause any errors but it will make the path longer than it needs to be. If you want to work around this, use an environment variable like as a flag - and set the path only if ENV_SET isn't set.
set path=($path ~/bin) C shell PATH=$PATH:$HOME/bin Bourne shell
For Bourne-type shells, load the updated PATH 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 alpha-test. I don't usually want to run the alpha-test commands - but when I do, I add the alpha-test 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)C shell $
PATH=$HOME/xxx/alpha-test:$PATHBourne shell $
Article 8.8 shows another way to change your path: command-by-command instead of directory-by-directory.