如何禁用 Linux shell 中的“你是说……”功能
如何使用错误输入的命令禁用安装包的提议
如果找不到您在 Linux 控制台中输入的命令,某些发行版会显示其他信息,提示输入的命令可能位于哪些包中以及如何安装它。
此类消息的示例:
Command 'magick' not found, did you mean:
command 'magic' from deb magic
command 'magics' from deb magics++
Try: sudo apt install <deb name>

使用它的发行版例如 Kali Linux 和 Ubuntu。
如果出于某种原因您不喜欢终端的这种行为,并且希望将错误输出限制为消息“找不到命令”,那么本文将告诉您如何去做。
由于“你的意思是...”功能是由“command-not-found”包提供的,您可以删除该包以禁用它:
sudo apt remove command-not-found
之后,重新启动计算机以使更改生效。

删除command-not-found后不出现错误的解决方法
为了在删除 command-not-found 后再次显示“command not found”消息,请重新启动计算机。
在不删除“command-not-found”包的情况下禁用“你的意思是……”功能
此方法可由非 root 用户使用,即无法删除软件包。
打开文件
- .bashrc(用于 Bash shell)
- .zshrc(用于 Zsh 外壳)
另请参阅:如何找出 Linux 中正在使用的 shell
并在那里添加行
unset command_not_found_handle
在将指定的行添加到其中一个 shell 文件之前,检查启用 command-not-found 的行。例如,在 Kali Linux 中,存在以下行:
# enable command-not-found if installed
if [ -f /etc/zsh_command_not_found ]; then
. /etc/zsh_command_not_found
fi
删除或注释掉 .zshrc 文件中的这些行以获得:
## enable command-not-found if installed
#if [ -f /etc/zsh_command_not_found ]; then
# . /etc/zsh_command_not_found
#fi
因此,command-not-found 功能将在所有新打开的终端中被禁用。