質問 :私は通常rpm -qa | grep command
コマンドが属するパッケージを検索します。ただし、greped outには複数のパッケージ名が表示され、検索パターンに一致する間違ったパッケージ名が表示されることもあります。 CentOSでこれを行うためのより良い方法があるかどうかを考えていましたか? –パビトラ
解決策:コマンドが属するパッケージを検索します
必要なのは、以下に示すような単純なコマンドだけです。
形式:
# rpm -qf $(which <command>)
例:
# rpm -qf $(which update-crypto-policies) crypto-policies-scripts-20211116-1.gitae470d6.el8.noarch
(または)
# rpm -qf `which update-crypto-policies`
(または)
または、以下のコマンドを試すこともできます。
形式:
# which <command> | xargs rpm -qf
例:
# which update-crypto-policies | xargs rpm -qf crypto-policies-scripts-20211116-1.gitae470d6.el8.noarch
dnf
を使用することもできます およびyum
同じものを見つけるためのコマンド。
# dnf provides `which update-crypto-policies` crypto-policies-scripts-20210209-1.gitbfb6bed.el8_3.noarch : Tool to switch between crypto policies Repo : baseos Matched from: Filename : /usr/bin/update-crypto-policies crypto-policies-scripts-20210617-1.gitc776d3e.el8.noarch : Tool to switch between crypto policies Repo : baseos Matched from: Filename : /usr/bin/update-crypto-policies crypto-policies-scripts-20211116-1.gitae470d6.el8.noarch : Tool to switch between crypto policies Repo : @System Matched from: Filename : /usr/bin/update-crypto-policies crypto-policies-scripts-20211116-1.gitae470d6.el8.noarch : Tool to switch between crypto policies Repo : baseos Matched from: Filename : /usr/bin/update-crypto-policies
yumの使用:
# yum provides `which update-crypto-policies`を提供します
推奨されない方法:
ただし、rpm -qa
の出力をgrepすると 、その場合、複数のパッケージ名になります。
# rpm -qa |grep crypto crypto-policies-20211116-1.gitae470d6.el8.noarch python3-cryptography-3.2.1-5.el8.x86_64 crypto-policies-scripts-20211116-1.gitae470d6.el8.noarch
ご指摘のとおり、検索パターン「crypto」は複数のパッケージ名と一致するため、別のコマンドを実行して、それが属するパッケージを見つける必要があります。
たとえば、パッケージに含まれているファイルを一覧表示し、以下に示すようにその出力をgrepする必要があります。
# rpm -ql crypto-policies-scripts | grep update-crypto-policies /usr/bin/update-crypto-policies /usr/share/crypto-policies/python/__pycache__/update-crypto-policies.cpython-36.opt-1.pyc /usr/share/crypto-policies/python/__pycache__/update-crypto-policies.cpython-36.pyc /usr/share/crypto-policies/python/update-crypto-policies.py /usr/share/man/man8/update-crypto-policies.8.gz
ただし、このチェックは、rpm -qa
でリストされているすべてのパッケージで実行する必要があります。 指図。したがって、これはパッケージを見つけるための理想的な方法ではありません。
Debian / Ubuntuの場合:
dpkg -S $(which update-crypto-policies)
注 :例で使用されているコマンドは、「update-crypto-policies
」です。 ‘は、システム全体の暗号化ポリシーを設定/変更するために使用されます。選択したコマンドに置き換える必要があります。