Ubuntu如何知道某个程序包含在某个包中?

Ubuntu如何知道某个程序包含在某个包中?,ubuntu,command-line,Ubuntu,Command Line,在Ubuntu中(在命令行上)使用一个未安装的程序,例如“sar”,它会告诉我哪个包包含这个程序 user@comp ~$ sar the program 'sar' can be found in the following packages * sysstat * atsar Try: sudo apt-get install <selected package> user@comp~$sar 程序“sar”可在以下软件包中找到 *系统统计 *阿特萨尔 尝试:sudo-apt-

在Ubuntu中(在命令行上)使用一个未安装的程序,例如“sar”,它会告诉我哪个包包含这个程序

user@comp ~$ sar
the program 'sar' can be found in the following packages
* sysstat
* atsar
Try: sudo apt-get install <selected package>
user@comp~$sar
程序“sar”可在以下软件包中找到
*系统统计
*阿特萨尔
尝试:sudo-apt-get-install

这是如何工作的?

bashshell使用一个特殊的用户定义函数,名为
command\u not\u found\u handle()
。要查看bash如何使用此函数的描述,请键入
info bash
并搜索“not found”--或

在Ubuntu 14.04.3 LTS上,该函数在
/etc/bash.bashrc
中定义,它是作为
bash
包的一部分安装的。该函数调用
/usr/lib/command not found
/usr/share/command not found/command not found

如果不希望出现这种行为,可以使用以下命令:

unset command_not_found_handle

删除函数定义。

由您的shell@BasileStarynkevitch:不,它是通过
命令\u not\u found\u handle
shell函数完成的。我投票将这个问题作为离题题题结束,因为它不是一个编程问题。这将更适合于或。