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 installed the most recent update to OS X Lion (10.7). After I did that, my terminal won't recognize normal commands. I typed ls and got:

-bash: ls: command not found

I figured I'd try to add usr/bin to my path, but I can't find .bash_profile to edit it since typing edit .bash_profile won't work. I can't set the Finder to show all files since my terminal won't recognize the commands necessary to do that.

what do I need to do?

share|improve this question
Let's get a path and see what shakes out. export PATH=/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin paste the dark part (or type it VERY CAREFULLY) - since two commands are missing - something whacked your path. Before doing anything big, kicking off a backup might be prudent. – bmike Aug 23 '11 at 1:27
@bmike thanks! added that to .bash_profile and it's all working now. had to open .bash_profile like this: /usr/bin/vi ~/.bash_profile Put that as an answer and I can accept! – LuxuryMode Aug 23 '11 at 1:37
up vote 19 down vote accepted

Since two commands are missing something “stomped” your path.

Before doing anything big, kicking off a backup might be prudent.

The default path on Mac OS X 10.7 (Lion) is something like this:


You can reset the path by typing the above into a shell window, and then typing export PATH

So you can start there and see what else might be amiss.

share|improve this answer
For me, this provides a temporary fix. – Etienne Low-Décarie Jun 26 '14 at 12:59

It sounds to me as if /etc/profile wasn't run at shell startup. It's the global startup file responsible for initializing PATH. Check whether /etc/profile exists and is readable and executable with the following command:

. /etc/profile

If it isn't there, you'll need to restore it from a backup or another machine with Lion installed, or install Lion again. If it exists but isn't executable, try using Disk Utility to Repair Disk Permissions.

If it does exist and is executable (and it contains some code), either it may not be getting run when it's supposed to or your startup script may somehow be overriding it. As a workaround, try putting . /etc/profile at the start of your ~/.bash_profile to ensure it is run. If you still encounter the problem, add echo $PATH after running it to see if PATH was initialized properly. If it was, something in your script is changing it.

Here's the default contents of /etc/profile:

# System-wide .profile for sh(1)

if [ -x /usr/libexec/path_helper ]; then
    eval `/usr/libexec/path_helper -s`

if [ "${BASH-no}" != "no" ]; then
    [ -r /etc/bashrc ] && . /etc/bashrc

path_helper constructs the default PATH. You could try running

unset PATH; /usr/libexec/path_helper -s

to see what it produces.

In any case, if the problem isn't in your startup script(s), please contact Apple support or report a bug at to let Apple know there's a problem.

share|improve this answer
unset PATH; /usr/libexec/path_helper -s shows me PATH that is not contained in my /etc/profile. Any suggestions? – Etienne Low-Décarie Jun 26 '14 at 13:00
Running . /etc/profile temporarily fixes the problem. I have pasted into the top of my ~/.bash_profile, but it appears that this is not run either. – Etienne Low-Décarie Jun 26 '14 at 13:10
Check the bash man page for the complete list of startup files and the order in which they are searched. If you have a login file it takes precedence over the profile, for example. Check for other startup files. – Chris Page Jun 26 '14 at 19:01

To check that it is indeed a problem with your path, what's the result of /bin/ls ?

If it works, than you should restore your path to /usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin, you can use for example VI whose path is (on my mac) /usr/bin/vi.

share|improve this answer

I was trying to set my maven path to envoronment variables when this happened. So I just moved my .profile and .bash_profile file to trash and tried again and it worked.

share|improve this answer

you can export the path as follows:

export PATH=$PATH:/bin:/usr/local/bin

share|improve this answer
Welcome to Ask Different! This question already has an accepted answer and your answer is not materially different than the accepted answer. Please see the following FAQ on how to provide a good answer: – fbara Apr 29 at 17:39

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.