原因
导致命令不可用的真正原因是zsh和bash的默认环境变量配置文件地址不一致导致的。习惯是只配置~/.zshrc,实际上~/.bash_profile环境的也是需要配置一下的
解决办法
# 进入~/.bash_profile文件
sudo vim ~/.bash_profile
# 在编辑模式下添加以下命令
export PATH=$PATH:/usr/sbin
# 之后点击ESC+:wq保存退出
# 执行source ~/.bash_profile和source ~/.zshrc
source ~/.bash_profile
source ~/.zshrc