Many problems encountered by new Linux users can be fixed with a better understanding of paths. The PATH environment variable tells your shell to look for the command you typed. This keeps you from having to type out the full path to a command every time. `/bin/ls` may only be 5 more keystrokes than `ls`, but after a while it really adds up. And if you have a command in a place like /opt/gempak/os/linux/bin, you really don’t want to have to type that out every time. By default, certain system paths are included: generally /bin and /usr/bin, at the least. You can set your PATH to include whatever directories you want ( ~/bin is a common addition), but you need to be careful.
I once had a user complain that some simple commands took a long time to execute. When I saw his PATH, I realized what his problem was. There were nearly a dozen directories in front of /bin, including a non-existent directory in a space that gets automounted. So when he’d type ls, the shell would go through each of those directories, and when it reached /home/cwp, it hung for several seconds while it tried in vain to mount the directory. This brings up two important points: make sure the directories in your PATH exist, and put the most frequently used directories first.
Another problem is that some packages contain programs with the same name. There’s not much you can do about that. Whichever comes first in the PATH gets executed. If there’s one that you use more than another, make sure it is toward the front of your PATH.
There’s also an environment variable called LD_LIBRARY_PATH. This comes up less often, but can be just as problematic. Many common functions are in files called libraries, that get shared by many binaries. System libraries are generally kept in /lib and /usr/lib. Many software packages have their own libraries, sometimes stored in their own lib directory. In a lot of cases, the binaries know where to look to find their library files, but sometimes they don’t. If a program complains that it can’t find some library, but you know it exists, you can set the LD_LIBRARY_PATH environment variable to point to where the libraries are located. For example, the WDSS-II radar analysis package doesn’t know to look in its lib directory, so you have to manually specify it:
setenv LD_LIBRARY_PATH /opt/WDSS2/lib
You can find out what libraries a binary needs using the ldd program:
[1013 bcotton@boone ~ ]$ ldd /usr/bin/gcc
linux-gate.so.1 => (0x00e12000)
libc.so.6 => /lib/libc.so.6 (0x00489000)