Take the 2-minute tour ×
Ask Different is a question and answer site for power users of Apple hardware and software. It's 100% free, no registration required.

I installed the most recent mac update to OS X Lion (10.7).

After I did that, my terminal won't recognize normal commands. I type 'ls' and get:

-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. And 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
1  
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
add comment

3 Answers

up vote 7 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 Lion is something like

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

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
add comment

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
add comment

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`
fi

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

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 http://www.apple.com/support/contact/ or report a bug at https://bugreport.apple.com/ to let Apple know there's a problem.

share|improve this answer
add comment

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.