獻給 Debian 和 Ubuntu 用戶的一組實用程序

獻給 Debian 和 Ubuntu 用戶的一組實用程序

編譯自: https://www.ostechnix.com/debian-goodies-a-set-of-useful-utilities-for-debian-and-ubuntu-users/

你使用的是基於 Debian 的系統嗎?如果是,太好了!我今天在這裡給你帶來了一個好消息。先向 “Debian-goodies” 打個招呼,這是一組基於 Debian 系統(比如:Ubuntu、Linux Mint)的有用工具。這些實用工具提供了一些額外的有用的命令,這些命令在基於 Debian 的系統中默認不可用。通過使用這些工具,用戶可以找到哪些程序佔用更多磁盤空間,更新系統後需要重新啟動哪些服務,在一個軟件包中搜索與模式匹配的文件,根據搜索字符串列出已安裝的包等等。在這個簡短的指南中,我們將討論一些有用的 Debian 的好東西。

Debian-goodies – 給 Debian 和 Ubuntu 用戶的實用程序

debian-goodies 包可以在 Debian 和其衍生的 Ubuntu 以及其它 Ubuntu 變體(如 Linux Mint)的官方倉庫中找到。要安裝 debian-goodies,只需簡單運行:

$ sudo apt-get install debian-goodies

debian-goodies 安裝完成後,讓我們繼續看一看一些有用的實用程序。

1、 checkrestart

讓我從我最喜歡的 checkrestart 實用程序開始。安裝某些安全更新時,某些正在運行的應用程序可能仍然會使用舊庫。要徹底應用安全更新,你需要查找並重新啟動所有這些更新。這就是 checkrestart 派上用場的地方。該實用程序將查找哪些進程仍在使用舊版本的庫,然後,你可以重新啟動服務。

在進行庫更新後,要檢查哪些守護進程應該被重新啟動,運行:

$ sudo checkrestart

[sudo] password for sk:

Found 0 processes using old versions of upgraded files

由於我最近沒有執行任何安全更新,因此沒有顯示任何內容。

請注意,checkrestart 實用程序確實運行良好。但是,有一個名為 needrestart 的類似的新工具可用於最新的 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 或者其它任何 AUR 幫助程序來安裝,就像下面這樣:

$ yaourt -S needrestart

在 Fedora:

$ sudo dnf install needrestart

2、 check-enhancements

check-enhancements 實用程序用於查找那些用於增強已安裝的包的軟件包。此實用程序將列出增強其它包但不是必須運行它的包。你可以通過 -ip 或 –installed-packages 選項來查找增強單個包或所有已安裝包的軟件包。

例如,我將列出增強 gimp 包功能的包:

$ 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 包中搜索包含正則表達式 “text” 的文件。

$ 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 將僅顯示已安裝的軟件包。如果要列出所有包(包括已安裝的和未安裝的),使用 -a 標誌。

$ sudo dglob vim -a

5、 debget

debget 實用程序將在 APT 的數據庫中下載一個包的 .deb 文件。請注意,它只會下載給定的包,不包括依賴項。

$ debget nano

Get:1 http://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 實用程序將查找並顯示那些佔用磁盤空間最多的已安裝包。

$ 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. debman

debman 實用程序允許你輕鬆查看二進制文件 .deb 中的手冊頁而不提取它。你甚至不需要安裝 .deb 包。以下命令顯示 nano 包的手冊頁。

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

如果你沒有 .deb 軟件包的本地副本,使用 -p 標誌下載並查看包的手冊頁。

$ debman -p nano nano

建議閱讀:

  • 每個 Linux 用戶都應該知道的 3 個 man 的替代品

8、 debmany

安裝的 Debian 包不僅包含手冊頁,還包括其它文件,如確認、版權和自述文件等。debmany 實用程序允許你查看和讀取那些文件。

$ debmany vim

獻給 Debian 和 Ubuntu 用戶的一組實用程序

使用方向鍵選擇要查看的文件,然後按回車鍵查看所選文件。按 q 返回主菜單。

如果未安裝指定的軟件包,debmany 將從 APT 數據庫下載並顯示手冊頁。應安裝 dialog 包來閱讀手冊頁。

9、 popbugs

如果你是開發人員,popbugs 實用程序將非常有用。它將根據你使用的包顯示一個定製的發佈關鍵 bug 列表(使用 popularity-contest 數據)。對於那些不關心的人,popularity-contest 包設置了一個 cron (定時)任務,它將定期匿名向 Debian 開發人員提交有關該系統上最常用的 Debian 軟件包的統計信息。這些信息有助於 Debian 做出決定,例如哪些軟件包應該放在第一張 CD 上。它還允許 Debian 改進未來的發行版本,以便為新用戶自動安裝最流行的軟件包。

要生成嚴重 bug 列表並在默認 Web 瀏覽器中顯示結果,運行:

$ popbugs

此外,你可以將結果保存在文件中,如下所示。

$ popbugs --output=bugs.txt

10、 which-pkg-broke

此命令將顯示給定包的所有依賴項以及安裝每個依賴項的時間。通過使用此信息,你可以在升級系統或軟件包之後輕鬆找到哪個包可能會在什麼時間損壞了另一個包。

$ which-pkg-broke vim

Package 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

dhomepage 實用程序將在默認 Web 瀏覽器中顯示給定包的官方網站。例如,以下命令將打開 Vim 編輯器的主頁。

$ dhomepage vim

這就是全部了。Debian-goodies 是你武器庫中必備的工具。即使我們不經常使用所有這些實用程序,但它們值得學習,我相信它們有時會非常有用。

我希望這很有用。更多好東西要來了。敬請關注!

乾杯!


via: https://www.ostechnix.com/debian-goodies-a-set-of-useful-utilities-for-debian-and-ubuntu-users/

作者: SK 選題: lujun9972 譯者: MjSeven 校對: wxy

本文由 LCTT 原創編譯, Linux中國 榮譽推出


分享到:


相關文章: