Difference between revisions of "Setting PATH variable"
(2 intermediate revisions by the same user not shown) | |||
Line 6: | Line 6: | ||
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. | ||
+ | |||
+ | == Identifying your [[Wikipedia:Shell_(computing)|shell]] == | ||
To get the current contents of the '''PATH''' | To get the current contents of the '''PATH''' | ||
Line 26: | Line 28: | ||
* /bin/tcsh | * /bin/tcsh | ||
* /bin/csh | * /bin/csh | ||
+ | |||
+ | == Altering your PATH == | ||
If your shell is ''bash'', edit the file ''~/.bashrc'' or ''~/.profile'' (Mac OS X) | If your shell is ''bash'', edit the file ''~/.bashrc'' or ''~/.profile'' (Mac OS X) | ||
− | export PATH=/new/path/for/ | + | export PATH=/new/path/for/executables/now/in/your/path:$PATH |
If your shell is ''csh'' or ''tcsh'', edit the file ''~/.login'' | If your shell is ''csh'' or ''tcsh'', edit the file ''~/.login'' | ||
− | setenv PATH /new/path/for/ | + | setenv PATH /new/path/for/executables/now/in/your/path:$PATH |
To commit these changes directly to the current terminal, you must source it: | To commit these changes directly to the current terminal, you must source it: | ||
source ~/.bashrc | source ~/.bashrc | ||
+ | |||
+ | The next time you will create a new terminal this file is read automatically and your '''PATH''' is correctly setup. | ||
+ | |||
+ | == Common mistake == | ||
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. | 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. | ||
Line 43: | Line 51: | ||
<any command name>: No such file or directory | <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 | + | 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 their absolute names: |
/usr/bin/vi ~/.bashrc | /usr/bin/vi ~/.bashrc |
Latest revision as of 13:55, 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.
Identifying your shell
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
Altering your PATH
If your shell is bash, edit the file ~/.bashrc or ~/.profile (Mac OS X)
export PATH=/new/path/for/executables/now/in/your/path:$PATH
If your shell is csh or tcsh, edit the file ~/.login
setenv PATH /new/path/for/executables/now/in/your/path:$PATH
To commit these changes directly to the current terminal, you must source it:
source ~/.bashrc
The next time you will create a new terminal this file is read automatically and your PATH is correctly setup.
Common mistake
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 their 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