找出命令来自哪个包

是否有一种通用的方法来找出导致安装命令的软件包?

打开终端并尝试以下命令:

dpkg -S 'command name' 

例如: dpkg -S /bin/ls

样本输出:

 coreutils: /bin/ls 

您还可以获取有关coreutils包的详细状态信息,请输入:

  dpkg -s coreutils 

样本输出:

 Package: coreutils Essential: yes Status: install ok installed Priority: required Section: utils Installed-Size: 9040 Maintainer: Ubuntu Core Developers Architecture: i386 Version: 5.97-5.3ubuntu3 Replaces: textutils, shellutils, fileutils, stat, debianutils (<= 2.3.1), dpkg (<< 1.13.2) Provides: textutils, shellutils, fileutils Pre-Depends: libacl1 (>= 2.2.11-1), libc6 (>= 2.6-1), libselinux1 (>= 2.0.15) Conflicts: stat Description: The GNU core utilities This package contains the essential basic system utilities. . Specifically, this package includes: basename cat chgrp chmod chown chroot cksum comm cp csplit cut date dd df dir dircolors dirname du echo env expand expr factor false fmt fold groups head hostid id install join link ln logname ls md5sum mkdir mkfifo mknod mv nice nl nohup od paste pathchk pinky pr printenv printf ptx pwd readlink rm rmdir sha1sum seq shred sleep sort split stat stty sum sync tac tail tee test touch tr true tsort tty uname unexpand uniq unlink users vdir wc who whoami yes Original-Maintainer: Michael Stone 

还有另外一种方法,可能有点傻,但比以前快一些:)只是错误输入一个命令,你将获得正确的命令名称和包来自。

样本输出:

 pawel@pawel-desktop:/var/www$ sfn No command 'sfn' found, did you mean: Command 'sn' from package 'mono-devel' (main) Command 'sfc' from package 'syfi-bin' (universe) Command 'svn' from package 'subversion' (main) sfn: command not found 

从命令名称,您可以使用’type’和’dpkg’命令来确定负责其安装的软件包。 例如,要找出哪个软件包安装了命令’who’,您可以在命令提示符处执行以下命令:

 $ type who who is /usr/bin/who $ dpkg -S /usr/bin/who coreutils: /usr/bin/who 

你也可以用一行来做:

 dpkg -S $(which command) 

例如,我想知道什么包包含ls

 dpkg -S $(which ls) 

这是输出:

 coreutils: /bin/ls 

所以现在我知道ls命令/ bin / ls文件来自coreutils包。

现在采用完全不同的方法。

转到packages.ubuntu.com并跟随你的鼻子。 特别是,向下滚动到“搜索包的内容”并输入文件名或系统命令。

  1. 下拉到命令提示符(菜单>应用程序>附件>终端)
  2. 输入dpkg-query --search 'command'其中’command’是您尝试查找其拥有包的命令。