bash-tutorial/tutorial/variables.org

771 B

Variables and how to add a directory to $PATH

System variables are stored in users environment

  • $PATH Finds the content of a variable ("PATH")
  • "env" variables defined in shell environment

Add directory to path

"Environment variables" in: Arch wiki

To add a directory to the PATH for local usage, put the following in "~/.bash_profile":

export PATH="${PATH}:/home/my_user/bin"

This will add the directory at the end of $PATH. To update the variable, re-login or source the file:

source ~/.bash_profile

Then check directories in "$PATH"

echo $PATH