网站搜索

如何使用 8 个有用的“Debian Goodies Utilities”来管理 Debian 软件包


Debian-goodies 是一个软件包,其中包括用于管理 Debian 及其衍生系统(例如 Ubuntu、Kali Linux)的工具箱式实用程序。该软件包下的实用程序以与许多公认的 shell 工具结合的方式开发,并且还包含其他工具,因为它们不能在基于 Debian 的 Linux 发行版上开发为自己的软件包。

在本指南中,我们将了解如何使用 debian-goodies 包下的实用程序,其中包括 dglobdebgetdpigs<dgrepdebmanycheckrestartpopbugswhich-pkg-broke强>。

下面我们来看看各个工具的说明:

  1. dglob – 生成与模式匹配的包名称列表
  2. dgrep – 在给定包中的所有文件中搜索正则表达式
  3. dpigs – 显示哪些已安装的软件包占用了最多的磁盘空间
  4. debget – 在 APT 数据库中获取软件包的 .deb
  5. debmany – 选择已安装或已删除软件包的联机帮助页
  6. checkrestart – 查找并重新启动使用过时版本的升级文件的进程
  7. popbugs – 根据您使用的软件包显示自定义的发布关键错误报告
  8. which-pkg-broke – 捕获哪个包可能破坏了另一个包

这些是非常有用的实用程序,与其他 shell 工具一起使用时,可以使系统管理变得更加容易。事实上,Debian-goodies 工具比 dpkg 和 apt 工具等标准工具显示更多有关软件包的信息。

另请阅读:学习 15 个 dpkg 命令和 25 个 apt-get 命令来管理 Debian 及其衍生版本中的软件包。

如何在 Debian、Ubuntu 和 Linux Mint 中安装 Debian-goodies

要安装 debian-goodies 软件包,请运行以下命令。

sudo apt-get install debian-goodies

一旦安装了 debian-goodies 软件包,现在就可以在本文的其余部分中查看该软件包提供的每个实用程序的用法了。

如何使用 Debian-Goodies 实用程序

1. dglob 实用程序

dglob 生成模式中指定的包或文件的名称列表。要生成所有包的名称,只需运行 dglob 或包含 -a 选项即可。

root@tecmint:~# dglob 
fonts-sil-abyssinica
libatk-adaptor
openoffice-onlineupdate
libvorbisfile3
libquadmath0
libxkbfile1
linux-sound-base
python-apt-common
python-gi-cairo
libgs9-common
libgom-1.0-common
libqt5qml5
libgtk2.0-bin
libregexp-common-perl
evolution-data-server
libaccount-plugin-generic-oauth
bind9-host
libhtml-tagset-perl
iputils-ping
libcgmanager0
evince
...

要查明系统上是否存在某个软件包,请使用软件包名称运行dglob。在下面的示例中,我们将搜索 FirefoxApache2debain-goodies

root@tecmint:~# dglob firefox
firefox-locale-en
unity-scope-firefoxbookmarks
firefox
root@tecmint:~# dglob apache2
apache2
apache2-utils
apache2-bin
apache2-data
root@tecmint:~# dglob debian-goodies
debian-goodies

您可以使用 -f 选项打印指定包中所有文件的列表。

root@tecmint:~# dglob -f firefox
/usr/share/doc/firefox-locale-en/copyright
/usr/share/doc/firefox-locale-en/changelog.Debian.gz
/usr/lib/firefox-addons/extensions/[email 
/usr/lib/firefox-addons/extensions/[email 
/usr/lib/firefox/distribution/searchplugins/locale/en-ZA/amazondotcom.xml
/usr/lib/firefox/distribution/searchplugins/locale/en-ZA/google.xml
/usr/lib/firefox/distribution/searchplugins/locale/en-ZA/ddg.xml
/usr/lib/firefox/distribution/searchplugins/locale/en-GB/google.xml
/usr/lib/firefox/distribution/searchplugins/locale/en-GB/amazon-en-GB.xml
/usr/lib/firefox/distribution/searchplugins/locale/en-GB/ddg.xml
/usr/lib/firefox/webapprt/extensions/[email 
/usr/lib/firefox/webapprt/extensions/[email 
/usr/share/unity/scopes/web/firefoxbookmarks.scope
/usr/share/unity-scopes/firefoxbookmarks/unity_firefoxbookmarks_daemon.py
/usr/share/unity-scopes/firefoxbookmarks/__init__.py
/usr/share/doc/unity-scope-firefoxbookmarks/copyright
....

2. 如何使用 dgrep 实用程序

dgreb 实用程序用于搜索指定包名称中的文件的正则表达式。它基本上通过系统上安装的软件包文件进行greps,并且除了少数之外,大多数使用的选项都是与 grep 一起使用的选项。

要指定模式,请使用 -e 选项,如下所示。

root@tecmint:~# dgrep -e README apache2
/usr/sbin/apache2ctl:        echo Setting ulimit failed. See README.Debian for more information. >&2
/usr/sbin/a2enmod:                info(     "See /usr/share/doc/apache2/README.Debian.gz on "
/etc/apache2/mods-available/autoindex.conf:	AddIcon /icons/hand.right.gif README
/etc/apache2/mods-available/autoindex.conf:	# ReadmeName is the name of the README file the server will look for by
/etc/apache2/mods-available/autoindex.conf:	ReadmeName README.html
/etc/apache2/mods-available/cache_disk.conf:	# /usr/share/doc/apache2/README.Debian, and the htcacheclean(8)
/etc/apache2/sites-available/default-ssl.conf:		#   /usr/share/doc/apache2/README.Debian.gz for more info.
...

要打印要打印输出的每个输入文件的名称,请使用 -l 选项。

root@tecmint:~# dgrep -l conf apache2
/usr/sbin/a2query
/usr/sbin/apache2ctl
/usr/sbin/a2enmod
/usr/share/doc/apache2/migrate-sites.pl
/usr/share/doc/apache2/copyright
/usr/share/doc/apache2/README.multiple-instances
/usr/share/doc/apache2/examples/setup-instance
/usr/share/doc/apache2/examples/secondary-init-script
/usr/share/doc/apache2/README.backtrace
/usr/share/apache2/apache2-maintscript-helper
/usr/share/lintian/overrides/apache2
/etc/bash_completion.d/apache2
/etc/init.d/apache2
...

要仅显示匹配行的匹配部分,请使用 -o 选项。

root@tecmint:~# dgrep -o conf apache2
/usr/sbin/a2query:conf
/usr/sbin/a2query:conf
/usr/sbin/a2query:conf
/usr/sbin/a2query:conf
/usr/sbin/a2query:conf
/usr/sbin/a2query:conf
/usr/sbin/a2query:conf
/usr/sbin/a2query:conf
...

3. 如何使用 dpigs 实用程序

该实用程序用于显示占用系统空间最多的软件包。这非常重要,尤其是当您空间不足并想要删除一些软件包时。

要找出占用系统空间最多的软件包,只需运行此命令即可。

root@tecmint:~# dpigs
158762 linux-image-extra-4.2.0-16-generic
157066 linux-image-extra-3.19.0-31-generic
155037 wine1.8-amd64
143459 wine1.8-i386
103364 linux-firmware
100412 firefox
96741 openjdk-8-jre-headless
96302 libgl1-mesa-dri
90808 thunderbird
90652 liboxideqtcore0

您可以使用 -H 选项以人类可读的格式读取包大小。

root@tecmint:~# dpigs -H
 155.0M linux-image-extra-4.2.0-16-generic
 153.4M linux-image-extra-3.19.0-31-generic
 151.4M wine1.8-amd64
 140.1M wine1.8-i386
 100.9M linux-firmware
  98.1M firefox
  94.5M openjdk-8-jre-headless
  94.0M libgl1-mesa-dri
  88.7M thunderbird
  88.5M liboxideqtcore0

要指定除默认值 10 之外的给定数量的包,请使用 -n 选项。

root@tecmint:~# dpigs -H -n 15
 155.0M linux-image-extra-4.2.0-16-generic
 153.4M linux-image-extra-3.19.0-31-generic
 151.4M wine1.8-amd64
 140.1M wine1.8-i386
 100.9M linux-firmware
  98.1M firefox
  94.5M openjdk-8-jre-headless
  94.0M libgl1-mesa-dri
  88.7M thunderbird
  88.5M liboxideqtcore0
  87.9M libgl1-mesa-dri
  81.3M openoffice-core04
  77.8M fonts-horai-umefont
  64.2M linux-headers-4.2.0-16
  61.5M ubuntu-docs

要寻求使用 dpigs 的帮助,请使用 -h 选项。

root@tecmint:~# dpigs -h
Usage: dpigs [options]

Options:
  -n, --lines=N
    Display the N largest packages on the system (default 10).
  -s, --status=status-file
    Use status-file instead of the default dpkg status file.
  -S, --source
    Display the largest source packages of binary packages installed
    on the system.
  -H, --human-readable
    Display package sizes in human-readable format (like ls -lh or du -h)
  -h, --help
    Display this message.

4. 如何使用 debget 实用程序

debget 用于从 APT 的软件包数据库中获取软件包的给定 .deb。在接下来的示例中,我们将为 apache2、zip 和 tar 实用程序获取 .deb 文件。

root@tecmint:~# debget apache2
(apache2 -> 2.4.12-2ubuntu2)
root@tecmint:~# debget zip
(zip -> 3.0-11)
Downloading zip from http://in.archive.ubuntu.com/ubuntu/pool/main/z/zip/zip_3.0-11_amd64.deb
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--   0  154k    0  1211    0     0   2039      0  0:01:17 --:--:--  0:01:17  47  154k   47 75059    0     0  44694      0  0:00:03  0:00:01  0:00:02 100  154k  100  154k    0     0  74182      0  0:00:02  0:00:02 --:--:-- 74220
root@tecmint:~# debget tar 
(tar -> 1.27.1-2)
Downloading tar from http://in.archive.ubuntu.com/ubuntu/pool/main/t/tar/tar_1.27.1-2_amd64.deb
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--  15  191k   15 30155    0     0  48338      0  0:00:04 --:--:--  0:00:04 100  191k  100  191k    0     0   201k      0 --:--:-- --:--:-- --:--:--  201k

所有获取的 .deb 包。

root@tecmint:~# dir -hl
total 348K
-rw-r--r-- 1 root root 86K Dec 30 12:46 apache2_2.4.7-1ubuntu4.6_amd64.deb
-rw-r--r-- 1 root root 192K Dec 30 12:46 tar_1.27.1-2_amd64.deb
-rw-r--r-- 1 root root 155K Dec 30 12:46 zip_3.0-11_amd64.deb

5. 如何使用 debmany 实用程序

它用于选择系统上已安装或已卸载软件包的手动输入页面。该实用程序允许您查看包的所有联机帮助页。

您可以将以下一些选项与 debmany 结合使用,以使用您选择的查看器显示联机帮助页:

如果您使用KDE桌面环境,请使用-k选项来使用kfmclient

root@tecmint:~# debmany -k tar

注意:我的系统上没有安装 KDE DE,因此很难显示上述命令的输出。

如果您使用 GNOME 桌面环境,请使用 -g 选项来使用 gnome-open

root@tecmint:~# debmany -g tar

如果您使用 KDE/GNOME/Xfce 桌面环境,请使用 -x 选项来使用 kdg-open

root@tecmint:~# debmany -x tar

确保上述查看器已安装,然后才能使用它们,否则可能会出现错误。

6. 如何使用 checkrestart 实用程序

chechstart 用于查找并重新启动正在使用已升级文件的旧版本的进程。

要对所有进程使用 checkrestart,请使用 -a 选项。

root@tecmint:~# checkrestart -a
lsof: WARNING: can't stat() fuse.gvfsd-fuse file system /run/user/1000/gvfs
      Output information may be incomplete.
Found 30 processes using old versions of upgraded files
(28 distinct programs)
(23 distinct packages)

Of these, 1 seem to contain systemd service definitions or init scripts which can be used to restart them.
The following packages seem to have definitions that could be used
to restart their services:
openssh-server:
	1947	/usr/sbin/sshd
	1889	/usr/sbin/sshd
These are the initd scripts:
service ssh restart
...

要仅指定处理附加到系统上给定包的已删除文件,请使用 -p 选项。

root@tecmint:~# checkrestart -p
lsof: WARNING: can't stat() fuse.gvfsd-fuse file system /run/user/1000/gvfs
      Output information may be incomplete.
Found 0 processes using old versions of upgraded files

您可以使用-v选项生成详细的输出信息。

root@tecmint:~# checkrestart -v
lsof: WARNING: can't stat() fuse.gvfsd-fuse file system /run/user/1000/gvfs
      Output information may be incomplete.
Found 1 processes using old versions of upgraded files
(1 distinct program)
[DEBUG] Process /usr/bin/update-manager (PID: 2027) 
List of deleted files in use:
	/var/cache/apt/pkgcache.bin
	/var/lib/dpkg/status (deleted)
	/var/cache/apt/pkgcache.bin
	/var/lib/dpkg/status (deleted)
	/var/cache/apt/pkgcache.bin
	/var/lib/dpkg/status (deleted)
	/var/cache/apt/pkgcache.bin
	/var/lib/dpkg/status (deleted)
[DEBUG] Running:['dpkg-query', '--search', '/usr/bin/update-manager']
[DEBUG] Reading line from dpkg-query: update-manager: /usr/bin/update-manager

[DEBUG] Found package update-manager for program /usr/bin/update-manager
(1 distinct packages)
[DEBUG] Running:['dpkg-query', '--listfiles', 'update-manager']
These processes (1) do not seem to have an associated init script to restart them:
update-manager:
	2027	/usr/bin/update-manager

7. 如何使用 popbugs 实用程序

它用于根据您系统上常用的软件包显示自定义的发布关键错误列表。当您第一次在没有任何选项的情况下运行 popbugs 时,它会向您显示一条消息,如下所示。

root@tecmint:~# popbugs

There is no popularity-contest data present on your system.  This
probably means that popularity-contest has not yet run since it
was installed.  Try waiting for /etc/cron.daily/popularity-contest to
to collect some data or manually run (as root user):

    /usr/sbin/popularity-contest >/var/log/popularity-contest

要生成popularity-contest日志,请运行以下命令。

root@tecmint:~# /usr/sbin/popularity-contest > /var/log/popularity-contest

要将输出存储在文件中,请使用 –output=/path/to/file 选项。输出文件应该是 html 文件。

root@tecmint:~# popbugs --output=/tmp/output.html

要查看输出文件,请通过指定文件位置从 Web 浏览器打开该文件。

要显示调试信息,请使用 -d 选项。

root@tecmint:~# popbugs --d
POPCON: Adding package zeitgeist-core
POPCON: Adding package upstart
POPCON: Adding package unity-gtk2-module
POPCON: Adding package whoopsie
POPCON: Adding package xserver-xorg-input-evdev
POPCON: Adding package unity-services
POPCON: Adding package zlib1g
POPCON: Adding package xserver-xorg-core
..

8. 如何使用which-pkg-broke实用程序

它用于查找损坏了另一个包的包。有时您的系统可能会被某些软件包破坏,尤其是在升级时。因此 which-pkg-broke 可以帮助您找到破坏系统的软件包或系统上的特定软件包。

要找出损坏 apache2 的软件包,请运行以下命令。

root@tecmint:~# which-pkg-broke apache2 
Package apache2 has no install time info
Package mysql-common has no install time info
Package libaprutil1-ldap has no install time info
Package  has no install time info
Package libmysqlclient18 has no install time info
Package  has no install time info
Package libaprutil1-dbd-sqlite3 has no install time info
Package  has no install time info
Package libaprutil1-dbd-mysql has no install time info
Package apache2-utils has no install time info
Package libpq5 has no install time info
Package apache2-data has no install time info
Package libaprutil1-dbd-pgsql has no install time info
Package libaprutil1-dbd-odbc has no install time info
libacl1:amd64                                          Wed Apr 22 17:31:54 2015
libattr1:amd64                                         Wed Apr 22 17:31:54 2015
insserv                                                Wed Apr 22 17:31:54 2015
libc6:amd64                                            Wed Apr 22 17:31:55 2015
...

概括

还有许多其他实用程序与我们所查看的实用程序相关,我们可以在后续文章中了解它们。希望您发现本指南有用,如果您在使用时遇到任何错误或有任何其他想法需要添加,请发表评论。与 Howtoing 保持联系。