Debian-goodies – 一组适用于 Debian 和 Ubuntu 用户的实用工具

Debian 好东西 是 Debian 及其变体(例如 Ubuntu)的有用实用程序的集合。 这些实用程序提供了一些默认情况下不可用的附加有用命令。 使用这些工具,用户可以发现哪些程序占用更多磁盘空间,更新系统后需要重新启动哪些服务,在包中搜索与模式匹配的文件,根据搜索字符串列出已安装的包等等更多的。 事不宜迟,让我们继续了解这些好东西。

内容

  1. 在 Debian 和 Ubuntu 中安装 Debian-goodies
  2. Debian-goodies – 对 Debian 和 Ubuntu 用户有用的实用程序
    1. 1.检查重启
    2. 2.检查增强
    3. 3.dgrep
    4. 4.dglob
    5. 5. 负债
    6. 6. dpigs
    7. 7. 德布曼
    8. 8. 德布尼
    9. 9. 爆米花
    10. 10. 哪个-pkg-坏了
    11. 11. 主页

在 Debian 和 Ubuntu 中安装 Debian-goodies

debian-goodies 软件包可在 Debian、Ubuntu 和其他 Ubuntu 变体(如 Linux Mint)的官方存储库中找到。

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

$ sudo apt-get install debian-goodies

Debian-goodies 已安装。 让我们继续通过实际示例来探索一些 debian 好东西。

Debian-goodies – 对 Debian 和 Ubuntu 用户有用的实用程序

debian-goodies 包含以下实用程序:

  1. 检查重启
  2. 检查增强
  3. dgrep
  4. dglob
  5. 债务
  6. 小猪
  7. 德布曼
  8. 德布尼
  9. 爆米花
  10. 哪个pkg坏了
  11. 主页

现在让我们看看每个实用程序的用法。

1.检查重启

让我从我最喜欢的一个开始, “检查重启” 公用事业。 安装安全更新时,某些正在运行的应用程序可能仍使用旧库。 为了完全应用安全更新,您需要找到并重新启动所有这些更新。 这就是 Checkrestart 派上用场的地方。 此实用程序将查找哪些进程仍在使用旧版本的库。 然后,您可以重新启动服务。

要检查库升级后需要重新启动哪些守护进程,请运行:

$ sudo checkrestart  [sudo] password for sk:  Found 0 processes using old versions of upgraded files

由于我最近没有执行任何安全更新,所以它什么也没显示。

请注意,Checkrestart 实用程序运行良好。 但是,有一个新的类似工具,名为 “需要重启” 在最新的 Debian 系统上可用。 Needrestart 的灵感来自 checkrestart 实用程序,它的工作完全相同。 Needrestart 得到积极维护并支持更新的技术,例如容器(LXC、Docker)。

以下是 Needrestart 的功能:

  • 支持(但不要求)systemd,
  • 二进制黑名单(即显示管理器),
  • 尝试检测未决的内核升级,
  • 尝试检测需要重启的基于解释器的守护进程(支持 Perl、Python、Ruby),
  • 使用钩子完全集成到 apt/dpkg 中。

它也可以在默认存储库中使用。 因此,您可以使用以下命令安装它:

$ sudo apt-get install needrestart

现在,使用命令检查更新系统后需要重新启动的守护进程列表:

$ sudo needrestart Scanning processes...  Scanning linux images...  Running kernel seems to be up-to-date.  Failed to check for processor microcode upgrades.  No services need to be restarted.  No containers need to be restarted.  No user sessions are running outdated binaries.

好消息是 Needrestart 也适用于其他 Linux 发行版。 例如,您可以在 Arch Linux 及其变体上安装 金子 使用任何 AUR 帮助程序,例如 .

$ yay -S needrestart

2.检查增强

检查增强 实用程序用于查找增强已安装软件包的软件包。 此实用程序将列出所有增强其他软件包但不是运行它所必需的软件包。 您可以使用“-ip”或“–installed-packages”标志找到单个包或所有已安装包的增强功能。

例如,我将列出针对 瘸子 包裹。

$ check-enhancements gimp gimp => gimp-data: Installed: (none) Candidate: 2.8.22-1 gimp => gimp-gmic: Installed: (none) Candidate: 1.7.9+zart-4build3 gimp => gimp-gutenprint: Installed: (none) Candidate: 5.2.13-2 gimp => gimp-help-ca: Installed: (none) Candidate: 2.8.2-0.1 gimp => gimp-help-de: Installed: (none) Candidate: 2.8.2-0.1 gimp => gimp-help-el: Installed: (none) Candidate: 2.8.2-0.1 gimp => gimp-help-en: Installed: (none) Candidate: 2.8.2-0.1 gimp => gimp-help-es: Installed: (none) Candidate: 2.8.2-0.1 gimp => gimp-help-fr: Installed: (none) Candidate: 2.8.2-0.1 gimp => gimp-help-it: Installed: (none) Candidate: 2.8.2-0.1 gimp => gimp-help-ja: Installed: (none) Candidate: 2.8.2-0.1 gimp => gimp-help-ko: Installed: (none) Candidate: 2.8.2-0.1 gimp => gimp-help-nl: Installed: (none) Candidate: 2.8.2-0.1 gimp => gimp-help-nn: Installed: (none) Candidate: 2.8.2-0.1 gimp => gimp-help-pt: Installed: (none) Candidate: 2.8.2-0.1 gimp => gimp-help-ru: Installed: (none) Candidate: 2.8.2-0.1 gimp => gimp-help-sl: Installed: (none) Candidate: 2.8.2-0.1 gimp => gimp-help-sv: Installed: (none) Candidate: 2.8.2-0.1 gimp => gimp-plugin-registry: Installed: (none) Candidate: 7.20140602ubuntu3 gimp => xcftools: Installed: (none) Candidate: 1.0.7-6

要列出所有已安装软件包的增强功能,请运行:

$ check-enhancements -ip autoconf => autoconf-archive: Installed: (none) Candidate: 20170928-2 btrfs-progs => snapper: Installed: (none) Candidate: 0.5.4-3 ca-certificates => ca-cacert: Installed: (none) Candidate: 2011.0523-2 cryptsetup => mandos-client: Installed: (none) Candidate: 1.7.19-1 dpkg => debsig-verify: Installed: (none) Candidate: 0.18 [...]

3.dgrep

顾名思义, dgrep 用于根据给定的正则表达式搜索指定包中的所有文件。 例如,我将搜索包含正则表达式的文件 “文本” 在 Vim 包中。

$ sudo dgrep "text" vim Binary file /usr/bin/vim.tiny matches /usr/share/doc/vim-tiny/copyright: that they must include this license text. You can also distribute /usr/share/doc/vim-tiny/copyright: include this license text. You are also allowed to include executables /usr/share/doc/vim-tiny/copyright: 1) This license text must be included unmodified. /usr/share/doc/vim-tiny/copyright: text under a) applies to those changes. /usr/share/doc/vim-tiny/copyright: context diff. You can choose what license to use for new code you /usr/share/doc/vim-tiny/copyright: context diff will do. The e-mail address to be used is /usr/share/doc/vim-tiny/copyright: On Debian systems, the complete text of the GPL version 2 license can be [...]

dgrep 支持 grep 的大部分选项。 请参阅以下指南来学习 grep 命令。

  • 带有初学者示例的 Grep 命令教程

4.dglob

dglob 实用程序生成与模式匹配的包名称列表。 例如,以下命令将查找与字符串匹配的包列表 “vim”.

$ sudo dglob vim vim-tiny:amd64 vim:amd64 vim-common:all vim-runtime:all

默认情况下,dglob 将仅显示已安装的包。 如果要列出所有软件包(已安装和未安装),请使用 -一个 旗帜。

$ sudo dglob vim -a

5. 负债

债务 实用程序将为 APT 数据库中的软件包下载 .deb。 请注意,它只会下载给定的包,而不是依赖项。

$ debget nano Get:1 https://in.archive.ubuntu.com/ubuntu bionic/main amd64 nano amd64 2.9.3-2 [231 kB] Fetched 231 kB in 2s (113 kB/s)

6. dpigs

这是此系列中另一个有用的补充。 这 小猪 实用程序将查找并显示哪些已安装的软件包占用最多的磁盘空间。

$ dpigs 260644 linux-firmware 167195 linux-modules-extra-4.15.0-20-generic 75186 linux-headers-4.15.0-20 64217 linux-modules-4.15.0-20-generic 55620 snapd 31376 git 31070 libicu60 28420 vim-runtime 25971 gcc-7 24349 g++-7

如您所见,linux-firmware 软件包占用的磁盘空间最多。 默认情况下,它将显示 前10名 占用磁盘空间最多的软件包。 如果要显示更多的包,例如 20,运行以下命令:

$ dpigs -n 20

7. 德布曼

德布曼 实用程序使您可以轻松地从二进制文件中查看手册页 .deb 没有提取它。 你甚至不需要安装 .deb 包。 以下命令显示 nano的手册页 包裹。

$ debman -f nano_2.9.3-2_amd64.deb nano

如果您没有 .deb 包的本地副本,请使用 -p 标志以下载和查看包的手册页,如下所示。

$ debman -p nano nano

建议阅读:

  • 每个 Linux 用户都应该知道的 3 个很好的手册页替代方案

8. 德布尼

已安装的 Debian 软件包不仅有一个手册页,还包括其他文件,如确认、版权和自述文件等。 德布尼 实用程序允许您查看和读取这些文件。

$ debmany vim
选择已安装或已卸载软件包的手册页

使用箭头键选择要查看的文件,然后按 ENTER 键查看所选文件。 按 q 返回主菜单。

如果指定的包没有安装,debmany 将从 APT 数据库下载它。

9. 爆米花

如果您是开发人员,则 爆米花 实用程序将非常有用。 它将根据您使用的软件包(使用 人气竞赛 数据)。 对于那些不知道的人,popularity-contest 软件包设置了一个 cron 作业,该作业将定期匿名地向 Debian 开发人员提交有关该系统上最常用的 Debian 软件包的统计信息。 这些信息有助于 Debian 开发团队做出决定,例如哪些软件包应该放在第一张 CD 上。 它还允许 Debian 团队改进发行版的未来版本,以便最流行的软件包是为新用户自动安装的软件包。

要生成严重错误列表并在默认 Web 浏览器中显示结果,请运行:

$ popbugs

此外,您可以将结果保存在文件中,如下所示。

$ popbugs --output=bugs.txt

10. 哪个-pkg-坏了

哪个pkg坏了 命令将显示给定包的所有依赖项以及安装每个依赖项的时间。 通过使用此信息,您可以轻松找到在升级系统或软件包后哪个软件包可能损坏了另一个软件包。

$ which-pkg-broke vim Package <debconf-2.0> has no install time info debconf Wed Apr 25 08:08:40 2018 gcc-8-base:amd64 Wed Apr 25 08:08:41 2018 libacl1:amd64 Wed Apr 25 08:08:41 2018 libattr1:amd64 Wed Apr 25 08:08:41 2018 dpkg Wed Apr 25 08:08:41 2018 libbz2-1.0:amd64 Wed Apr 25 08:08:41 2018 libc6:amd64 Wed Apr 25 08:08:42 2018 libgcc1:amd64 Wed Apr 25 08:08:42 2018 liblzma5:amd64 Wed Apr 25 08:08:42 2018 libdb5.3:amd64 Wed Apr 25 08:08:42 2018 [...]

11. 主页

主页 实用程序将在您的默认网络浏览器中显示给定包的官方网站。 例如,以下命令将打开 维姆 编辑的主页。

$ dhomepage vim

Debian-goodies 是您武器库中的必备工具。 尽管我们并不经常使用所有这些实用程序,但它们值得学习,我相信它们有时会非常有用。

Debian Debian-goodiesLinuxUbuntu