...
Introduction
Environmental variables are a class of variables (i.e., items whose values can be changed) that tell the shell (like Bash or Tcsh) how to behave as the user works at the command line (i.e., in a text-only mode) or with shell scripts (i.e., short programs written in a shell programming language). A shell is a program that provides the traditional, text-only user interface for Unix-like operating systems; its primary function is to read commands that are typed in at the command line and then execute (i.e., run) them.
The default PATH
PATH is an environmental variable in Linux and other Unix-like operating systems that tells the shell which directories to search for executable files (i.e., ready-to-run programs) in response to commands issued by a user.
...
Expand | ||||||
---|---|---|---|---|---|---|
| ||||||
*Yikes, this machine doesn't have samtools on it! Or does it?
/opt/apps/tar-lustre/1.22/bin:/opt/apps/gzip-lustre/1.3.12/bin:/opt/apps/intel11_1/mvapich2/1.6/bin:/opt/apps/intel/11.1/bin/intel64:/opt/sge6.2/bin/lx24-amd64:/usr/lib64/qt-3.3/bin:/usr/kerberos/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/gsi-openssh-4.3/bin:/usr/X11R6/bin:/opt/ofed/bin:/opt/ofed/sbin:/usr/local/bin:/sge_common/default/pe_scripts:.:/opt/apps/irods/2.5/bin
|
...
Code Block |
---|
login1$ which bash /bin/bash login1$ which gcc /usr/bin/gcc login1$ which samtools /usr/bin/which: no samtools in (/opt/apps/python/epd/7.2.2:/opt/apps/python/epd/7.2.2/bin:/opt/apps/tar-lustre/1.22/bin:/opt/apps/gzip-lustre/1.3.12/bin:/opt/apps/intel11_1/mvapich2/1.6/bin:/opt/apps/intel/11.1/bin/intel64:/opt/sge6.2/bin/lx24-amd64:/usr/lib64/qt-3.3/bin:/usr/kerberos/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/gsi-openssh-4.3/bin:/usr/X11R6/bin:/opt/ofed/bin:/opt/ofed/sbin:/usr/local/bin:/sge_common/default/pe_scripts:.:/opt/apps/irods/2.5/bin) |
Extending PATH
You extend your PATH by changing the PATH variable (yes, you can do that!). Try the following:
...
This works for other people's code too. So, you could install a copy of samtools in your $HOME/bin directory and it would show up. You won't need to do this, as we will demonstrate in the next section, but you should get the general idea.
Making it stick
Having to remember to type in export PATH=$PATH:$HOME/bin
every time you start a new shell is... burdensome. Luckily, it's easy to make it semi-permanent by editing the .profile_user
file that exists in your $HOME directory. If you open it in a text editor, add the line export PATH=$PATH:$HOME/bin
, save, and re-login to Lonestar you will find that your PATH automatically includes $HOME/bin.
Let's move on now to the next section: The modules system