Terminal returns not found for most commands Mac OSX

Solution 1:

$PATH should contain these folders: /usr/bin:/usr/sbin:/bin:/sbin.

Try editing ~/.bash_profile, ~/.profile, or ~/.bash_login (with for example /usr/bin/open ~/.bash_profile -a TextEdit) and commenting out any lines that modify the path.

If that works, you can add a line like export PATH=/opt/local/bin:/opt/local/sbin:$PATH to ~/.bash_profile.

Solution 2:

Similar problem was happening to me, so what I did was:

1) typing export PATH="/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin" into the terminal in order to make it temporarily working

2) Editing bash_profile by typing /usr/bin/open ~/.bash_profile -a TextEdit

3) When I opened my bash_profile file I realised the last line export looked really messy with some strange symbols, so I changed it entirely to export PATH=/opt/local/bin:/opt/local/sbin:$PATH

I'm an absolutely beginner at this but I managed to get those steps by reading pieces of solutions from different questions on SE, so hope it could help someone else.

Solution 3:

It sounds like you overwrote your path rather then just adding to it.

Make sure when you set your PATH you include "${PATH}" to include your existing path, as well.

By default the $PATH is set in a couple of files. Technically you should add to your $PATH in the .bash_profile file in your home directory.

One suggestion if to check if a certain folder exists before you add them to your PATH.

For example I have:

if [ -d /usr/local/bin ] ; then
    PATH=/usr/local/bin:"${PATH}"
fi

if [ -d /usr/local/mysql/bin ] ; then
    PATH=/usr/local/mysql/bin:"${PATH}"
fi

if [ -d /opt/local/bin ] ; then
    PATH=/opt/local/bin:"${PATH}"
fi

if [ -d /opt/local/sbin ] ; then
    PATH=/opt/local/sbin:"${PATH}"
fi

if [ -d ~/bin ] ; then
    PATH=~/bin:"${PATH}"
fi

(The -d directory command checks to see if the directory exists)