Sponsored Links

Maxabout.com > Tips

Adding a directory to the PATH

Added on:8/22/2008 12:30:30 AM
In Linux Tips
 Rated by 1 users


  1. Commands that you type on the shell command line are searched in the directories listed in the PATH variable:
    echo $PATH

  2. When several directories contain a command with the same name (a bad situation), the first directory encountered in the PATH has priority. To find out the directory that contains the command that will be executed:
    which command

  3. To add a new directory 'newdir' to the PATH:

  4. If the shell is sh or bash (check with echo $SHELL):
    export PATH=newdir:$PATH

  5. Place these lines in the file '.bashrc' in your home directory to have the PATH set correctly the next time you open a shell.

  6. If the SHELL is tsch or csh:
    set path = (newdir $path)
    rehash

  7. Place these lines in the file '.cshrc' in your home directory, to have the correct PATH the next time you open a shell.


Sponsored Links
Tools
Bookmark/Discuss