Skip to content

Instantly share code, notes, and snippets.

@janAkali
Last active February 6, 2025 04:08
Show Gist options
  • Save janAkali/338e6bf143fcd0161a2f0d768b938e4b to your computer and use it in GitHub Desktop.
Save janAkali/338e6bf143fcd0161a2f0d768b938e4b to your computer and use it in GitHub Desktop.
How to add directories to PATH variable in every OS (for whole system, not limited to terminal).

Linux

  • Ubuntu, Debian, ArchLinux and most other ditributions:

    1. Open file ~/.profile in any editor and add your directory to PATH variable, for example:
      export PATH="$HOME/Documents/apps/bin:$PATH"
  • OpenSuse Tumbleweed / Leap:

    1. Edit or create new system-wide file /etc/profile.local with root privileges, for example with terminal:
      sudo nano /etc/profile.local
    2. Add your directory to PATH variable in /etc/profile.local:
      export PATH="$HOME/Documents/apps/bin:$PATH"
  • All: after changing PATH variable logout and login to apply changes

Windows (gist)

  1. The first step depends which version of Windows you're using:
  • If you're using Windows 8 or later, press the Windows key, then search for and select "System (Control Panel)".
  • If you're using Windows 7, right click the "Computer" icon on the desktop and click "Properties".
  1. Click "Advanced system settings".
  2. Click "Environment Variables".
  3. Under "System Variables", find the PATH variable, select it, and click "Edit". If there is no PATH variable, click "New".
  4. Add your directory to the beginning of the variable value followed by ; (a semicolon). For example, if the value was C:\Windows\System32, change it to C:\Users\Me\bin;C:\Windows\System32.
  5. Click "OK".
  6. Restart your terminal.
  1. Open up Terminal.
  2. Run the following command:
    sudo nano /etc/paths
  3. Enter your password, when prompted.
  4. Go to the bottom of the file, and enter the path you wish to add.
  5. Hit control-x to quit.
  6. Enter y to save the modified buffer.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment