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 ping
the 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 /sbin
and /usr/sbin
, which is ping
the 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
) ~/.bashrc
and add the following lines:
export PATH="/usr/sbin:/sbin:$PATH"
Save the file and restart the terminal, then try running ping
the command again.