DNF包管理工具

CentOS8启用了DNF作为系统软件包管理工具,Yum也不是被放弃,因为DNF应该说是Yum的一个更新的版本。

DNF是Dandified yum的缩写,DNF三个字母却没有一个来自yum。DNF也是基于RPM的包管理工具,其首先在Fedora系统中出现,已经成为Fedora系统的默认的包管理工具。现在又来到了CentOS,应该说使用CentOS是幸运的,因为其相对保守的特性。尝鲜的事情,就给Fedora系统吧。DNF的出现,是为了解决Yum系统的性能瓶颈,优化内存使用,依赖关系解析,执行速度等。DNF是用Python写的。
用dnf --help,查看你能够使用的命令参数,跟yum差不多。

DNF的优势

  1. DNF comes with a simplified code: DNF has about 29000 lines of code compared to over 59000 in yum.
    DNF代码比Yum要简单,只有不到3万行代码,而Yum接近6完行。
  2. Support for multiple repositories.
    支持多repo。
  3. Faster and lesser memory intensive operations compared to yum.
    更快,比Yum消耗更少内容。
  4. Simple interface.
    简单的界面。
  5. DNF runs in both Python 2 and Python 3.
  6. Simple configuration.
    配置简单。
  7. DNF has faster dependency resolving speed than yum.
    依赖包解析速度更快。
  8. RPM consistent behavior.
    与RPM一致的行为。
  9. C bindings for lower level libraries.
  10. Package group support, including multiple-repository groups.
    支持对package进行group管理
    The default location of DNF configuration file is /etc/dnf/dnf.conf.

DNF的主要命令

$ dnf --help
usage: dnf [options] COMMAND
List of Main Commands:
alias                     List or create command aliases
autoremove                remove all unneeded packages that were originally installed as dependencies
check                     check for problems in the packagedb
check-update              check for available package upgrades
clean                     remove cached data
deplist                   List package's dependencies and what packages provide them
distro-sync               synchronize installed packages to the latest available versions
downgrade                 Downgrade a package
group                     display, or use, the groups information
help                      display a helpful usage message
history                   display, or use, the transaction history
info                      display details about a package or group of packages
install                   install a package or packages on your system
list                      list a package or groups of packages
makecache                 generate the metadata cache
mark                      mark or unmark installed packages as installed by user.
module                    Interact with Modules.
provides                  find what package provides the given value
reinstall                 reinstall a package
remove                    remove a package or packages from your system
repolist                  display the configured software repositories
repoquery                 search for packages matching keyword
repository-packages       run commands on top of all packages in given repository
search                    search package details for the given string
shell                     run an interactive DNF shell
swap                      run an interactive dnf mod for remove and install one spec
updateinfo                display advisories about packages
upgrade                   upgrade a package or packages on your system
upgrade-minimal           upgrade, but only 'newest' package match which fixes a problem that affects your system

配置新的yum源(BASEOS中存放基本系统软件包,AppStream中存放app包如nginx)

[root@ck8s1 yum.repos.d]# cat /etc/yum.repos.d/base.repo
[base]
name=base
gpgcheck=0
enabled=1
baseurl=file:///mnt/median/BaseOS
[AppStream]
name=AppStream
gpgcheck=0
enabled=1
baseurl=file:///mnt/median/AppStream

清除缓存

[root@ck8s1 yum.repos.d]# dnf clean all && dnf makecache

文件已删除
AppStream 122 MB/s | 5.2 MB 00:00
base 102 MB/s | 2.2 MB 00:00
元数据缓存已建立。

使用dnf命令来安装NGINX来确认yum搭建是否正确

[root@ck8s1 yum.repos.d]# dnf install nginx -y

用法
已安装包的列表

dnf list installed

查找与安装软件包

dnf search nginx

安装httpd包命令

dnf install nginx

重新安装软件nginx

dnf reinstall nginx

查看nginx包的详细信息

dnf info nginx

检查系统安装包更新

dnf check-update

更新所有安装包

dnf update

更新nginx

dnf update nginx

卸载nginx

dnf remove nginx

去掉不需要的依赖包

dnf autoremove

清除所有缓存

dnf clean all
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值