I am having some difficulties understanding the difference between PATH and LD_LIBRARY_PATH. I have an installation setup that needs a file pkg.tcl and I am not where to add the path to it: should it be to PATH or LD_LIBRARY_PATH?

  • Regarding your installation problem, personally I would bet on TCLLIBPATH. Sorry, I have no argument. Just a hint.
    – manatwork
    Aug 8, 2012 at 7:46

2 Answers 2


Unix systems tend to be organized with different types of files spread over different directories. For example, executables are usually in directories called bin (/bin, /usr/bin, /usr/local/bin, …); historically, bin stood for binary, because the executables are binaries (machine code), but there can be scripts as well. Since there are several directories that contain executables, and it's useful to add and remove directories on the fly (e.g. to test a multi-executable application, you temporarily add it to the search path for executables), there is an environment variable for that: PATH. When you execute a program by giving its name, the shell looks it up in the directories mentioned in the PATH variable (it's a colon-separated list of directories).

The same mechanism exists for other types of files that some program is going to search for by name. Here are a few typical PATH-like variables (note that the example paths that I give aren't exactly what you'll find on your system, there' just there to give an idea).

  • PATH: executables (e.g. /home/username/bin:/usr/local/bin:/usr/bin:/bin).
  • MANPATH: manual pages (e.g. /usr/local/man:/usr/man).
  • LD_LIBRARY_PATH: native code libraries (on Linux, in addition to the value of this variable, the lookup path typically contains /usr/local/lib, /usr/lib, /lib and a few others). The name LD comes from dynamic loader, the system component that loads libraries into dynamically linked executables.
  • PERL5LIB: Perl libraries (e.g. /usr/local/lib/site-perl:/usr/lib/site-perl:/usr/lib/perl:/usr/share/perl).
  • PYTHONPATH: Python libraries (e.g. /usr/local/lib/python:/usr/lib/python:/usr/lib/python2.6).
  • TCLLIBPATH: TCL libraries (e.g. /usr/local/lib/tcltk:/usr/lib/tcltk).

So if your pkg.tcl is a standalone executable, give it execution permissions and drop it somewhere in $PATH. If it's a TCL library loaded by a TCL program, drop it somewhere in $TCLLIBPATH.


PATH is for specifying directories of executable programs. LD_LIBRARY_PATH is used to specify directories of libraries.

  • 7
    From other point of view, PATH is used primarily by the shell, while LD_LIBRARY_PATH is used by the dynamic loader (usually ld-linux.so).
    – manatwork
    Aug 8, 2012 at 7:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.