一、简介:
DNF是linux系统的另一个软件安装解决方案,相对于yum,对于依赖有更好,更高效的解决方案。对于开发者来说,也更加友好,而且对于Python也有更好的支持;redhat8已经默认有DNF,只需要修改源就可以直接使用
1、Yum没有API文档。这意味着开发者需要做更多的工作。Yum开发者写一个调用函数都需要查看Yum的代码库,使开发变得缓慢。
2、Python3。Fedora将会过渡到Python3,但Yum却没有这个能力,而DNF既可以使用Python2,也可以在Python3环境下运行。
3、依赖解决能力长期是Fedora软件包管理的阿喀硫斯之踵。DNF使用基于SAT的依赖问题解决方法,与SUSE和OpenSUSE的Zypper类似。
二、安装:
下载:
#下载源文件
sudo wget -O /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-8.repo
#配置DNF,耗时比较久
sudo dnf update
#如果想配置yum源,使用以下命令:
# 清除缓存
#yum clean all
# 生存缓存
#yum makecache
也可以直接复制日下内容,放到/etc/yum.repos.d/Centos-8.repo中,
内容如下:
# CentOS-Base.repo
#
# The mirror system uses the connecting IP address of the client and the
# update status of each mirror to pick mirrors that are updated to and
# geographically close to the client. You should use this for CentOS updates
# unless you are manually picking other mirrors.
#
# If the mirrorlist= does not work for you, as a fall back you can try the
# remarked out baseurl= line instead.
#
#
[base]
name=CentOS-$releasever - Base - mirrors.aliyun.com
failovermethod=priority
baseurl=https://mirrors.aliyun.com/centos/$releasever/BaseOS/$basearch/os/
http://mirrors.aliyuncs.com/centos/$releasever/BaseOS/$basearch/os/
http://mirrors.cloud.aliyuncs.com/centos/$releasever/BaseOS/$basearch/os/
gpgcheck=1
gpgkey=https://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-Official
#additional packages that may be useful
[extras]
name=CentOS-$releasever - Extras - mirrors.aliyun.com
failovermethod=priority
baseurl=https://mirrors.aliyun.com/centos/$releasever/extras/$basearch/os/
http://mirrors.aliyuncs.com/centos/$releasever/extras/$basearch/os/
http://mirrors.cloud.aliyuncs.com/centos/$releasever/extras/$basearch/os/
gpgcheck=1
gpgkey=https://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-Official
#additional packages that extend functionality of existing packages
[centosplus]
name=CentOS-$releasever - Plus - mirrors.aliyun.com
failovermethod=priority
baseurl=https://mirrors.aliyun.com/centos/$releasever/centosplus/$basearch/os/
http://mirrors.aliyuncs.com/centos/$releasever/centosplus/$basearch/os/
http://mirrors.cloud.aliyuncs.com/centos/$releasever/centosplus/$basearch/os/
gpgcheck=1
enabled=0
gpgkey=https://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-Official
[PowerTools]
name=CentOS-$releasever - PowerTools - mirrors.aliyun.com
failovermethod=priority
baseurl=https://mirrors.aliyun.com/centos/$releasever/PowerTools/$basearch/os/
http://mirrors.aliyuncs.com/centos/$releasever/PowerTools/$basearch/os/
http://mirrors.cloud.aliyuncs.com/centos/$releasever/PowerTools/$basearch/os/
gpgcheck=1
enabled=0
gpgkey=https://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-Official
[AppStream]
name=CentOS-$releasever - AppStream - mirrors.aliyun.com
failovermethod=priority
baseurl=https://mirrors.aliyun.com/centos/$releasever/AppStream/$basearch/os/
http://mirrors.aliyuncs.com/centos/$releasever/AppStream/$basearch/os/
http://mirrors.cloud.aliyuncs.com/centos/$releasever/AppStream/$basearch/os/
gpgcheck=1
gpgkey=https://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-Official
三、使用:
DNF的语法与Yum类似(以安装lrzsz为例);
sudo dnf install lrzsz
删除lrzsz的命令为
sudo dnf remove lrzsz
升级软件
sudo dnf update
升级系统
sudo dnf upgrade
清除RPM包缓存
sudo dnf clean packages
输入命令man dnf查看完整的用法。
其他版本的RHEL需要手动安装DNF:
yum install epel-release
yum install dnf