PATH: Difference between revisions

From Hackepedia
Jump to navigationJump to search
No edit summary
 
No edit summary
 
Line 14: Line 14:
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.  
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 ==
== bash ==


$ echo $SHELL
/bin/bash
  $ echo $PATH
  $ echo $PATH
  /usr/local/bin:/usr/bin:/bin:/usr/bin/X11:/usr/games
  /usr/local/bin:/usr/bin:/bin:/usr/bin/X11:/usr/games
Line 35: Line 34:
== csh ==
== csh ==


$ echo $SHELL
/bin/csh
  $ echo $PATH
  $ echo $PATH
  /sbin:/bin:/usr/sbin:
  /sbin:/bin:/usr/sbin:

Latest revision as of 10:15, 27 May 2006

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/