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

When I open Terminal it shows this:

Last login: Fri Apr 1 17:04:59 on ttys000
-bash: export: /opt/local/bin': not a valid identifier
-bash: export::/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/opt/local/bin:/usr/local/git/bin:/usr/X11/bin': not a valid identifier
Josh@Macbook-Pro~$ export

I installed something yesterday and modified bash_profile. Now I cannot do anything in Terminal. Even "ls". It returns…

bash: ls: No such file or directory

How can I fix it?

share|improve this question
We need to see what file was modified, and it'd be great if we knew what "something" was that you installed. You can use Secrets.prefpane to show hidden files in Finder, then open up ~/.bash_profile, or .profile, or .bashrc, or what have you in your favorite text editor, then copy/paste into here. – Jason Salaz Apr 1 '11 at 21:45
up vote 7 down vote accepted

Sounds like it's screwing up your PATH, so the shell can't find any of the usual commands. In this case, you can still use the commands by specifying their entire path (e.g. /bin/ls instead of just `ls), or just reset your PATH manually:


(Note that that's based on the error you gave; there may be some directories missing.)

If .bash_profile is the only thing messed up, it's probably easiest to just disable it:

/bin/mv .bash_profile bash_profile_disabled
/bin/mv .bashrc bashrc_disabled

... and then open a new (clean) Terminal window, and then look through the file to see if you can undo the damage before renaming it back.

share|improve this answer
THANK YOU SOOOO MUCH! Mine was screwed up to and I have spent hours of research trying to fix it! Your advice worked! I can''t tell you how grateful I am right now!!!! – user22254 Apr 30 '12 at 12:29
Te above steps work for most cases, but we have more on bad path recovery steps here: – bmike Dec 26 '13 at 16:04

Your Answer


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.