Here is the video version, if you prefer it:
Let’s talk about a special kind of environment variable – the
PATH variable, also known as the command path. (Ward, 2014) This variable stores all the places your operating system will look for executables. (“How to set your $PATH variable in Linux,” n.d.) To recall, executables are a type of a command (executable is another name for an “ordinary” program (just like Firefox)). What this means is that every time you modify or append something to your
PATH variable, you are, in essence, telling the operating system: “Look for the executable in this directory as well”. If you have multiple directories containing the same executable, the operating system will take the first one it finds.
Here is how the
PATH variable looks like:
mislav@mislavovo-racunalo:~/Linux_folder$ echo $PATH
$ in front of
PATH to get the contents of the
PATH variable. Here we see that all the folders where to look for executables are separated with a colon. So the structure of the PATH variable looks like this:
This is convenient for the operating system because it tells the operating system where to look for executables. Otherwise, it would have to search through the entire computer looking for your executable. Yikes! Better help the good ol’ operating system by telling it where to look for.
Hope you learned something useful!
How to set your $PATH variable in Linux. (n.d.). Retrieved February 27, 2020, from https://opensource.com/article/17/6/set-path-linux
Ward, B. (2014). How Linux Works: What Every Superuser Should Know (2nd ed.). No Starch Press. Pages 22-23