Modifying the PATH
Explore how to modify the PATH environment variable to include custom directories for executable scripts. Learn to prepend or append paths, create new executable scripts in a local bin folder, and verify command priority within the shell.
We'll cover the following...
Appending and prepending
As we learned in the earlier lessons, the PATH environment variable determines where the shell looks for executable programs. We may want to add additional directories to the list.
One common approach is to create a local bin folder in the home directory to hold executable scripts we create ourselves. This way, we don’t have to move executable scripts to a directory like /usr/local/bin.
When modifying the PATH variable, we usually want to append or prepend a directory to the list. Rather than setting the entire PATH value, we use the existing value. Let’s add the following line to the ~/.bashrc file ...