centos8 platform uses dnf / yum to manage software packages

One, the use of dnf

Since centos7, DNF has become the default package manager, while yum is still available

The DNF package manager overcomes some of the bottlenecks of the YUM package manager and improves the user experience, memory footprint, dependency analysis, running speed, etc.

DNF makes it easy to maintain software package groups and automatically resolve dependency problems

 

Description: Liu Hongdian's Architectural Forest is a blog dedicated to architecture, address: https://www.cnblogs.com/architectforest

         The corresponding source code can be obtained here:  https://github.com/liuhongdi/

 Description: Author: Liu association E-mail: [email protected]

 

Second, the package to which dnf belongs

1, the package to which dnf belongs

[root@blog zshfile]# whereis dnf
dnf: /usr/bin/dnf /etc/dnf /usr/share/man/man8/dnf.8.gz

[root@blog zshfile]# rpm -qf /usr/bin/dnf
dnf-4.2.7-7.el8_1.noarch 

 

2, The package that yum belongs to:

[root@blog zshfile]# whereis yum
yum: /usr/bin/yum /etc/yum /etc/yum.conf /usr/share/man/man8/yum.8.gz

[root@blog zshfile]# ll /usr/bin/yum
lrwxrwxrwx 1 root root 5 Dec 19 23:43 /usr/bin/yum -> dnf-3 

Visible yum is a symbolic link, linked to dnf-3

[root@blog zshfile]# whereis dnf-3
dnf-3: /usr/bin/dnf-3

[root@blog zshfile]# rpm -qf /usr/bin/dnf-3
python3-dnf-4.2.7-7.el8_1.noarch 

 

Third, check the dnf version and help

1, view version

[root@blog zshfile]# dnf --version
4.2.7
  Installed: dnf-0:4.2.7-7.el8_1.noarch at Thu 05 Mar 2020 02:18:51 AM GMT
  Built    : CentOS Buildsys <[email protected]> at Thu 19 Dec 2019 03:44:23 PM GMT

  Installed: rpm-0:4.14.2-11.el8_0.x86_64 at Wed 25 Dec 2019 03:36:22 AM GMT
  Built    : CentOS Buildsys <[email protected]> at Tue 01 Oct 2019 01:45:29 PM GMT

 

2. View help

[root@blog zshfile]# dnf --help

 

3. View the manual

[root@blog zshfile]# man dnf

 

Four, dnf operation example: query on repo

1, List the repositories on the system, the status is enabled

[root@blog ~]# dnf repolist

Note: This command is equivalent to dnf repolist enabled

 

2, List all repositories: (including enabled / disabled)

[root@blog ~]# dnf repolist all

 

3. List the repo not installed in the system (the status is disabled)

[root@blog ~]# dnf repolist disabled

 

4. View the details of a repo

[root@blog ~]# dnf repolist  -v BaseOS

Note: You can also use repoinfo

[root@blog ~]# dnf repoinfo BaseOS 

 

Fifth, dnf operation examples: query and search of software packages

1, List all packages:

(Including installable and installed)

[root@blog ~]# dnf list 

Description: The display is divided into two parts:

Installed Packages

Available Packages

Note that the @ character is added before the repo, indicating that it is installed

 

2. List installed packages

[root@blog ~]# dnf list installed  

 

3. List all installable packages:

[root@blog ~]# dnf list available 

 

4. View the details of the package

# info: View detailed information of the rpm package

[root@blog ~]# dnf info zsh
Last metadata expiration check: 0:14:50 ago on Sun 12 Apr 2020 07:27:24 PM CST.
Installed Packages
Name         : zsh
Version      : 5.5.1
Release      : 6.el8
Architecture : x86_64
Size         : 6.9 M
Source       : zsh-5.5.1-6.el8.src.rpm
Repository   : @System
Summary      : Powerful interactive shell
URL: http: // zsh.sourceforge.net/ 
License: MIT
Description  : The zsh shell is a command interpreter usable as an interactive login
             : shell and as a shell script command processor.  Zsh resembles the ksh
             : shell (the Korn shell), but includes many enhancements.  Zsh supports
             : command line editing, built-in spelling correction, programmable
             : command completion, shell functions (with autoloading), a history
             : mechanism, and more.

Available Packages
Name         : zsh
Version      : 5.5.1
Release      : 6.el8_1.2
Architecture : x86_64
Size         : 2.9 M
Source       : zsh-5.5.1-6.el8_1.2.src.rpm
Repository   : BaseOS
Summary      : Powerful interactive shell
URL: http: // zsh.sourceforge.net/ 
License: MIT
Description  : The zsh shell is a command interpreter usable as an interactive login
             : shell and as a shell script command processor.  Zsh resembles the ksh
             : shell (the Korn shell), but includes many enhancements.  Zsh supports
             : command line editing, built-in spelling correction, programmable
             : command completion, shell functions (with autoloading), a history
             : mechanism, and more.

List the information of the two installed and available rpm packages respectively

 

5, search rpm package

[root@blog ~]# dnf search zsh
Last metadata expiration check: 0:14:10 ago on Sun 12 Apr 2020 07:27:24 PM CST.
====================================== Name Exactly Matched: zsh =========================================
zsh.x86_64 : Powerful interactive shell
========================================= Name & Summary Matched: zsh =====================================
zsh-html.noarch : Zsh shell manual in html format
zsh-syntax-highlighting.noarch : Fish shell like syntax highlighting for Zsh
=================================================== Name Matched: zsh ======================================
cekit-zsh-completion.noarch : Container image creation tool

 

6. Query which software package the specified file belongs to?

#provides: See which software package provides a file in the system

[root@blog ~]# dnf provides /usr/bin/zsh
Last metadata expiration check: 0:48:19 ago on Sun 12 Apr 2020 07:27:24 PM CST.
zsh-5.5.1-6.el8.x86_64 : Powerful interactive shell
Repo        : @System
Matched from:
Filename    : /usr/bin/zsh

 

7, List the software packages owned by the specified warehouse

[root@centos8 yum.repos.d]# dnf list --repo epel

 

Six, dnf operation example: installation of the package

1. Installation

[root@blog ~]# dnf install zsh

 

2. Install a rpm package from the specified repo

[root@blog ~]# dnf --enablerepo=BaseOS install zsh 

 

3. Download only, not install

[root@blog ~]# dnf download nginx

After the download is complete, you can find the downloaded rpm package in the current directory

 

Seven, dnf operation example: delete the package

1, delete the specified package

#remove: delete the specified rpm package

[root@blog ~]# yum remove zsh

 

2. Remove cached useless packages

[root@blog ~]# dnf clean all
41 files removed

 

Eight, dnf operation example: update the package

1, Update the specified software package:

[root@blog ~]# dnf update zsh

 

2. Update all packages:

[root@blog ~]# dnf update 

You can also use upgrade

[root@blog ~]# dnf upgrade

 

3. Check the packages that can be updated

[root@blog ~]# dnf check-update

 

Nine, dnf operation example: other operations:

1. View the execution history of DNF commands

[root@blog ~]# dnf history 

 

2. View help for a specific command

#help: View help for the specified command

[root@blog yum.repos.d]$ dnf help list 

 

3. Cache the metadata list of the software package locally:

[root@centos8 yum.repos.d]# dnf makecache

 

Ten, how to edit the dnf repo?

1. Example: Modify dnf repo to use domestic source

Appstream library:

[root@centos8 yum.repos.d]# vi CentOS-AppStream.repo

Modify the baseurl behavior:

baseurl=https://mirrors.aliyun.com/centos/$releasever/AppStream/$basearch/os/

 

Base library:

[root @ centos8 yum .repos.d] # vi CentOS-Base.repo

Modify the baseurl behavior:

baseurl=https://mirrors.aliyun.com/centos/$releasever/BaseOS/$basearch/os/

 

Extras library:

[root @ centos8 yum .repos.d] # vi CentOS-Extras.repo

Modify the baseurl behavior:

baseurl=https://mirrors.aliyun.com/centos/$releasever/extras/$basearch/os/

 

After the above modifications are completed:

[root @ centos8 yum .repos.d] # dnf clean all
 51 file has been deleted

refresh cache 

[root@centos8 yum.repos.d]# dnf makecache
CentOS-8 - AppStream                                                                                                          3.8 MB/s | 6.6 MB     00:01    
CentOS-8 - Base                                                                                                               2.8 MB/s | 5.0 MB     00:01    
CentOS-8 - Extras                                                                                                              15 kB/s | 4.9 kB     00:00    
Official OpenResty Open Source Repository for RHEL                                                                            158 kB/s |  38 kB     00:00    

Metadata cache has been established.

View the information of the BaseOS repo

[root@centos8 yum.repos.d]# dnf repoinfo BaseOS 
Metadata expired last check: 0 : 01 : 54 before execution in 2020 April 13 Monday 13:53:29.

Warehouse ID: BaseOS
Warehouse name: CentOS - 8 - Base
Warehouse status: enabled
Warehouse version: 1585863557
Warehouse update: Friday, April 03, 2020 05:39:17
Warehouse package: 2 , 126 
Warehouse size: 1.9 G
Warehouse basic address: https: // mirrors.aliyun.com/centos/8/BaseOS/x86_64/os/ 
warehouse expiration: 172 , 800 seconds (most recent Monday, April 13, 2020 13:53:27 )
Warehouse file name: / etc / yum .repos.d / CentOS-Base.repo

 

Perform an installation and test the effect

[root@centos8 yum.repos.d]# yum install tmux

 

2. Modify the epel source to also use Alibaba Cloud

Install epel source:

[root @ centos8 yum .repos.d] # yum  install epel-release

Configure the source as Alibaba Cloud

[root @ centos8 yum .repos.d] # vi epel.repo

 

Modify the baseurl of the epel segment to:

baseurl=http://mirrors.aliyun.com/epel/8/Everything/$basearch

And commented out: metalink

[root @ centos8 yum .repos.d] # dnf clean all
 22 file has been deleted

 

[root@centos8 yum.repos.d]# dnf makecache
CentOS-8 - AppStream                                                                                                          2.4 MB/s | 6.6 MB     00:02    
CentOS-8 - Base                                                                                                               2.7 MB/s | 5.0 MB     00:01    
CentOS-8 - Extras                                                                                                              18 kB/s | 4.9 kB     00 : 00     
Extra Packages for Enterprise Linux 8 -x86_64                                                                                 5.1 MB / s | 6.2 MB      00 : 01     
Official OpenResty Open Source Repository for RHEL                                                                             162 kB / s |   38 kB      00 : 00     
metadata cache has been established.

 

[root@centos8 yum.repos.d]# dnf repolist 
Metadata expired last check: 0 : 00 : 09 before, executed on April 13 2020 Monday 14:07:30.
Warehouse ID Warehouse Name Status
AppStream CentOS - 8 - AppStream                                                  5 , 124 
BaseOS CentOS - 8 - Base                                                       2 , 126 
epel Extra Packages for Enterprise Linux 8 - x86_64                        5 , 240 extra 
CentOS - 8 - Extras                                                     12
openresty                             Official OpenResty Open Source Repository for RHEL                   83

 

[root@centos8 yum.repos.d]# dnf repoinfo epel
Metadata expired last check: 0 : 00 : 20 before execution in 2020 April 13 Monday 14:07:30.

Warehouse ID: epel
Warehouse name: Extra Packages for Enterprise Linux 8 - x86_64
Warehouse status: enabled
Warehouse version: 1586537550
Warehouse update: Saturday, April 11, 2020 00:53:18
Warehouse package: 5 , 240 
Warehouse size: 6.5 G
Warehouse basic address: http: // mirrors.aliyun.com/epel/8/Everything/x86_64 
Warehouse expiration: 172 , 800 seconds (most recent Monday, April 13, 2020 14:07:26 )
Warehouse file name: / etc / yum .repos.d / epel.repo

 

Test if epel source is available?

[root@centos8 yum.repos.d]# dnf install nethogs

 

Eleven, check the version of centos

[root@centos8 yum.repos.d]# cat /etc/redhat-release 
CentOS Linux release 8.1.1911 (Core)

 

Guess you like

Origin www.cnblogs.com/architectforest/p/12691304.html