To make changes to the PATH variable permanent, you can add the desired directory to your PATH in your shell's configuration file. Here are the steps for common shells:
For Bash:
- Open your terminal.
- Edit the
.bashrcor.bash_profilefile in your home directory:
ornano ~/.bashrcnano ~/.bash_profile - Add the following line at the end of the file, replacing
/your/directorywith the path you want to add:export PATH="$PATH:/your/directory" - Save the file and exit the editor (in nano, press
CTRL + X, thenY, andEnter). - To apply the changes, run:
orsource ~/.bashrcsource ~/.bash_profile
For Zsh:
- Open your terminal.
- Edit the
.zshrcfile:nano ~/.zshrc - Add the same line as above:
export PATH="$PATH:/your/directory" - Save and exit, then run:
source ~/.zshrc
For Fish:
- Open your terminal.
- Use the following command to add a directory to your
PATH:set -U fish_user_paths /your/directory $fish_user_paths
After following these steps, your PATH changes will be permanent and will persist across terminal sessions.
