PATH

From Hackepedia
Revision as of 09:15, 27 May 2006 by Franks (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

To see your current PATH:

$ echo $PATH
/usr/local/bin:/usr/bin:/bin:/usr/bin/X11:/usr/games

What this means, is if the application you're trying to run is in a directory listed in your PATH, then you don't have to type the complete /path/to/the/application. In this example, I'm trying to run a command called foo in /home/user/bin/

$ foo
foo: command not found
$ /home/user/bin/foo
Command Initialized, welcome to FOO!

but I don't want to have to type out /home/user/bin/foo every single time. How you set your PATH depends on your shell.

$ echo $SHELL

bash

$ echo $PATH
/usr/local/bin:/usr/bin:/bin:/usr/bin/X11:/usr/games

The long way:

$ export PATH=/usr/local/bin:/usr/bin:/bin:/usr/bin/X11:/usr/games:/home/user/bin/
$ echo $PATH
/usr/local/bin:/usr/bin:/bin:/usr/bin/X11:/usr/games:/home/user/bin/

The easier way:

$ export PATH=$PATH:/home/user/bin/
$ echo $PATH
/usr/local/bin:/usr/bin:/bin:/usr/bin/X11:/usr/games:/home/user/bin/


csh

$ echo $PATH
/sbin:/bin:/usr/sbin:
$ set PATH=/sbin:/bin:/usr/sbin:/home/user/bin/
$ echo $PATH
/sbin:/bin:/usr/sbin:/home/user/bin/