Add Executable Files to $PATH with Bash

Cameron Nokes
InstructorCameron Nokes

Share this video with your friends

Send Tweet

PATH is a global environment variable that represents a list of directories bash looks in for executable files. The executable files for bash commands like grep are all somewhere on your OS’s PATH. We can add our own folders to PATH to make our executables available as a command to bash. In this lesson we’ll learn how to add a new folder to our PATH in .bash_profile and how to symlink an executable file into /usr/local/bin, which is in PATH by default.

Note that in zsh, when modifying your PATH you to provide an absolute path, ~ is not expanded.

Shripada Hebbar
Shripada Hebbar
~ 2 years ago

Next time you echo your path, try this: echo $PATH | tr : '\n' | cat

Cameron Nokes
Cameron Nokesinstructor
~ a year ago

Note: starting with Catalina, macOS now uses zsh as the default shell instead of bash. zsh and bash are very similar, but zsh looks for a .zshrc and .zprofile instead. See for more info on the differences between the two.