Bootstrap FreeKB - Linux Fundamentals - $PATH variable
Linux Fundamentals - $PATH variable

Updated:   |  Linux Fundamentals articles

$PATH is a default Linux variable that contains directories to commands. echo or printf can be used to display the current directories in the $PATH variable.

echo $PATH

 

Which should return something like this.

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

 

Directories can temporarily be appended to the PATH variable like this.

export PATH=$PATH:/opt/foo:/usr/bar

 

Better yet, PATH can be defined in your /home/username/.bash_profile file, so that every time you sign into the system, your PATH will contain the directories defined in your .bash_profile file.

PATH=$PATH:/home/john.doe/.local/bin:/home/john.doe/bin
export PATH

 

You would then want to log out of the system, log back in, and echo or printf should now contain the additional directories.




Did you find this article helpful?

If so, consider buying me a coffee over at Buy Me A Coffee



Comments


Add a Comment


Please enter c2931c in the box below so that we can be sure you are a human.