Mac suddenly cannot use ping and ifconfig

I encountered a "command not found: ping" error when using Zsh in the macOS Terminal.

Because the system's PATH environment variable is not set correctly. This may cause the terminal to be unable to find pingthe command. 

1. Check the PATH environment variable:

Run the following command in the terminal to view the current PATH settings:

echo $PATH

Make sure you include /sbinand /usr/sbin, which is pingthe path to the command. If these paths are missing, you can try the following methods to fix them.

2. Modify the terminal configuration file

Open your terminal configuration file (usually or ~/.zshrc) ~/.bashrcand add the following lines:

export PATH="/usr/sbin:/sbin:$PATH"

Save the file and restart the terminal, then try running pingthe command again.

Guess you like

Origin blog.csdn.net/qq_23938507/article/details/131101191