LoginSignup
2
1

運用保守 よく使うrpm yumパッケージの確認コマンドをまとめました。

Last updated at Posted at 2023-10-29

はじめに

運用保守でよく使うパッケージ関連のコマンドをまとめました。
※Debian系のパッケージは記載しておりません。

パッケージのアンインストールとインストールを実施せずにパッケージの確認のみの場合は、安全のために一般ユーザーでコマンドを実行してください

以下の記事を参考にしました。
https://www.wakuwakubank.com/posts/275-linux-yum/#index_id12
https://atmarkit.itmedia.co.jp/ait/articles/1609/13/news024.html
https://reasonable-code.com/yumdownloader/

インストールされているパッケージを検索

$ rpm -qa | grep <パッケージ名>

apacheのパッケージがインストールされていることを確認する

[root@localhost ~]# rpm -qa | grep httpd
httpd-tools-2.4.6-99.el7.centos.1.x86_64
httpd-2.4.6-99.el7.centos.1.x86_64

yum リポジトリ一覧を表示する

有効なリポジトリ一覧を表示する

$ yum repolist
[root@localhost ~]# yum repolist
読み込んだプラグイン:fastestmirror
Repodata is over 2 weeks old. Install yum-cron? Or run: yum makecache fast
Loading mirror speeds from cached hostfile
 * base: ftp.riken.jp
 * epel: ftp.iij.ad.jp
 * extras: ftp.riken.jp
 * remi-safe: ftp.riken.jp
 * updates: ftp.riken.jp
リポジトリー ID                                        リポジトリー名                                                                 状態
!base/7/x86_64                                         CentOS-7 - Base                                                                10,072
!epel/x86_64                                           Extra Packages for Enterprise Linux 7 - x86_64                                 13,771
!extras/7/x86_64                                       CentOS-7 - Extras                                                                 518
!mysql-connectors-community/x86_64                     MySQL Connectors Community                                                        227
!mysql-tools-community/x86_64                          MySQL Tools Community                                                             100

有効と無効のリポジトリ一覧を表示

$ yum repolist all

※途中まで表示

yum repolist all
* base: ftp.riken.jp
 * epel: ftp.iij.ad.jp
 * extras: ftp.riken.jp
 * remi-safe: ftp.riken.jp
 * updates: ftp.riken.jp
リポジトリー ID                     リポジトリー名                  状態
C7.0.1406-base/x86_64               CentOS-7.0.1406 - Base          無効
C7.0.1406-centosplus/x86_64         CentOS-7.0.1406 - CentOSPlus    無効
C7.0.1406-extras/x86_64             CentOS-7.0.1406 - Extras        無効
C7.0.1406-fasttrack/x86_64          CentOS-7.0.1406 - Fasttrack     無効
C7.0.1406-updates/x86_64            CentOS-7.0.1406 - Updates       無効
C7.1.1503-base/x86_64               CentOS-7.1.1503 - Base          無効
C7.1.1503-centosplus/x86_64         CentOS-7.1.1503 - CentOSPlus    無効
C7.1.1503-extras/x86_64             CentOS-7.1.1503 - Extras        無効

インストール済みパッケージ表示

$ yum list installed

インストール済みパッケージ表示からhttpdを検索した

[test@localhost ~]$ yum list installed | grep httpd
Repodata is over 2 weeks old. Install yum-cron? Or run: yum makecache fast
httpd.x86_64                          2.4.6-99.el7.centos.1          @updates
httpd-tools.x86_64 
2.4.6-99.el7.centos.1          @updates

アップデート可能なパッケージを表示

$ yum check-update

アップデート可能なパッケージによくカーネルのパッケージが含まれていないか確認することがあります。
アップデート可能なパッケージにカーネルが含まれていないか検索する

[test@localhost ~]$ yum check-update | grep kernel
kernel.x86_64                         3.10.0-1160.102.1.el7    updates
kernel-tools.x86_64                   3.10.0-1160.102.1.el7    updates
kernel-tools-libs.x86_64              3.10.0-1160.102.1.el7    updates

全パッケージ情報を表示

どのリポジトリにインストール予定のパッケージが含まれているか確認出来ます。
インストール済みのパッケージの場合はどのリポジトリからインストールされているか確認出来ます。

httpdインストール済みの場合は

[root@localhost ~]# yum list httpd
読み込んだプラグイン:fastestmirror
Loading mirror speeds from cached hostfile
 * base: ftp.riken.jp
 * epel: ftp.riken.jp
 * extras: ftp.riken.jp
 * remi-safe: ftp.riken.jp
 * updates: ftp.riken.jp
インストール済みパッケージ
httpd.x86_64                                                 2.4.6-99.el7.centos.1                                                  @updates
[root@localhost ~]#

nginxのパッケージはインストール済みではないですがepelリポジトリに含まれています。

[root@localhost ~]# yum list nginx
読み込んだプラグイン:fastestmirror
Loading mirror speeds from cached hostfile
 * base: ftp.riken.jp
 * epel: ftp.riken.jp
 * extras: ftp.riken.jp
 * remi-safe: ftp.riken.jp
 * updates: ftp.riken.jp
利用可能なパッケージ
nginx.x86_64                                                      1:1.20.1-10.el7                                                       epel
[root@localhost ~]#

まとめ

パッケージ周りの確認コマンドはよく本番環境の調査で使用します。
誤って本番環境でパッケージをインストールしてしまう事故を防ぐために、
本記事に記載のコマンドは一般ユーザーで実行してください

この記事に記載のコマンドはよく現場で使用されるため覚えておいた方が良いでしょう

2
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
1