How to make PATH changes permanent?

0155

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:

  1. Open your terminal.
  2. Edit the .bashrc or .bash_profile file in your home directory:
    nano ~/.bashrc
    or
    nano ~/.bash_profile
  3. Add the following line at the end of the file, replacing /your/directory with the path you want to add:
    export PATH="$PATH:/your/directory"
  4. Save the file and exit the editor (in nano, press CTRL + X, then Y, and Enter).
  5. To apply the changes, run:
    source ~/.bashrc
    or
    source ~/.bash_profile

For Zsh:

  1. Open your terminal.
  2. Edit the .zshrc file:
    nano ~/.zshrc
  3. Add the same line as above:
    export PATH="$PATH:/your/directory"
  4. Save and exit, then run:
    source ~/.zshrc

For Fish:

  1. Open your terminal.
  2. 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.

0 Comments

no data
Be the first to share your comment!