You can make a difference in the Apple Support Community!

When you sign up with your Apple Account, you can provide valuable feedback to other community members by upvoting helpful replies and User Tips.

Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

"command not found" error for most terminal commands

All commands that I try to run in the command line return an error such as:


-bash: open: command not found


I have tried to find a solution online but I cant find anything helpful. I found this while trying to download and install Git but the commands wouldn't run. I am not very experienced with macos and commands for it.

Mac mini, macOS 10.15

Posted on Jan 8, 2022 1:57 PM

Reply
Question marked as Top-ranking reply

Posted on Jan 9, 2022 9:23 AM

Sorry, I keep forgetting you have not PATH

/usr/bin/printenv PATH


I am guessing this is this line in your .bash_profile

/Users/<username>/.bash_profile:export PATH=’/usr/local/bin:??

that is causing you problems.


/usr/bin/nano $HOME/.bash_profile

Unless you have another preferred text editor, in which case use the full path to that editor

/usr/bin/which vim
/usr/bin/which emac

as examples to find the full path to other editors


After you have corrected your .bash_profile, /usr/bin/which Quit your Terminal session, start a new Terminal session, and see if you have a working PATH now.

Similar questions

5 replies
Question marked as Top-ranking reply

Jan 9, 2022 9:23 AM in response to DeadScorpion

Sorry, I keep forgetting you have not PATH

/usr/bin/printenv PATH


I am guessing this is this line in your .bash_profile

/Users/<username>/.bash_profile:export PATH=’/usr/local/bin:??

that is causing you problems.


/usr/bin/nano $HOME/.bash_profile

Unless you have another preferred text editor, in which case use the full path to that editor

/usr/bin/which vim
/usr/bin/which emac

as examples to find the full path to other editors


After you have corrected your .bash_profile, /usr/bin/which Quit your Terminal session, start a new Terminal session, and see if you have a working PATH now.

Jan 8, 2022 3:15 PM in response to DeadScorpion

Your PATH environment variable is screwed up.


It should look like

PATH=/usr/bin:/bin:/usr/sbin:/sbin

but yours is apparently broken. Use

printenv PATH

to see what your PATH is actually set to. It is allowed to be different from the default, but it should still include the default set of directories.


You can access commands by specifying their full path.


/usr/bin/grep 'PATH=' $HOME/.[a-z]*

should find all the shell initialization files that set PATH


When you find the offending shell initialization file

/usr/bin/nano .name-of-offending-file

and fix it.

Jan 9, 2022 7:54 AM in response to BobHarris

And the next command(/usr/bin/grep 'PATH=' $HOME/.[a-z]*) returned:

/Users/<username>/.bash_history:echo export PATH=’/usr/local/bin:$PATH’ >> ~/.bash_profile

/Users/<username>/.bash_history:export PATH="/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin"

/Users/<username>/.bash_history:/usr/bin/grep 'PATH=' $HOME/.[a-z]*

/Users/<username>/.bash_profile:PATH="/Library/Frameworks/Python.framework/Versions/3.9/bin:${PATH}"

/Users/<username>/.bash_profile:export PATH=’/usr/local/bin:??

grep: /Users/<username>/.bash_sessions: Is a directory

grep: /Users/<username>/.cache: Is a directory

grep: /Users/<username>/.config: Is a directory

grep: /Users/<username>/.cups: Is a directory

grep: /Users/<username>/.idlerc: Is a directory

grep: /Users/<username>/.oracle_jre_usage: Is a directory

grep: /Users/<username>/.vscode: Is a directory


I don't know the offending file or what the PATH is supposed to be

"command not found" error for most terminal commands

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