Ask Different is a question and answer site for power users of Apple hardware and software. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I stuffed up (basically wiped) my PATH variable.

Is there any way to reset it to the default?

I look at How do I reset the $PATH variable on Mac OS X?, but I find it very confusing. As far as I know I stuffed up my ~/.profile file.

share|improve this question
up vote 14 down vote accepted

I have the following in my ~/.profile:

PATH=/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin
PATH=$PATH:~/bin

The first PATH declaration overrides any existing PATH setting (it doesn't include $PATH). The path used is the OS X default.

The second line appends ~/bin to the PATH and it is a personal preference, not a default.

After edit, restart your session — or use command source ~/.profile to activate the changes immediately.

share|improve this answer
    
Thanks a million man - everything so far has been insanely confusing - your advice is incredibly straightforward and easy to follow – Jaco Pretorius Apr 11 '11 at 17:09
    
Great answer, this worked like a champ for me. – Roy Ashbrook May 26 '15 at 6:11
    
Better to use ~/.bash_profile for this simple case and in more general ~/.bashrc and source that in your ~/.bash_profile – Mark Jun 29 at 16:07

The file can have the name .bash_profile or .profile - one solution could be to rename the file e.g. mv ~/.bash_profile ~/.bash_prolile.old and then restart your machine and see if it helped.

You can also try to edit the file, and then maybe you'll see the wrong PATH, which you then can edit.

share|improve this answer

In the case of logging in as a normal user and invoking su - root, I found that Mac OS X 10.8.5's bash was ignoring .profile and .bash_profile; I was unable to change root's $PATH by editing those files. What did work was editing /etc/paths. After exiting the root shell and entering again with su - root, the new path was present.

share|improve this answer
    
Messing with system paths could generate instability. – sas08 Nov 8 '15 at 9:54

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.