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?

  • 2
    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. Commented Apr 1, 2011 at 21:45

1 Answer 1


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.

  • 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
    Commented Apr 30, 2012 at 12:29
  • Te above steps work for most cases, but we have more on bad path recovery steps here: apple.stackexchange.com/questions/66931/terminal-path-error
    – bmike
    Commented Dec 26, 2013 at 16:04

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .