如何在 Debian 中找到包含程序的软件包?

Lia*_*odi 23 debian apt package-management

我正在使用一个没有top安装程序的最小 Debian 系统。我试图用 安装 top sudo apt-get install top,但是top不是包名。

这似乎top是其他一些包的一部分。我怎样才能找出我应该安装哪个包来获取它?更一般地说,我如何找到包含程序的包?

Chr*_*own 44

直接的答案是procps。您可以通过以下方式自行了解这一点:

# Install apt-file, which allows you to search
# for the package containing a file
sudo apt-get install apt-file

# Update the package/file mapping database
sudo apt-file update

# Search for "top" at the end of a path
apt-file search --regexp '/top$'
Run Code Online (Sandbox Code Playgroud)

最终命令的输出应如下所示:

crossfire-maps: /usr/share/games/crossfire/maps/santo_dominion/magara/well/top
crossfire-maps-small: /usr/share/games/crossfire/maps/santo_dominion/magara/well/top
liece: /usr/share/emacs/site-lisp/liece/styles/top
lxpanel: /usr/share/lxpanel/profile/two_panels/panels/top
procps: /usr/bin/top
quilt: /usr/share/quilt/top
Run Code Online (Sandbox Code Playgroud)

你可以看到它只procps在你的标准 PATH 中提供了一个可执行文件,这给出了它可能是正确的一个线索。您还可以了解更多信息procps以确保它看起来是正确的:

$ apt-cache show procps
Package: procps
Version: 1:3.3.3-3

[...]

Description-en: /proc file system utilities
 This package provides command line and full screen utilities for browsing
 procfs, a "pseudo" file system dynamically generated by the kernel to
 provide information about the status of entries in its process table
 (such as whether the process is running, stopped, or a "zombie").
 .
 It contains free, kill, pkill, pgrep, pmap, ps, pwdx, skill, slabtop,
 snice, sysctl, tload, top, uptime, vmstat, w, and watch.
Run Code Online (Sandbox Code Playgroud)

  • 我比mods链接的帖子更喜欢这个答案。如果没有`--regexp`,搜索结果会变得很糟糕,就像搜索短命名命令(例如**dig**)时的+10000 个结果一样。 (3认同)

gol*_*cks 5

您可以使用 搜索内容apt-cache search ...,尽管它只是包名称和描述的匹配项,有时这还不够。在这种情况下,例如使用

apt-file search top
Run Code Online (Sandbox Code Playgroud)

可能的工作-它发现有一个文件中的所有包top在他们的名字,但对于这一点,是有点滑稽的(它包括setopt.desktop等等)。根据克里斯的回答来完善这个:

apt-file search --regexp 'bin/top$'
Run Code Online (Sandbox Code Playgroud)

这会发现,有结尾(“$”是一个文件路径包ular EXP ression语法标志着结束)的bin/top; 可执行文件总是在 abinsbin目录中。当您找到所需内容时:

apt-get install whatever

在这种情况下whatever显然是procps