Any terminal command does not work.

Hello,

I tried to chenge something in my bash_profile but I think I mistacked something. So I can not run any terminal command if I post "ls" command then I get

"-bash: ls: command not found" now I can not open bash_profile also. So what can I do here. I get the below path using echo command but there was some any other path. Please help.

echo $PATH: /usr/local/bin:/usr/local/bin:

But if I write /bin/ls it works.

MacBook Pro EI Capitan : 10.11.4


Thanks.

MacBook Pro, OS X El Capitan (10.11.4)

Posted on May 1, 2016 5:16 AM

Reply
2 replies

May 1, 2016 6:57 AM in response to mahdimormi

You messed up your PATH environment variable.

/bin/ls

works because you did not need PATH to find the 'ls' program. You can run ANY command by specifying its full path.


You need to re-edit your .bash_profile to either remove your PATH, or fix it. I do not know what editor you used to modify .bash_profile to begin with, but you can use

/usr/bin/nano

/usr/bin/vi (ONLY if you know vi/Vim)

/usr/bin/vim (ONLY if you know vi/Vim)

/usr/bin/emacs (I shutter to think about this)

TextWrangler (a very good free GUI text editor) <http://www.barebones.com/products/textwrangler/>


Or you can just rename the current .bash_profile and start a new terminal session, then fix the renamed .bash_profile before putting it back in service

/bin/mv .bash_profile saved.bash_profile

May 1, 2016 7:03 AM in response to mahdimormi

And while your echo $PATH kind of looked OK, it will not show any spaces or non-printing characters that go into the environment variable. Please use the following command and post the results

echo "@@@${PATH}@@@" | cat -vte

The @@@ will make sure we see any white space between the @ and the first/last character in $PATH


The cat -vte will convert any non-printing characters into notation such as a tab will display as ^I and the very last character will be a $ since echo adds a newline to the output, and cat -vte will display $ for that echo added newline.


That will show us a clear picture of what your PATH environment variable looks like.

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

Any terminal command does not work.

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.