-
Ubuntu, Debian, ArchLinux and most other ditributions:
Open file~/.profilein any editor and add your directory toPATHvariable, for example:export PATH="$HOME/Documents/apps/bin:$PATH"
-
Bash login shell (default on most distributions):
try~/.bash_profileor~/.bash_loginor~/.bashrcinstead. -
Zsh login shell:
try~/.zprofileor~/.zloginor~/.zshenv -
Tcsh, Csh login shell:
try~/.cshrcor~/.loginor~/.csh.login -
Fish login shell:
add in fish config (usually~/.config/fish/config.fish):set -ga PATH "$HOME/somedir" # append directory to PATH set -gp PATH "$HOME/somedir" # alternatively, prepend directory to PATH
-
-
OpenSuse Tumbleweed / Leap:
- Edit or create new system-wide file
/etc/profile.localwith root privileges, for example, in terminal:sudo nano /etc/profile.local
- Add your directory to
PATHin/etc/profile.local:export PATH="$HOME/Documents/apps/bin:$PATH"
- Edit or create new system-wide file
Windows (gist)
- 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".
- Click "Advanced system settings".
- Click "Environment Variables".
- Under "System Variables", find the
PATHvariable, select it, and click "Edit". If there is noPATHvariable, click "New". - Add your directory to the beginning of the variable value followed by
;(a semicolon). For example, if the value wasC:\Windows\System32, change it toC:\Users\Me\bin;C:\Windows\System32. - Click "OK".
- Restart your terminal.
MacOS (stackoverflow)
Edit system-wide file /etc/paths with root privileges.
For example with terminal:
- Open Terminal
- Edit
/etc/pathswith nano:sudo nano /etc/paths
- Enter password when prompted
- Add the path you want to the top or bottom of the file
- Exit nano with
control-x - Press
yandenterto save changes
- Restart your Terminal