开发者社区> 系统> 正文
0
0
0
18
打赏
0
分享

Linux系统之dnf包管理器的基本使用

简介: Linux系统之dnf包管理器的基本使用
+关注继续查看

Linux系统之dnf包管理器的基本使用
一、dnf工具介绍
1. dnf工具简介
2. dnf的功能
二、DNF的安装
1. 检查本地操作系统版本
2. 安装epel
3. 检查本地yum仓库状态
4. 安装dnf包
三、dnf的使用帮助
1. 查看dnf版本
2. 查看dnf命令的帮助信息
3. dnf命令的选项解释
四、dnf命令的基本使用
1. 查询dnf软件库
2.查询系统的rpm包
3. 软件包的安装与卸载
4. 检查系统软件包的更新
5. 升级所有系统软件包
6. 查看dnf命令的执行历史
7. 查看所有的软件包组
8. 查询软件的详细信息
五、dnf命令的使用总结
1. dnf命令的使用总结
2. dnf与yum包管理器比较
一、dnf工具介绍
1. dnf工具简介
DNF(Dandified Yum)是Fedora Linux操作系统中的一个包管理器,它是基于Yum开发的。它的主要特点是快速、可靠、易用和优秀的用户体验。

2. dnf的功能
DNF提供了许多强大的功能和命令行工具,包括:

安装和升级软件包:可以使用dnf install和dnf update命令来安装和升级软件包。

查询和列出软件包:可以使用dnf search和dnf list命令来查询和列出软件包。

删除软件包:可以使用dnf remove命令来删除已安装的软件包。

清理系统:可以使用dnf clean命令来清理系统中的软件包缓存和元数据。

版本管理:可以使用dnf history命令来查看软件包操作历史记录,并进行回滚或重做操作。

软件包组管理:可以使用dnf group命令来安装、升级和删除软件包组。

存储库管理:可以使用dnf repolist命令来列出系统中的存储库,并使用dnf config命令来配置存储库。

二、DNF的安装
1. 检查本地操作系统版本
检查本地操作系统版本

[root@jeven ~]# cat /etc/system-release
CentOS Linux release 7.6.1810 (Core) 

1
2
3
2. 安装epel
配置epel,启动epel的yum仓库。
yum install epel-release -y
1
或者使用阿里云的epel源
wget -O /etc/yum.repos.d/epel.repo https://mirrors.aliyun.com/repo/epel-7.repo
1
3. 检查本地yum仓库状态
检查本地yum仓库状态

[root@jeven ~]# yum repolist all |grep enable 
!base/7/x86_64        CentOS-7 - Base - mirrors.aliyun.com       enabled: 10,072
epel/x86_64           Extra Packages for Enterprise Linux 7 - x8 enabled: 13,753
!extras/7/x86_64      CentOS-7 - Extras - mirrors.aliyun.com     enabled:    515
!updates/7/x86_64     CentOS-7 - Updates - mirrors.aliyun.com    enabled:  5,053

1
2
3
4
5
6
4. 安装dnf包
使用yum安装dnf包

yum install dnf -y
1


三、dnf的使用帮助
1. 查看dnf版本
查看dnf包管理器版本

[root@jeven ~]# dnf --version
4.0.9
  Installed: dnf-0:4.0.9.2-2.el7_9.noarch at Mon 03 Jul 2023 11:24:14 AM CST
  Built    : CentOS BuildSystem <http://bugs.centos.org> at Wed 07 Apr 2021 03:52:38 PM CST

  Installed: rpm-0:4.11.3-48.el7_9.x86_64 at Sat 24 Jun 2023 10:08:53 PM CST
  Built    : CentOS BuildSystem <http://bugs.centos.org> at Wed 24 Nov 2021 04:33:39 PM CST

1
2
3
4
5
6
7
8
2. 查看dnf命令的帮助信息
查看DNF在Linux的help帮助信息

[root@jeven ~]# 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

Optional arguments:
  -c [config file], --config [config file]
                        config file location
  -q, --quiet           quiet operation
  -v, --verbose         verbose operation
  --version             show DNF version and exit
  --installroot [path]  set install root
  --nodocs              do not install documentations
  --noplugins           disable all plugins
  --enableplugin [plugin]
                        enable plugins by name
  --disableplugin [plugin]
                        disable plugins by name
  --releasever RELEASEVER
                        override the value of $releasever in config and repo
                        files
  --setopt SETOPTS      set arbitrary config and repo options
  --skip-broken         resolve depsolve problems by skipping packages
  -h, --help, --help-cmd
                        show command help
  --allowerasing        allow erasing of installed packages to resolve
                        dependencies
  -b, --best            try the best available package versions in
                        transactions.
  -C, --cacheonly       run entirely from system cache, don't update cache
  -R [minutes], --randomwait [minutes]
                        maximum command wait time
  -d [debug level], --debuglevel [debug level]
                        debugging output level
  --debugsolver         dumps detailed solving results into files
  --showduplicates      show duplicates, in repos, in list/search commands
  -e ERRORLEVEL, --errorlevel ERRORLEVEL
                        error output level
  --obsoletes           enables dnf's obsoletes processing logic for upgrade
                        or display capabilities that the package obsoletes for
                        info, list and repoquery
  --rpmverbosity [debug level name]
                        debugging output level for rpm
  -y, --assumeyes       automatically answer yes for all questions
  --assumeno            automatically answer no for all questions
  --enablerepo [repo]
  --disablerepo [repo]
  --repo [repo], --repoid [repo]
                        enable just specific repositories by an id or a glob,
                        can be specified multiple times
  --enable, --set-enabled
                        enable repos with config-manager command
                        (automatically saves)
  --disable, --set-disabled
                        disable repos with config-manager command
                        (automatically saves)
  -x [package], --exclude [package], --excludepkgs [package]
                        exclude packages by name or glob
  --disableexcludes [repo], --disableexcludepkgs [repo]
                        disable excludepkgs
  --repofrompath [repo,path]
                        label and path to additional repository, can be
                        specified multiple times.
  --noautoremove        disable removal of dependencies that are no longer
                        used
  --nogpgcheck          disable gpg signature checking (if RPM policy allows)
  --color COLOR         control whether color is used
  --refresh             set metadata as expired before running the command
  -4                    resolve to IPv4 addresses only
  -6                    resolve to IPv6 addresses only
  --destdir DESTDIR, --downloaddir DESTDIR
                        set directory to copy packages to
  --downloadonly        only download packages
  --comment COMMENT     add a comment to transaction
  --bugfix              Include bugfix relevant packages, in updates
  --enhancement         Include enhancement relevant packages, in updates
  --newpackage          Include newpackage relevant packages, in updates
  --security            Include security relevant packages, in updates
  --advisory ADVISORY, --advisories ADVISORY
                        Include packages needed to fix the given advisory, in
                        updates
  --bzs BUGZILLA        Include packages needed to fix the given BZ, in
                        updates
  --cves CVES           Include packages needed to fix the given CVE, in
                        updates
  --sec-severity {Critical,Important,Moderate,Low}, --secseverity {Critical,Important,Moderate,Low}
                        Include security relevant packages matching the
                        severity, in updates
  --forcearch ARCH      Force the use of an architecture

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
3. dnf命令的选项解释
dnf命令的选项解释

DNF(Dandified Yum)是Fedora、CentOS、RHEL等Linux发行版上最新的包管理工具,下面是DNF工具常用选项的解释:

1. `install`:安装一个或多个软件包
2. `remove`:卸载一个或多个软件包
3. `update`:更新现有的软件包
4. `upgrade`:更新系统中所有软件包(包括依赖项)
5. `info`:查询软件包详细信息
6. `search`:搜索软件包
7. `list`:列出系统中所有已安装的软件包
8. `clean`:清除系统中的缓存
9. `check-update`:检查系统中可用的更新
10. `repository`:管理 YUM 仓库
11. `module`:管理模块
12. `group`:管理软件包组
13. `config-manager`:管理 DNF 配置文件和库
14. `version`:查看 DNF 版本信息
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
四、dnf命令的基本使用
1. 查询dnf软件库
查看系统中可用的DNF软件库
[root@jeven ~]# dnf repolist
Extra Packages for Enterprise Linux 7 - x86_64                                                                                         6.5 MB/s |  17 MB     00:02    
CentOS-7 - Base - mirrors.aliyun.com                                                                                                   7.0 MB/s |  10 MB     00:01    
CentOS-7 - Updates - mirrors.aliyun.com                                                                                                8.2 MB/s |  27 MB     00:03    
CentOS-7 - Extras - mirrors.aliyun.com                                                                                                 978 kB/s | 332 kB     00:00    
repo id                                                      repo name                                                                                           status
base                                                         CentOS-7 - Base - mirrors.aliyun.com                                                                10,072
epel                                                         Extra Packages for Enterprise Linux 7 - x86_64                                                      13,753
extras                                                       CentOS-7 - Extras - mirrors.aliyun.com                                                                 515
updates                                                      CentOS-7 - Updates - mirrors.aliyun.com                                                              5,053
1
2
3
4
5
6
7
8
9
10
查询系统中所有的 DNF软件库,包括可用于不可用的。
[root@jeven ~]# dnf repolist all
Last metadata expiration check: 0:01:45 ago on Mon 03 Jul 2023 07:32:09 PM CST.
repo id                                                repo name                                                                                        status
base                                                   CentOS-7 - Base - mirrors.aliyun.com                                                             enabled: 10,072
centosplus                                             CentOS-7 - Plus - mirrors.aliyun.com                                                             disabled
contrib                                                CentOS-7 - Contrib - mirrors.aliyun.com                                                          disabled
epel                                                   Extra Packages for Enterprise Linux 7 - x86_64                                                   enabled: 13,753
epel-debuginfo                                         Extra Packages for Enterprise Linux 7 - x86_64 - Debug                                           disabled
epel-source                                            Extra Packages for Enterprise Linux 7 - x86_64 - Source                                          disabled
extras                                                 CentOS-7 - Extras - mirrors.aliyun.com                                                           enabled:    515
updates                                                CentOS-7 - Updates - mirrors.aliyun.com                                                          enabled:  5,053
1
2
3
4
5
6
7
8
9
10
11
2.查询系统的rpm包
查询系统中所有的软件包,该命令用于列出用户系统上的所有来自软件库的可用软件包和所有已经安装在系统上的软件包。
dnf list
1


查询已经安装的rpm包
dnf list installed
1


查询可供安装的 RPM 包
dnf list available
1
搜索软件库中的某个软件包
[root@jeven ~]# dnf search fdisk
Last metadata expiration check: 0:07:32 ago on Mon 03 Jul 2023 07:32:09 PM CST.
======================================================================= Summary Matched: fdisk ========================================================================
gdisk.x86_64 : An fdisk-like partitioning tool for GPT disks
1
2
3
4
查询某个命令对应的软件名
dnf provides /bin/bash
1
3. 软件包的安装与卸载
安装软件包
dnf install tree -y
1


卸载软件包
dnf remove tree -y
1
更新软件包
dnf update tree -y
1


4. 检查系统软件包的更新
使用以下命令检查系统中所有软件包的更新
dnf check-update
1
5. 升级所有系统软件包
使用以下命令升级系统中所有有可用升级的软件包

dnf update 或 dnf upgrade

1
2
6. 查看dnf命令的执行历史
查看DNF命令的执行历史

[root@jeven ~]# dnf history
ID     | Command line             | Date and time    | Action(s)      | Altered
-------------------------------------------------------------------------------
     1 | install nginx -y         | 2023-07-03 19:47 | Install        |    3   
1
2
3
4
7. 查看所有的软件包组
查看所有的软件包组

dnf grouplist
1
安装开发包组
dnf groupinstall "Development Tools" -y
1
8. 查询软件的详细信息
查看某个软件的详细信息
[root@jeven ~]# dnf info tree
Last metadata expiration check: 0:21:56 ago on Mon 03 Jul 2023 07:32:09 PM CST.
Installed Packages
Name         : tree
Version      : 1.6.0
Release      : 10.el7
Arch         : x86_64
Size         : 87 k
Source       : tree-1.6.0-10.el7.src.rpm
Repo         : @System
Summary      : File system tree viewer
URL          : http://mama.indstate.edu/users/ice/tree/
License      : GPLv2+
Description  : The tree utility recursively displays the contents of directories in a
             : tree-like format.  Tree is basically a UNIX port of the DOS tree
             : utility.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
五、dnf命令的使用总结
1. dnf命令的使用总结
安装软件包:使用dnf install命令,后跟要安装的软件包的名称。例如,dnf install firefox安装Firefox浏览器。
升级软件包:使用dnf upgrade命令升级所有已安装的软件包。dnf upgrade package-name升级单个软件包。
搜索软件包:使用dnf search命令搜索要安装的软件包。例如,dnf search mysql搜索MySQL软件包。
删除软件包:使用dnf remove命令删除已安装的软件包。例如,dnf remove firefox删除Firefox浏览器。
列出已安装的软件包:使用dnf list installed命令列出所有已安装的软件包。
列出可用的软件包:使用dnf list available命令列出所有可用的软件包。
列出软件包的详细信息:使用dnf info package-name命令列出软件包的详细信息。
清理缓存:使用dnf clean all命令清理DNF缓存。
禁用或启用软件包仓库:使用dnf config-manager命令禁用或启用软件包仓库。例如,dnf config-manager --disable repository-name禁用软件包仓库。
检查依赖关系:使用dnf check命令检查软件包之间的依赖关系。
2. dnf与yum包管理器比较
dnf相比于yum有以下几个优点:

性能更好:dnf使用了更先进的依赖关系解决算法,因此速度更快。

交互性更好:dnf提供更友好的命令行交互,支持自动补全、多个软件包同时安装、更好的错误信息提示等功能。

依赖关系处理更加精确:dnf可以非常准确地处理软件包之间的依赖关系,避免因为缺少依赖而导致安装失败的问题。

提供更多的包信息:dnf提供更多、更详细的软件包信息,包括依赖关系、提供的功能、安装的文件以及其他相关信息。

具有扩展性:dnf是基于插件架构设计的,可以方便地扩展新的功能。
————————————————
版权声明:本文为CSDN博主「江湖有缘」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/jks212454/article/details/131522044




免责声明:本文章版权归属原创作者所有,由本站用户分享仅供学习交流之用!

参考文档

Linux下做性能分析:perf

Google-Wide Profiling: A Continuous Profiling Infrastructure for Data Centers

Profiling concepts bookmark_border

What is continuous profiling?

版权声明:本文内容由Webmeng实名注册用户自发贡献,版权归原作者所有,搜寻云开发者社区不拥有其著作权,亦不承担相应法律责任。具体规则请查看《搜寻云开发者社区用户服务协议》和《Webmeng开发者社区知识产权保护指引》。如果您发现本社区中有涉嫌抄袭的内容,填写侵权投诉表单进行举报,一经查实,本社区将立刻删除涉嫌侵权内容。

评论

登录后可评论
相关文章
远程桌面连接出现了内部错误的问题
远程桌面连接出现了内部错误。我尝试以管理员身份登录,还是无法解决。重启电脑虽然可以暂时解决问题,但错误还是会随机出现。如何轻松地解决Win10远程连接提示内部错误的问题?”
0
新开阿里云服务器必须在安全组放行80,443端口 否则网站打不开
新开阿里云服务器必须在安全组放行80,443端口 否则网站打不开
0
域名解析到的阿里云的网站打不开
Re我的域名解析成功了。但是还是访问不了网站
0
Linux系统内核升级
mainline指由Linus Torvalds亲自制作的内核发布版,是官方当前最新版本的kernel source。在Torvalds对所有其他程序员所做出的重大变化进行整合,并且对先前版本的bug进行几轮修复之后,大约每十周正式发布一个新版本。mainline事实上代表着一个linux kernel分支,这个分支有另一个名称,叫做vanilla。
0
Linux系统yum的安装、升级、卸载命令详解
Linux系统yum的安装、升级、卸载命令详解
0
域名到期后多久可以注册
域名到期后,并不会立即被他人注册,而是经历了一定的释放周期。这是因为域名注册机构为了保护域名的合法权益,会设置一段时间用于处理续期、赎回以及其他相关操作。
0
blob:https格式的视频链接怎么下载
因此这些链接具有一定的时效性,仅在当前会话中有效。 由于 blob URL 是针对浏览器内存中的数据生成的临时链接,直接通过复制链接或其他方式在其他应用程序或设备上访问或下载该视频是不可行的。
0
【宝塔一键部署】项目包构建文档
【宝塔一键部署】项目包构建文档
0
windows云主机挂载磁盘的方法是什么
打开“计算机管理”工具。可以通过右键点击“计算机”图标,然后选择“管理”来打开该工具。
0
Linux更新指令 升级指令
yum命令用于redhat系统下的软件安装和更新,是redhat和Fedora系统中rpm的软件包管理器,使用前要配置好yum源,可以使用极为相似的centos源,而且免费。yum提供了安装,查找,删除软件包的命令,好记又好用。
0
Linux内核升级简易教程,轻松掌握(linux内核升级教程)
Linux在20世纪90年代晚期诞生的,它的出现是一个巨大的革命,被认为是开源系统的一大成功,也引领了互联网时代的到来。因为Linux一直不断地发展壮大,每隔一段时间就会有新的内核版本发布,当Linux的新版本发布后,就需要对内核进行升级。
0


+关注
7
文章
0
问答
0
视频

文章排行榜
最热
最新

相关电子书
更多
基于Lindorm快速构建高效的监控系统
立即下载
Elasticsearch全观测技术解析与应用(构建日志、指标、APM统一观测平台)
立即下载
基于资产配置业务场景下全链路监控平台
立即下载