ウェブサイト検索

Debian パッケージを管理するための 8 つの便利な「Debian Goodies ユーティリティ」の使用方法


Debian-goodies は、Debian とその派生システム (Ubuntu、Kali Linux など) を管理するために使用されるツールボックス スタイルのユーティリティを含むパッケージです。このパッケージのユーティリティは、多くの認識されているシェル ツールと組み合わせる方法で開発されており、Debian ベースの Linux ディストリビューションでは独自のパッケージとして開発できないため、他のユーティリティも含まれています。

このガイドでは、dglobdebgetdpigs< などの debian-goodies パッケージにあるユーティリティの使用方法を説明します。dgrepdebmanycheckrestartpopbugs、および what-pkg-broke強い>。

以下で各ツールの説明を見てみましょう。

  1. dglob – パターンに一致するパッケージ名のリストを生成します。
  2. dgrep – 指定されたパッケージ内のすべてのファイルの正規表現を検索します。
  3. dpigs – どのインストール済みパッケージがディスク容量を最も多く消費したかを表示します
  4. debget – APT のデータベース内のパッケージの .deb を取得します。
  5. debmany – インストールまたは削除されたパッケージのマンページを選択します
  6. checkrestart – アップグレードされたファイルの古いバージョンを使用しているプロセスを見つけて再起動します。
  7. popbugs – 使用するパッケージに基づいてカスタマイズされたリリースクリティカルなバグ レポートを表示します
  8. どのパッケージが壊れた – どのパッケージが別のパッケージを壊したのかを確認します

これらは、 他のシェル ツールと併用するとシステム管理がはるかに簡単になる非常に便利なユーティリティです。実際、Debian-goodies ツールは、dpkg や apt ツールなどの標準ツールよりもパッケージに関するより多くの情報を表示します。

こちらもお読みください: Debian とその派生製品でパッケージを管理するための 15 個の dpkg コマンドと 25 個の apt-get コマンドを学習します。

Debian、Ubuntu、Linux Mint に Debian グッズをインストールする方法

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 を実行します。以下の例では、FirefoxApache2、およびdebain-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 ユーティリティは、指定されたパッケージ名のファイルを正規表現で検索するために使用されます。基本的に、 システムにインストールされているパッケージのファイルをgrep で検索し、使用されるオプションのほとんどは、いくつかを除いて 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. what-pkg-broke ユーティリティの使用方法

別のパッケージを破損したパッケージを見つけるために使用されます。特にアップグレード時に、特定のパッケージによってシステムが壊れる場合があります。したがって、what-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
...

まとめ

私たちが見てきたものに関連するユーティリティは他にもたくさんありますが、それについては今後の記事で学ぶかもしれません。このガイドがお役に立てば幸いです。使用中にエラーが発生したり、他に追加すべきアイデアがある場合は、コメントを投稿してください。 Tecmint への接続を維持します。