Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

  1. To add a location to your PATH environment variable in Linux, you need to do the following:
    Open a terminal and run the following command to open the .bashrc file in a text editor:

    nano ~/.bashrc

  2. Scroll to the bottom of the .bashrc file and add the following line, replacing /your/path with the location you want to add to the PATH variable:

    export PATH=$PATH:/your/path

    Note: You can add any environment variable in a similar way:
    export VAR=/Some/path/
    *Don't add spaces next to the '"=' " sign

  3. Press CTRL + X to exit the editor, then press Y to save the changes and Enter to confirm the file name.

  4. Run the following command to apply the changes to the current terminal session:

    source ~/.bashrc

  5. Verify that the location was added to the PATH variable correctly by running the following command:

    echo $PATH

  6. You should see the new location in the list of paths that is printed to the screen. Keep in mind that you will need to open a new terminal or log out and log back in for the changes to take effect.

...