为什么Ubuntu说“命令未找到”需要这么长时间
出于某种原因,在我的设置中,当我意外地错误命令时,Ubuntu可能需要几秒钟来响应“未找到命令”。 为什么需要这么长时间? 有没有办法缩短我必须等待的时间?
我的PATH中有13个目录,但即便如此(其中大多数只有几个文件),搜索13个目录的命令不需要几秒钟吗?
shell不只是查看$PATH
。 如果找不到命令,则执行bash函数command_not_found_handle
,然后调用python脚本/usr/lib/command-not-found
。 这将在包列表中搜索应该为命令工作而安装的程序。 在您知道如何解决的拼写错误的情况下,只需按Ctrl + C即可中止搜索过程。
错字的有用消息示例:
$ aptget update No command 'aptget' found, did you mean: Command 'apt-get' from package 'apt' (main) aptget: command not found
丢失包的有用消息示例:
$ deja-dup The program 'deja-dup' is currently not installed. You can install it by typing: sudo apt-get install deja-dup
另请参阅此背后的基本原理, https://wiki.ubuntu.com/CommandNotFoundMagic
这是因为一个名为“command-not-found”的包。 您可以将其卸载以缩短响应时间。