0.はじめに
普段Linuxで必要なパッケージをインストールする場合はdnf install package
などでインストールしていますが、これに慣れきっていると、いざインシデントが発生したり、新しいツールの詳細が知りたくてパッケージ詳細が見たい!というときに調べ方が分からず・・・という事になります。
インストールされるrpmパッケージを確認する方法を理解しておけば、こんなコマンド、ファイルも存在していたのか。という発見にもつながりますので手段を確認しておいて損はありません。
本稿では一例として、リモートホストにssh接続するために必要なopenssh-clients
パッケージを確認してみましょう。
1.パッケージの情報を表示する
rpm -qi package
実行例
[yoyo@AL ~]$ rpm -qi openssh-clients
Name : openssh-clients
Version : 8.7p1
Release : 38.el9
Architecture: x86_64
Install Date: Tue May 21 10:46:49 2024
Group : Unspecified
Size : 2145557
License : BSD
Signature : RSA/SHA256, Tue Apr 2 17:53:22 2024, Key ID d36cb86cb86b3716
Source RPM : openssh-8.7p1-38.el9.src.rpm
Build Date : Tue Apr 2 16:52:30 2024
Build Host : x64-builder02.almalinux.org
Packager : AlmaLinux Packaging Team <packager@almalinux.org>
Vendor : AlmaLinux
URL : http://www.openssh.com/portable.html
Summary : An open source SSH client applications
Description :
OpenSSH is a free version of SSH (Secure SHell), a program for logging
into and executing commands on a remote machine. This package includes
the clients necessary to make encrypted connections to SSH servers.
8.7p1のpはpatchを意味します。この場合はバージョン8.7の初回(1回目)のパッチが当たっている事を意味します。
el9はEnterprise Linux9の略で、RHEL9とその派生のディストリビューションを意味します。
例えばRelease:38.el9は、38番目のリリースでRHEL9系統向けのリリースである事を意味します。
2.パッケージに含まれるファイルを表示
rpm -ql package
rpmパッケージが提供するファイルを表示する事ができます。
実行例
[yoyo@AL ~]$ rpm -ql openssh-clients
/etc/ssh/ssh_config
/etc/ssh/ssh_config.d
/etc/ssh/ssh_config.d/50-redhat.conf
/usr/bin/scp
/usr/bin/sftp
/usr/bin/ssh
/usr/bin/ssh-add
/usr/bin/ssh-agent
/usr/bin/ssh-copy-id
/usr/bin/ssh-keyscan
/usr/lib/.build-id
/usr/lib/.build-id/3b
/usr/lib/.build-id/3b/e7c97c1a34bc09eaff83a1ba56584431a2279c
/usr/lib/.build-id/45
/usr/lib/.build-id/45/215b12d3cbea348533dc617a288fe9ca441710
/usr/lib/.build-id/56
/usr/lib/.build-id/56/171f3b9bcacbf35d60877269db0ecef914ace6
/usr/lib/.build-id/7b
/usr/lib/.build-id/7b/cc5a7abeb94743b20a40ccf4c4179d32250446
/usr/lib/.build-id/ce
/usr/lib/.build-id/ce/449959a87ef036c7e4664a1446188098a85a98
/usr/lib/.build-id/d6
/usr/lib/.build-id/d6/7811927e4017f0e0c04fb99ab04021a33cc478
/usr/lib/.build-id/ef
/usr/lib/.build-id/ef/e881104af5509e6b6a28a82d710550bd693152
/usr/lib/.build-id/f5
/usr/lib/.build-id/f5/0427ae4cf5c69966a534f397d139c8008c796f
/usr/lib/systemd/user/ssh-agent.service
/usr/libexec/openssh/ssh-pkcs11-helper
/usr/libexec/openssh/ssh-sk-helper
/usr/share/man/man1/scp.1.gz
/usr/share/man/man1/sftp.1.gz
/usr/share/man/man1/ssh-add.1.gz
/usr/share/man/man1/ssh-agent.1.gz
/usr/share/man/man1/ssh-copy-id.1.gz
/usr/share/man/man1/ssh-keyscan.1.gz
/usr/share/man/man1/ssh.1.gz
/usr/share/man/man5/ssh_config.5.gz
/usr/share/man/man8/ssh-pkcs11-helper.8.gz
/usr/share/man/man8/ssh-sk-helper.8.gz
これを見ると、ssh_configファイルとそれにインクルードされる50-redhat.confファイルが提供されている事、コマンドとしてはscp,sftp,ssh,ssh-add,ssh-agent,ssh-copy-id,ssh-keygenコマンドが提供されている事が分かります。
また、それぞれのマニュアルページを圧縮したgzデータも提供されている事が分かります。
man scp
コマンドを実行した場合はこのgzデータが解凍されて表示されます。
/usr/binディレクトリは一般ユーザが使用できるコマンドやプログラムを格納するディレクトリです。新たなパッケージをインストールした際に実行できるようになるユーザ用のコマンド類はここに格納されます。
3.依存しているファイル名を表示
rpm -qR package
この結果のうち、等号・不等号がないものは特定のファイルやコマンドが必要である事、等号・不等号があるものは、そのバージョンが必要である事を意味します。
以下の場合はlibc.so.6(64bit版)ライブラリのGLIBC_2.14という関数あるいは変数が必要である事を意味します。
libc.so.6(GLIBC_2.14)(64bit)
実行例
[yoyo@AL ~]$ rpm -qR openssh-clients
/bin/sh
/bin/sh
/usr/bin/sh
config(openssh-clients) = 8.7p1-38.el9
crypto-policies >= 20200610-1
libc.so.6()(64bit)
libc.so.6(GLIBC_2.14)(64bit)
libc.so.6(GLIBC_2.15)(64bit)
libc.so.6(GLIBC_2.17)(64bit)
libc.so.6(GLIBC_2.2.5)(64bit)
libc.so.6(GLIBC_2.25)(64bit)
libc.so.6(GLIBC_2.26)(64bit)
libc.so.6(GLIBC_2.3)(64bit)
libc.so.6(GLIBC_2.3.4)(64bit)
libc.so.6(GLIBC_2.33)(64bit)
libc.so.6(GLIBC_2.34)(64bit)
libc.so.6(GLIBC_2.4)(64bit)
libc.so.6(GLIBC_2.7)(64bit)
libc.so.6(GLIBC_2.8)(64bit)
libcrypt.so.2()(64bit)
libcrypto.so.3()(64bit)
libcrypto.so.3(OPENSSL_3.0.0)(64bit)
libedit.so.0()(64bit)
libfido2.so.1()(64bit)
libgssapi_krb5.so.2()(64bit)
libgssapi_krb5.so.2(gssapi_krb5_2_MIT)(64bit)
libselinux.so.1()(64bit)
libselinux.so.1(LIBSELINUX_1.0)(64bit)
libz.so.1()(64bit)
openssh = 8.7p1-38.el9
rpmlib(CompressedFileNames) <= 3.0.4-1
rpmlib(FileDigests) <= 4.6.0-1
rpmlib(PayloadFilesHavePrefix) <= 4.0-1
rpmlib(PayloadIsZstd) <= 5.4.18-1
rtld(GNU_HASH)
4.依存しているファイルがインストールされているかを表示
ファイル一覧に加え、ファイルがインストールされているかを表示する事ができます。
rpm -qs package
実行例
[yoyo@AL ~]$ rpm -qs openssh-clients
normal /etc/ssh/ssh_config
normal /etc/ssh/ssh_config.d
normal /etc/ssh/ssh_config.d/50-redhat.conf
normal /usr/bin/scp
normal /usr/bin/sftp
normal /usr/bin/ssh
normal /usr/bin/ssh-add
normal /usr/bin/ssh-agent
normal /usr/bin/ssh-copy-id
normal /usr/bin/ssh-keyscan
normal /usr/lib/.build-id
normal /usr/lib/.build-id/3b
normal /usr/lib/.build-id/3b/e7c97c1a34bc09eaff83a1ba56584431a2279c
normal /usr/lib/.build-id/45
normal /usr/lib/.build-id/45/215b12d3cbea348533dc617a288fe9ca441710
normal /usr/lib/.build-id/56
normal /usr/lib/.build-id/56/171f3b9bcacbf35d60877269db0ecef914ace6
normal /usr/lib/.build-id/7b
normal /usr/lib/.build-id/7b/cc5a7abeb94743b20a40ccf4c4179d32250446
normal /usr/lib/.build-id/ce
normal /usr/lib/.build-id/ce/449959a87ef036c7e4664a1446188098a85a98
normal /usr/lib/.build-id/d6
normal /usr/lib/.build-id/d6/7811927e4017f0e0c04fb99ab04021a33cc478
normal /usr/lib/.build-id/ef
normal /usr/lib/.build-id/ef/e881104af5509e6b6a28a82d710550bd693152
normal /usr/lib/.build-id/f5
normal /usr/lib/.build-id/f5/0427ae4cf5c69966a534f397d139c8008c796f
normal /usr/lib/systemd/user/ssh-agent.service
normal /usr/libexec/openssh/ssh-pkcs11-helper
normal /usr/libexec/openssh/ssh-sk-helper
normal /usr/share/man/man1/scp.1.gz
normal /usr/share/man/man1/sftp.1.gz
normal /usr/share/man/man1/ssh-add.1.gz
normal /usr/share/man/man1/ssh-agent.1.gz
normal /usr/share/man/man1/ssh-copy-id.1.gz
normal /usr/share/man/man1/ssh-keyscan.1.gz
normal /usr/share/man/man1/ssh.1.gz
normal /usr/share/man/man5/ssh_config.5.gz
normal /usr/share/man/man8/ssh-pkcs11-helper.8.gz
normal /usr/share/man/man8/ssh-sk-helper.8.gz
5.パッケージの変更履歴
[yoyo@AL ~]$ rpm -q --changelog openssh-clients
* Fri Jan 05 2024 Dmitry Belyavskiy <dbelyavs@redhat.com> - 8.7p1-38
- Fix Terrapin attack
Resolves: CVE-2023-48795
* Fri Jan 05 2024 Dmitry Belyavskiy <dbelyavs@redhat.com> - 8.7p1-37
- Fix Terrapin attack
Resolves: CVE-2023-48795
・・・以下略・・・
6.コマンドオプションまとめ
パッケージの情報を表示
>rpm -qi package
パッケージが含むファイルを表示
>rpm -ql package
パッケージが依存するファイル名を表示
>rpm -qR package
パッケージが依存するファイルのインストール状況を表示
rpm -qs package
パッケージの変更履歴を表示
>rpm -q --changelog package
qはqueryの略です。qの後にi(information),l(list),R(reqires)が続くと覚えるとコマンドも思い出しやすいかもしれません。
なお、--changelogの場合は短縮系がなさそうでした・・・この辺の正確な情報を知りたい場合はman rpm
コマンドでQUERY OPTION
の項目を参照すると記載されています。