3
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

dnfコマンドについて~備忘録~

Posted at

##そもそもdnfとは

yumの後継者であるパッケージ管理ソフトです。
centos8ではデフォルトになっている管理ソフトですが、ネットの記事を確認するとyumがまだまだ多い気がします。
自分は基本的に脳死状態でdnfコマンドを使っています。

バージョン確認

dnf --version
Failed to set locale, defaulting to C.UTF-8
4.2.23
  Installed: dnf-0:4.2.23-4.el8.noarch at Mon May 31 12:54:12 2021
  Built    : CentOS Buildsys <bugs@centos.org> at Tue Aug  4 18:52:03 2020

  Installed: rpm-0:4.14.3-4.el8.x86_64 at Mon May 31 12:53:45 2021
  Built    : CentOS Buildsys <bugs@centos.org> at Tue J

##dnfに関するファイル群

・/var/cache/dnf:キャッシュファイル
・/etc/dnf/dnf.conf:設定ファイル
・/etc/yum.repos.d/:リポジトリ用のファイルを置くディレクトリです。

##リポジトリ一覧を表示する方法(--all)

dnf repolist --all
Failed to set locale, defaulting to C.UTF-8
repo id                            repo name                            status
appstream                          CentOS Linux 8 - AppStream           enabled
appstream-source                   CentOS Linux 8 - AppStream - Source  disabled
baseos                             CentOS Linux 8 - BaseOS              enabled
baseos-source                      CentOS Linux 8 - BaseOS - Source     disabled
cr                                 CentOS Linux 8 - ContinuousRelease   disabled
debuginfo                          CentOS Linux 8 - Debuginfo           disabled
devel                              CentOS Linux 8 - Devel WARNING! FOR  disabled
epel                               Extra Packages for Enterprise Linux  enabled
epel-debuginfo                     Extra Packages for Enterprise Linux  disabled
epel-modular                       Extra Packages for Enterprise Linux  enabled
~~

ほぼdisabledになっていて使っていないですが、、
なんのリポジトリなのかも把握していないです。

##有効なリポジトリを表示する方法(--enabled)

$dnf repolist
Failed to set locale, defaulting to C.UTF-8
repo id                    repo name
appstream                  CentOS Linux 8 - AppStream
baseos                     CentOS Linux 8 - BaseOS
epel                       Extra Packages for Enterprise Linux 8 - x86_64
epel-modular               Extra Packages for Enterprise Linux Modular 8 - x86_64
extras                     CentOS Linux 8 - Extras
mysql-connectors-community MySQL Connectors Community
mysql-tools-community      MySQL Tools Community
mysql80-community          MySQL 8.0 Community Server
remi-modular               Remi's Modular repository for Enterprise Linux 8 - x86_64
remi-safe                  Safe Remi's RPM repository for Enterprise Linux 8 - x86_64


全体の10%くらいしか使ってないですね、、

##無効なリポジトリを表示する方法(--disabled)

$ dnf repolist --disabled
Failed to set locale, defaulting to C.UTF-8
repo id                            repo name
appstream-source                   CentOS Linux 8 - AppStream - Source
baseos-source                      CentOS Linux 8 - BaseOS - Source
cr                                 CentOS Linux 8 - ContinuousRelease
debuginfo                          CentOS Linux 8 - Debuginfo
devel                              CentOS Linux 8 - Devel WARNING! FOR BUILDROOT USE ONLY!
epel-debuginfo                     Extra Packages for Enterprise Linux 8 - x86_64 - Debug
epel-modular-debuginfo             Extra Packages for Enterprise Linux Modular 8 - x86_64 - Debug
epel-modular-source                Extra Packages for Enterprise Linux Modular 8 - x86_64 - Source
epel-playground                    Extra Packages for Enterprise Linux 8 - Playground - x86_64
epel-playground-debuginfo          Extra Packages for Enterprise Linux 8 - Playground - x86_64 - Debug
epel-playground-source             Extra Packages for Enterprise Linux 8 - Playground - x86_64 - Source
epel-source                        Extra Packages for Enterprise Linux 8 - x86_64 - Source
epel-testing                       Extra Packages for Enterprise Linux 8 - Testing - x86_64
epel-testing-debuginfo             Extra Packages for Enterprise Linux 8 - Testing - x86_64 - Debug
epel-testing-modular               Extra Packages for Enterprise Linux Modular 8 - Testing - x86_64
epel-testing-modular-debuginfo     Extra Packages for Enterprise Linux Modular 8 - Testing - x86_64 - Debug
epel-testing-modular-source        Extra Packages for Enterprise Linux Modular 8 - Testing - x86_64 - Source
epel-testing-source                Extra Packages for Enterprise Linux 8 - Testing - x86_64 - Source
extras-source                      CentOS Linux 8 - Extras - Source
fasttrack                          CentOS Linux 8 - FastTrack
ha                                 CentOS Linux 8 - HighAvailability
media-appstream                    CentOS Linux 8 - Media - AppStream
media-baseos                       CentOS Linux 8 - Media - BaseOS
mysql-cluster-7.5-community        MySQL Cluster 7.5 Community
mysql-cluster-7.5-community-source MySQL Cluster 7.5 Community - Source
mysql-cluster-7.6-community        MySQL Cluster 7.6 Community
mysql-cluster-7.6-community-source MySQL Cluster 7.6 Community - Source
mysql-cluster-8.0-community        MySQL Cluster 8.0 Community
mysql-cluster-8.0-community-source MySQL Cluster 8.0 Community - Source
mysql-connectors-community-source  MySQL Connectors Community - Source
mysql-tools-community-source       MySQL Tools Community - Source
mysql-tools-preview                MySQL Tools Preview
mysql-tools-preview-source         MySQL Tools Preview - Source
mysql55-community                  MySQL 5.5 Community Server
mysql55-community-source           MySQL 5.5 Community Server - Source
mysql56-community                  MySQL 5.6 Community Server
mysql56-community-source           MySQL 5.6 Community Server - Source
mysql57-community                  MySQL 5.7 Community Server
mysql57-community-source           MySQL 5.7 Community Server - Source
mysql80-community-source           MySQL 8.0 Community Server - Source
plus                               CentOS Linux 8 - Plus
plus-source                        CentOS Linux 8 - Plus - Source
powertools                         CentOS Linux 8 - PowerTools
remi                               Remi's RPM repository for Enterprise Linux 8 - x86_64
remi-debuginfo                     Remi's RPM repository for Enterprise Linux 8 - x86_64 - debuginfo
remi-modular-test                  Remi's Modular testing repository for Enterprise Linux 8 - x86_64
remi-safe-debuginfo                Remi's RPM repository for Enterprise Linux 8 - x86_64 - debuginfo
remi-test                          Remi's test RPM repository for Enterprise Linux 8 - x86_64
remi-test-debuginfo                Remi's test RPM repository for Enterprise Linux 8 - x86_64 - debugin

使われていないレポジトリめっちゃありますね。
自分mysqlはversion8を使ってますんでそれ以外はいらないかもですね。

##dnf履歴確認

$ dnf history
Failed to set locale, defaulting to C.UTF-8
ID     | Command line              | Date and time    | Action(s)      | Altered
--------------------------------------------------------------------------------
    18 | install telnet            | 2021-06-08 22:43 | Install        |    1   
    17 | install postfix           | 2021-06-08 21:55 | Install        |    1   
    16 | -y install langpacks-ja   | 2021-06-07 00:46 | Install        |    1   
    15 | --enablerepo=remi install | 2021-06-04 00:10 | Install        |   37   
    14 | install php-pdo php-json  | 2021-06-02 20:01 | Upgrade        |   15   
    13 | install wget              | 2021-06-02 19:48 | Install        |    1   
    12 | -y install mysql-communit | 2021-06-02 00:16 | I, O           |   14   
    11 | localinstall http://dev.m | 2021-06-02 00:08 | Install        |    1   
    10 | update                    | 2021-06-01 21:48 | Upgrade        |    2   
     9 | install -y lsof           | 2021-06-01 19:54 | Install        |    1   
     8 | update                    | 2021-05-31 21:52 | I, U           |  323 EE
     7 | --enablerepo=remi install | 2021-05-31 19:50 | Install        |   27 EE
     6 | install php-bcmath        | 2021-05-31 19:28 | Install        |    1   
     5 | module install php:remi-8 | 2021-05-31 19:21 | I, U           |   44   
     4 | install https://rpms.remi | 2021-05-31 19:16 | I, O, U        |    7   
     3 | -y install expect httpd-d | 2021-05-31 19:08 | I, U           |   59   
     2 | -y update                 | 2020-02-04 13:32 | I, U           |   44 EE
     1 |                           | 2020-02-04 13:28 | Install        |  620 EE


前回の実行telnet をインストールしてますね。

##詳細情報を出力
dnf history info ID

前回のインストールしたtelnetの詳細を見てみましょう。IDが18だったので dnf history info 18 で確認します。

$ dnf history info 18
Failed to set locale, defaulting to C.UTF-8
Transaction ID : 18
Begin time     : Tue Jun  8 22:43:10 2021
Begin rpmdb    : 780:42e1a04c8966d87ca68cbae189750dbc18c24de4
End time       : Tue Jun  8 22:43:11 2021 (1 seconds)
End rpmdb      : 781:d69f533e4d9e377771617d639ef62030d5cd301d
User           :  <m1>
Return-Code    : Success
Releasever     : 8
Command Line   : install telnet
Comment        : 
Packages Altered:
    Install telnet-1:0.17-76.el8.x86_64 @appstream

telnetのインストール情報の詳細が確認できますね。

##キャッシュクリアー

dnf clean all

とりあえず以上。

3
3
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
3
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?