Understanding the PATH variable

I was reading about rbenv and found the best way of describing what PATH means to newbies and thought it should make an entry to my blog ;). The author says as follows:

When you run a command like ruby or rake, your operating system searches through a list of directories to find an executable file with that name. This list of directories lives in an environment variable called PATH, with each directory in the list separated by a colon:

/usr/local/bin:/usr/bin:/bin

Directories in PATH are searched from left to right, so a matching executable in a directory at the beginning of the list takes precedence over another one at the end. In this example, the/usr/local/bin directory will be searched first, then /usr/bin, then /bin.

Leave a comment