Difference between revisions of "Setting PATH variable"

From GeopsyWiki
Jump to navigation Jump to search
Line 3: Line 3:
 
For instance, if you type ''geopsy'', it translates to:
 
For instance, if you type ''geopsy'', it translates to:
 
* ''/usr/local/sesarray/bin/geopsy'' under Linux
 
* ''/usr/local/sesarray/bin/geopsy'' under Linux
* ''C:\Program Files\sesarray\bin\geopsy.exe''
+
* ''C:\Program Files\sesarray\bin\geopsy.exe'' under Windows
  
 
Hence ''/usr/local/sesarray/bin'' or ''C:\Program Files\sesarray\bin'' must be listed in your '''PATH''' variable.
 
Hence ''/usr/local/sesarray/bin'' or ''C:\Program Files\sesarray\bin'' must be listed in your '''PATH''' variable.

Revision as of 13:41, 7 December 2008

PATH environment variable contains a list directories used by your operating system to search for executable files. When running commands in a terminal (MSYS for Windows or a classical Linux terminal) their names are directly translated to real executable files by searching through all directories of the PATH variable for a matching file name.

For instance, if you type geopsy, it translates to:

  • /usr/local/sesarray/bin/geopsy under Linux
  • C:\Program Files\sesarray\bin\geopsy.exe under Windows

Hence /usr/local/sesarray/bin or C:\Program Files\sesarray\bin must be listed in your PATH variable.

To get the current contents of the PATH

echo $PATH

A possible output can be:

/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin

Which is the default list of system paths.

To add new custom paths, you can add a new line in your shell configuration file. There are several types of shell, to determine yours:

echo $SHELL

Which output can be

  • /bin/bash
  • /bin/tcsh
  • /bin/csh

If your shell is bash, edit the file ~/.bashrc or ~/.profile (Mac OS X)

 export PATH=/new/path/for/executable/now/in/your/path:$PATH

If your shell is csh or tcsh, edit the file ~/.login

 setenv PATH /new/path/for/executable/now/in/your/path:$PATH

To commit these changes directly to the current terminal, you must source it:

source ~/.bashrc

Do NOT forget the last part of the line which recall the current content of PATH. If you get this error for all commands you type, you probably forgot to add :$PATH at the end.

<any command name>: No such file or directory

Every time you will start a new terminal you will always have the same problem. To solve it you must edit your shell configuration file. You can still access to all commands by there absolute names:

/usr/bin/vi ~/.bashrc

To locate an executable (e.i. to make a request using current PATH variable), use command which

 which geopsy