Priority of executables in bin directories

In Linux, we sometimes experience confusing situation in executing programs. For a program, we may have different versions installed by Linux distribution itself and by root user or somebody else. As a result, executable programs with the same name locate in different directories. Usually they are in /usr/bin and /usr/local/bin. When we simply type a executable program without typing the full path, which program gets executed?

The answer lays in the environment variable PATH. PATH variable records a long series of different paths split by “:” character. Directory in the front is called before the latter.

For example, if your PATH variable records


Same-name executable programs in /usr/local/bin is called rather than the one in /usr/bin

Don’t know how to show PATH variable?
Simply type

echo $PATH


Leave a Reply

Your email address will not be published.