Skip to main content
original advice about .profile was incorrect for macOS. Also, mention that these are only called at login.
Source Link
Gilles 'SO- stop being evil'
  • 865.2k
  • 205
  • 1.8k
  • 2.3k

Put the line to modify PATH in ~/.profile, or in ~/.bash_profile or if that's what you have. On macOS(If your login shell is zsh and not bash, you may need to useput it in ~/.zprofile instead, even if it doesn't already exist. In all these cases)

The profile file is read by login shells, so it will only take effect the next time you must log out and then back in for changes. (Some systems configure terminals to read a login shell; in that case you can start a new terminal window, but the setting will take effect only for programs started via a terminal, and how to set PATH for all programs depends on the system.)

Put the line to modify PATH in ~/.profile, or in ~/.bash_profile if that's what you have. On macOS, you may need to use ~/.zprofile instead, even if it doesn't already exist. In all these cases, you must log out and then back in for changes to take effect.

Put the line to modify PATH in ~/.profile, or in ~/.bash_profile or if that's what you have. (If your login shell is zsh and not bash, put it in ~/.zprofile instead.)

The profile file is read by login shells, so it will only take effect the next time you log in. (Some systems configure terminals to read a login shell; in that case you can start a new terminal window, but the setting will take effect only for programs started via a terminal, and how to set PATH for all programs depends on the system.)

original advice about .profile was incorrect for macOS. Also, mention that these are only called at login.
Source Link

Put the line to modify PATH in ~/.profile, or in ~/.bash_profile if that's what you have. On macOS, you may need to use ~/.zprofile instead, even if it doesn't already exist. In all these cases, you must log out and then back in for changes to take effect.

Put the line to modify PATH in ~/.profile, or in ~/.bash_profile if that's what you have.

Put the line to modify PATH in ~/.profile, or in ~/.bash_profile if that's what you have. On macOS, you may need to use ~/.zprofile instead, even if it doesn't already exist. In all these cases, you must log out and then back in for changes to take effect.

Rollback to Revision 14
Source Link
Paulo Tomé
  • 3.8k
  • 6
  • 28
  • 39

NOTE: You need to restart your terminal session, otherwise the changes won't take effect.

NOTE: You need to restart your terminal session, otherwise the changes won't take effect.

deleted 14 characters in body
Source Link
Gilles 'SO- stop being evil'
  • 865.2k
  • 205
  • 1.8k
  • 2.3k
Loading
minor formatting and wording to clarify you only need 1 path command, and to make the correct file to place this in stand out
Source Link
Loading
Fix syntax and grammar
Source Link
Gilles 'SO- stop being evil'
  • 865.2k
  • 205
  • 1.8k
  • 2.3k
Loading
add a note about /etc/environment since a reader didn't realize that this wasn't a shell script
Source Link
Gilles 'SO- stop being evil'
  • 865.2k
  • 205
  • 1.8k
  • 2.3k
Loading
note that some systems already have ~/bin as suggested by patryk.beza
Source Link
Gilles 'SO- stop being evil'
  • 865.2k
  • 205
  • 1.8k
  • 2.3k
Loading
Add an explicit note not to add `export` to the first section; move the bit about why you don't need it to a separate section because that's not "simple stuff"; use overstrike for the bad example; add a discussion of an initially empty PATH as suggested by James Tocknell
Source Link
Gilles 'SO- stop being evil'
  • 865.2k
  • 205
  • 1.8k
  • 2.3k
Loading
added 187 characters in body
Source Link
Stéphane Chazelas
  • 584.4k
  • 96
  • 1.1k
  • 1.7k
Loading
replaced http://unix.stackexchange.com/ with https://unix.stackexchange.com/
Source Link
Loading
replaced http://superuser.com/ with https://superuser.com/
Source Link
Loading
reorganize the answer to separate out the non-bash stuff; cite some other threads about duplicate removal, which is good to mention here; note that `export var=~` is expanded in bash (thanks mikeserv)
Source Link
Gilles 'SO- stop being evil'
  • 865.2k
  • 205
  • 1.8k
  • 2.3k
Loading
mention the necessity of double quotes in some shells
Source Link
Gilles 'SO- stop being evil'
  • 865.2k
  • 205
  • 1.8k
  • 2.3k
Loading
mention the relevance of the order, since it came up in http://unix.stackexchange.com/questions/115964/program-installed-to-home-username-bin-and-added-to-path-not-launching
Source Link
Gilles 'SO- stop being evil'
  • 865.2k
  • 205
  • 1.8k
  • 2.3k
Loading
Source Link
Gilles 'SO- stop being evil'
  • 865.2k
  • 205
  • 1.8k
  • 2.3k
Loading