The PATH
is an important concept when working on the command line. It is a list of driectories which tell your operating system where to look for programs. When calling scripts typically you have to give the exact path location such has /home/<usr>/bin/scriptname
but if you add the entire path to the folder to your PATH
you can call the script from anywhere with just scriptname
.
- Open the
.bash_profile
file in your home directory (for example,/Users/your-user-name/.bash_profile
) in a text editor. - Add export
PATH="your-dir:$PATH"
to the last line of the file, where your-dir is the directory you want to add. - Save the
.bash_profile
file. - Restart your terminal.
- Open the .bashrc file in your home directory (for example,
/home/your-user-name/.bashrc
) in a text editor. - Add export
PATH="your-dir:$PATH"
to the last line of the file, where your-dir is the directory you want to add. - Save the
.bashrc
file. - Restart your terminal.
- Pro tip: you can hot reload your .bashrc with
source ~/.bashrc