zsh: command not found: Solve the problem of Mac terminal command failure

zsh: command not found: Solve the problem of Mac terminal command failure

When configuring maven and Java environment variables to use the terminal, I encountered the problem of zsh: command not found: After that, basically entering any command was invalid. After trying a lot of methods, I finally solved it.

1. Enter in the terminal:

PATH=/bin:/usr/bin:/usr/local/bin:${PATH}

export PATH

Use of other directives can be forcibly restored.

2. Enter open .zshrc to open the .zshrc file and enter the above two lines in it

PATH=/bin:/usr/bin:/usr/local/bin:${PATH}

export PATH

and source .bash_profile or source ~/.bash_profile

(This step is to add all the environment variables of .bash_profile to the zsh shell when zshrc is executed. If the file .bash_profile has not been created before, there is no need to add it. Just enter the two lines in step 2.) Save and
exit

3. After saving and exiting, enter source .zshrc in the terminal to make the file take effect, exit the terminal and reopen it to use.

Guess you like

Origin blog.csdn.net/qq_53779954/article/details/129827748
Recommended