0
  • 聊天消息
  • 系統(tǒng)消息
  • 評論與回復(fù)
登錄后你可以
  • 下載海量資料
  • 學(xué)習(xí)在線課程
  • 觀看技術(shù)視頻
  • 寫文章/發(fā)帖/加入社區(qū)
會員中心
創(chuàng)作中心

完善資料讓更多小伙伴認識你,還能領(lǐng)取20積分哦,立即完善>

3天內(nèi)不再提示

yum工具使用大全:從安裝到更新,輕松管理軟件包

馬哥Linux運維 ? 來源:馬哥Linux運維 ? 2024-11-25 17:23 ? 次閱讀
加入交流群
微信小助手二維碼

掃碼添加小助手

加入工程師交流群

目錄

yum工具的使用

1. yum本地倉庫

2. yum網(wǎng)絡(luò)倉庫

3. yum管理命令

yum倉庫管理

yum倉庫管理

1. yum本地倉庫

掛載鏡像
f3117d56-a0db-11ef-93f3-92fbcf53809c.png

[root@lnh ~]# cd /etc/yum.repos.d/
[root@lnh yum.repos.d]# ls
CentOS-Stream-AppStream.repo         CentOS-Stream-RealTime.repo
CentOS-Stream-BaseOS.repo            epel-modular.repo
CentOS-Stream-Debuginfo.repo         epel-playground.repo
CentOS-Stream-Extras.repo            epel.repo
CentOS-Stream-HighAvailability.repo  epel-testing-modular.repo
CentOS-Stream-Media.repo             epel-testing.repo
CentOS-Stream-PowerTools.repo
[root@lnh yum.repos.d]# rm -rf *
[root@lnh yum.repos.d]# ls
[root@lnh yum.repos.d]# 
//因為我們用的是centos8.5,所以有這些本地倉庫,如果是redhat就沒有,我們需要刪除這些倉庫然后進行創(chuàng)建
[root@lnh yum.repos.d]# vim xbz.repo
[root@lnh yum.repos.d]# ls
xbz.repo
[root@lnh yum.repos.d]# cat xbz.repo 
[BaseOS]
name=111
baseurl=file:///mnt/BaseOS
gpgcheck=0
enabled=1
[AppStream]
name=222
baseurl=file:///mnt/AppStream
gpgcheck=0
enabled=1
//配置本地倉庫  復(fù)制快捷鍵5yy p
[root@lnh yum.repos.d]# mount /dev/cdrom /mnt/
mount: /mnt: /dev/sr0 already mounted on /mnt.
//掛載鏡像,此處我已經(jīng)掛載了
[root@lnh yum.repos.d]# dnf clean all 
13 files removed
//清空yum本地緩存,此處用yum也可以但是用dnf可以解決它的一些依賴關(guān)系更好一些
[root@lnh yum.repos.d]# dnf list all
.....
xterm-resize.x86_64            331-1.el8                            AppStream
xz-devel.i686                  5.2.4-3.el8                          BaseOS   
xz-devel.x86_64                5.2.4-3.el8                          BaseOS   
xz-libs.i686                   5.2.4-3.el8                          BaseOS   
yajl.i686                      2.1.0-10.el8                         AppStream
yajl.x86_64                    2.1.0-10.el8                         AppStream
yelp.x86_64                    2:3.28.1-3.el8                       AppStream
yelp-libs.i686                 2:3.28.1-3.el8                       AppStream
yelp-libs.x86_64               2:3.28.1-3.el8                       AppStream
yelp-tools.noarch              3.28.0-3.el8                         AppStream
yelp-xsl.noarch                3.28.0-2.el8                         AppStream
yp-tools.x86_64                4.2.3-1.el8                          AppStream
ypbind.x86_64                  3:2.5-2.el8                          AppStream
ypserv.x86_64                  4.0-6.20170331git5bfba76.el8         AppStream
yum-utils.noarch               4.0.18-1.el8                         BaseOS 
.....
//檢驗yum地倉庫

2. yum網(wǎng)絡(luò)倉庫

官方的網(wǎng)絡(luò)yum倉庫在國外
我們可以使用國內(nèi)的yum倉庫:
阿里云yum倉庫(https://developer.aliyun.com/mirror/)
epel源
(https://developer.aliyun.com/mirror/)
163yum倉庫
(http://mirrors.163.com/)
清華大學(xué)yum倉庫
(https://mirrors.tuna.tsinghua.edu.cn/)

[root@lnh yum.repos.d]# ls
xbz.repo
[root@lnh yum.repos.d]# rm -rf *
[root@lnh yum.repos.d]# ls
[root@lnh yum.repos.d]# 
//因為本地倉庫和網(wǎng)絡(luò)倉庫不可以共存所以我們先刪除本地倉庫
[root@lnh yum.repos.d]# wget -O /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-vault-8.5.2111.repo
--2022-07-09 00:59:38--  https://mirrors.aliyun.com/repo/Centos-vault-8.5.2111.repo
Resolving mirrors.aliyun.com (mirrors.aliyun.com)... 58.49.248.231, 58.49.248.232, 119.96.204.211, ...
Connecting to mirrors.aliyun.com (mirrors.aliyun.com)|58.49.248.231|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 2495 (2.4K) [application/octet-stream]
Saving to: ‘/etc/yum.repos.d/CentOS-Base.repo’

/etc/yum.repos.d/Ce 100%[================>]   2.44K  --.-KB/s    in 0s      

2022-07-09 00:59:38 (25.2 MB/s) - ‘/etc/yum.repos.d/CentOS-Base.repo’ saved [2495/2495]
//在阿里云里面下載新的 CentOS-Base.repo 到 /etc/yum.repos.d/
[root@lnh yum.repos.d]# yum makecache 
CentOS-8.5.2111 - Base - mirrors.aliyun.com   19 MB/s | 4.6 MB     00:00    
CentOS-8.5.2111 - Extras - mirrors.aliyun.co  90 kB/s |  10 kB     00:00    
CentOS-8.5.2111 - AppStream - mirrors.aliyun  16 MB/s | 8.4 MB     00:00    
Metadata cache created.
//運行 yum makecache 生成緩存
[root@lnh yum.repos.d]# sed -i -e '/mirrors.cloud.aliyuncs.com/d' -e '/mirrors.aliyuncs.com/d' /etc/yum.repos.d/CentOS-Base.repo
[root@lnh yum.repos.d]# 
//非阿里云ECS用戶會出現(xiàn) Couldn't resolve host 'mirrors.cloud.aliyuncs.com' 信息,不影響使用。用戶也可自行修改相關(guān)配置
[root@lnh yum.repos.d]# ls
CentOS-Base.repo
//這個就是yum網(wǎng)絡(luò)倉庫
[root@lnh yum.repos.d]# dnf list all
...
yajl.x86_64                                2.1.0-10.el8             AppStream
yelp.x86_64                                2:3.28.1-3.el8           AppStream
yelp-libs.i686                             2:3.28.1-3.el8           AppStream
yelp-libs.x86_64                           2:3.28.1-3.el8           AppStream
yelp-tools.noarch                          3.28.0-3.el8             AppStream
yelp-xsl.noarch                            3.28.0-2.el8             AppStream
...
//檢驗一下是否配置成功

3. yum管理命令

常用的options:
安裝,卸載

[root@lnh ~]# dnf -y install vim
Last metadata expiration check: 041 ago on Sat 09 Jul 2022 0112 AM CST.
Dependencies resolved.
=============================================================================
 Package             Arch        Version                Repository      Size
=============================================================================
Installing:
 vim-enhanced        x86_64      2:8.0.1763-16.el8      AppStream      1.4 M
Installing dependencies:
 gpm-libs            x86_64      1.20.7-17.el8          AppStream       39 k
 vim-common          x86_64      2:8.0.1763-16.el8      AppStream      6.3 M
 vim-filesystem      noarch      2:8.0.1763-16.el8      AppStream       49 k

Transaction Summary
=============================================================================
Install  4 Packages

Total download size: 7.8 M
Installed size: 30 M
Downloading Packages:
(1/4): gpm-libs-1.20.7-17.el8.x86_64.rpm     947 kB/s |  39 kB     00:00    
(2/4): vim-filesystem-8.0.1763-16.el8.noarch 2.6 MB/s |  49 kB     00:00    
(3/4): vim-enhanced-8.0.1763-16.el8.x86_64.r 4.4 MB/s | 1.4 MB     00:00    
(4/4): vim-common-8.0.1763-16.el8.x86_64.rpm  13 MB/s | 6.3 MB     00:00    
-----------------------------------------------------------------------------
Total                                         16 MB/s | 7.8 MB     00:00     
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
  Preparing        :                                                     1/1 
  Installing       : vim-filesystem-2:8.0.1763-16.el8.noarch             1/4 
  Installing       : vim-common-2:8.0.1763-16.el8.x86_64                 2/4 
  Installing       : gpm-libs-1.20.7-17.el8.x86_64                       3/4 
  Running scriptlet: gpm-libs-1.20.7-17.el8.x86_64                       3/4 
  Installing       : vim-enhanced-2:8.0.1763-16.el8.x86_64               4/4 
  Running scriptlet: vim-enhanced-2:8.0.1763-16.el8.x86_64               4/4 
  Running scriptlet: vim-common-2:8.0.1763-16.el8.x86_64                 4/4 
  Verifying        : gpm-libs-1.20.7-17.el8.x86_64                       1/4 
  Verifying        : vim-common-2:8.0.1763-16.el8.x86_64                 2/4 
  Verifying        : vim-enhanced-2:8.0.1763-16.el8.x86_64               3/4 
  Verifying        : vim-filesystem-2:8.0.1763-16.el8.noarch             4/4 
Installed products updated.

Installed:
  gpm-libs-1.20.7-17.el8.x86_64                                              
  vim-common-2:8.0.1763-16.el8.x86_64                                        
  vim-enhanced-2:8.0.1763-16.el8.x86_64                                      
  vim-filesystem-2:8.0.1763-16.el8.noarch                                    

Complete!
//此處install表示安裝 -y表示自動回復(fù)yes進行安裝
[root@lnh ~]# dnf -y remove vim
Dependencies resolved.
=============================================================================
 Package           Arch      Version                     Repository     Size
=============================================================================
Removing:
 vim-enhanced      x86_64    2:8.0.1763-16.el8_5.12      @appstream    2.9 M
Removing unused dependencies:
 gpm-libs          x86_64    1.20.7-17.el8               @appstream     28 k
 vim-common        x86_64    2:8.0.1763-16.el8_5.12      @appstream     27 M
 vim-filesystem    noarch    2:8.0.1763-16.el8_5.12      @appstream     40  

Transaction Summary
=============================================================================
Remove  4 Packages

Freed space: 30 M
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
  Preparing        :                                                     1/1 
  Erasing          : vim-enhanced-2:8.0.1763-16.el8_5.12.x86_64          1/4 
  Erasing          : vim-common-2:8.0.1763-16.el8_5.12.x86_64            2/4 
  Erasing          : vim-filesystem-2:8.0.1763-16.el8_5.12.noarch        3/4 
  Erasing          : gpm-libs-1.20.7-17.el8.x86_64                       4/4 
  Running scriptlet: gpm-libs-1.20.7-17.el8.x86_64                       4/4 
  Verifying        : gpm-libs-1.20.7-17.el8.x86_64                       1/4 
  Verifying        : vim-common-2:8.0.1763-16.el8_5.12.x86_64            2/4 
  Verifying        : vim-enhanced-2:8.0.1763-16.el8_5.12.x86_64          3/4 
  Verifying        : vim-filesystem-2:8.0.1763-16.el8_5.12.noarch        4/4 
Installed products updated.

Removed:
  gpm-libs-1.20.7-17.el8.x86_64                                              
  vim-common-2:8.0.1763-16.el8_5.12.x86_64                                   
  vim-enhanced-2:8.0.1763-16.el8_5.12.x86_64                                 
  vim-filesystem-2:8.0.1763-16.el8_5.12.noarch                               

Complete!
//remove是卸載的意思
[root@lnh ~]# dnf -y install --nogpgcheck wget
Last metadata expiration check: 054 ago on Sat 09 Jul 2022 0155 AM CST.
Dependencies resolved.
=============================================================================
 Package      Architecture   Version                 Repository         Size
=============================================================================
Installing:
 wget         x86_64         1.19.5-10.el8           AppStream         734 k

Transaction Summary
=============================================================================
Install  1 Package

Total download size: 734 k
Installed size: 2.8 M
Downloading Packages:
wget-1.19.5-10.el8.x86_64.rpm                5.1 MB/s | 734 kB     00:00    
-----------------------------------------------------------------------------
Total                                        5.0 MB/s | 734 kB     00:00     
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
  Preparing        :                                                     1/1 
  Installing       : wget-1.19.5-10.el8.x86_64                           1/1 
  Running scriptlet: wget-1.19.5-10.el8.x86_64                           1/1 
  Verifying        : wget-1.19.5-10.el8.x86_64                           1/1 
Installed products updated.

Installed:
  wget-1.19.5-10.el8.x86_64                                                  

Complete!
//不檢查合法性進行下載
[root@lnh ~]# dnf -q install wget
Is this ok [y/N]: y
[root@lnh ~]# 
//安裝的時候不顯示安裝信息,一般不推薦使用因為看不出是否安裝成功
--disablerepo=repoidglob    //臨時禁用此處指定的repo
--enablerepo=repoidglob     //臨時啟用此處指定的repo
--noplugins                 //禁用所有插件

常用的command:

[root@lnh ~]# cd /etc/yum.repos.d/
[root@lnh yum.repos.d]# yum list all
...
yum-utils.noarch                           4.0.21-3.el8             base     
zenity.x86_64                              3.28.1-1.el8             AppStream
zlib.i686                                  1.2.11-17.el8            base     
zlib-devel.i686                            1.2.11-17.el8            base     
zlib-devel.x86_64                          1.2.11-17.el8            base     
zsh.x86_64                                 5.5.1-6.el8_1.2          base   
...
//列出倉庫里面的東西相當(dāng)于清單
[root@lnh yum.repos.d]# dnf list available
...
xsane.x86_64                               0.999-30.el8             AppStream
xsane-common.x86_64                        0.999-30.el8             AppStream
xsane-gimp.x86_64                          0.999-30.el8             AppStream
xterm.x86_64                               331-1.el8_3.2            AppStream
xterm-resize.x86_64                        331-1.el8_3.2            AppStream
xz-devel.i686                              5.2.4-3.el8              base    
...
//列出倉庫中有的,但尚未安裝的所有可用的包
[root@lnh yum.repos.d]# dnf list installed 
Installed Packages
NetworkManager.x86_64              1:1.30.0-0.3.el8                @anaconda 
NetworkManager-libnm.x86_64        1:1.30.0-0.3.el8                @anaconda 
NetworkManager-team.x86_64         1:1.30.0-0.3.el8                @anaconda 
NetworkManager-tui.x86_64          1:1.30.0-0.3.el8                @anaconda 
acl.x86_64                         2.2.53-1.el8                    @anaconda 
adwaita-cursor-theme.noarch        3.28.0-2.el8                    @anaconda 
adwaita-icon-theme.noarch          3.28.0-2.el8                    @anaconda 
at-spi2-atk.x86_64                 2.26.2-1.el8                    @anaconda 
at-spi2-core.x86_64                2.28.0-1.el8                    @anaconda 
atk.x86_64                         2.28.1-1.el8                    @anaconda 
audit.x86_64                       3.0-0.17.20191104git1c2f876.el8 @anaconda 
audit-libs.x86_64                  3.0-0.17.20191104git1c2f876.el8 @anaconda 
authselect.x86_64                  1.2.2-1.el8                     @anaconda 
authselect-libs.x86_64             1.2.2-1.el8                     @anaconda
...
//列出已經(jīng)安裝的包
[root@lnh yum.repos.d]# dnf list updates 
Last metadata expiration check: 0:25:44 ago on Sat 09 Jul 2022 01:11:55 AM CST.
Available Upgrades
NetworkManager.x86_64                  1:1.32.10-4.el8              base     
NetworkManager-libnm.x86_64            1:1.32.10-4.el8              base     
NetworkManager-team.x86_64             1:1.32.10-4.el8              base     
NetworkManager-tui.x86_64              1:1.32.10-4.el8              base     
authselect.x86_64                      1.2.2-3.el8                  base     
authselect-libs.x86_64                 1.2.2-3.el8                  base     
bash.x86_64                            4.4.20-2.el8                 base     
bind-export-libs.x86_64                32:9.11.26-6.el8             base     
brotli.x86_64                          1.0.6-3.el8                  base     
ca-certificates.noarch                 2021.2.50-80.0.el8_4         base     
centos-gpg-keys.noarch                 1:8-3.el8                    base     
centos-stream-repos.noarch             8-3.el8                      extras   
chkconfig.x86_64                       1.19.1-1.el8                 base     
coreutils.x86_64                       8.30-12.el8                  base     
//列出可升級的包,并且已經(jīng)指定了可以升級到上面版本
[root@lnh yum.repos.d]# dnf clean packages 
0 files removed
//清理緩存的包
headers  清理頭部文件
metadata 清理元數(shù)據(jù)
dbcache  清理數(shù)據(jù)庫
[root@lnh ~]# dnf repolist all
repo id        repo name                                             status
AppStream      CentOS-8.5.2111 - AppStream - mirrors.aliyun.com      enabled
PowerTools     CentOS-8.5.2111 - PowerTools - mirrors.aliyun.com     disabled
base           CentOS-8.5.2111 - Base - mirrors.aliyun.com           enabled
centosplus     CentOS-8.5.2111 - Plus - mirrors.aliyun.com           disabled
extras         CentOS-8.5.2111 - Extras - mirrors.aliyun.com         enabled
//顯示列表的信息
[root@lnh ~]# dnf repolist enabled
repo id            repo name
AppStream          CentOS-8.5.2111 - AppStream - mirrors.aliyun.com
base               CentOS-8.5.2111 - Base - mirrors.aliyun.com
extras             CentOS-8.5.2111 - Extras - mirrors.aliyun.com
//顯示默認是enabled
[root@lnh ~]# dnf repolist disabled
repo id            repo name
PowerTools         CentOS-8.5.2111 - PowerTools - mirrors.aliyun.com
centosplus         CentOS-8.5.2111 - Plus - mirrors.aliyun.com
//顯示禁用的

升級,查詢

[root@lnh ~]# dnf list all |grep curl
curl.x86_64                                            7.61.1-17.el8                                          @anaconda 
libcurl.x86_64                                         7.61.1-17.el8                                          @anaconda 
curl.x86_64                                            7.61.1-22.el8                                          base      
libcurl.i686                                           7.61.1-22.el8                                          base      
libcurl.x86_64                                         7.61.1-22.el8                                          base      
libcurl-devel.i686                                     7.61.1-22.el8                                          base      
libcurl-devel.x86_64                                   7.61.1-22.el8                                          base      
libcurl-minimal.i686                                   7.61.1-22.el8                                          base      
libcurl-minimal.x86_64                                 7.61.1-22.el8                                          base      
nbdkit-curl-plugin.x86_64                              1.16.2-4.module_el8.5.0+746+bbd5d70c                   AppStream 
python3-pycurl.x86_64                                  7.43.0.2-4.el8                                         AppStream 
qemu-kvm-block-curl.x86_64                             15:4.2.0-59.module_el8.5.0+1063+c9b9feff.1             AppStream 
//列出curl的包
[root@lnh ~]# dnf list updates 
Last metadata expiration check: 008 ago on Sat 09 Jul 2022 0155 AM CST.
Available Upgrades
NetworkManager.x86_64                    1:1.32.10-4.el8           base     
NetworkManager-libnm.x86_64              1:1.32.10-4.el8           base     
NetworkManager-team.x86_64               1:1.32.10-4.el8           base     
NetworkManager-tui.x86_64                1:1.32.10-4.el8           base     
authselect.x86_64                        1.2.2-3.el8               base     
authselect-libs.x86_64                   1.2.2-3.el8               base     
bind-export-libs.x86_64                  32:9.11.26-6.el8          base     
ca-certificates.noarch                   2021.2.50-80.0.el8_4      base     
centos-gpg-keys.noarch                   1:8-3.el8                 base     
...
//列出可升級的包
[root@lnh ~]# dnf list all | grep man-db
man-db.x86_64                                          2.7.6.1-17.el8                                         @anaconda 
man-db.x86_64                                          2.7.6.1-18.el8                                         base      
man-db-cron.noarch                                     2.7.6.1-18.el8                                         base      
//列出man-db的包
[root@lnh ~]# dnf -y update man-db
Last metadata expiration check: 131 ago on Sat 09 Jul 2022 0155 AM CST.
Dependencies resolved.
============================================================================
 Package        Architecture   Version                   Repository    Size
============================================================================
Upgrading:
 man-db         x86_64         2.7.6.1-18.el8            base         887 k

Transaction Summary
============================================================================
Upgrade  1 Package

Total size: 887 k
Downloading Packages:
[SKIPPED] man-db-2.7.6.1-18.el8.x86_64.rpm: Already downloaded             
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
  Preparing        :                                                    1/1 
  Running scriptlet: man-db-2.7.6.1-18.el8.x86_64                       1/1 
  Running scriptlet: man-db-2.7.6.1-18.el8.x86_64                       1/2 
  Upgrading        : man-db-2.7.6.1-18.el8.x86_64                       1/2 
  Running scriptlet: man-db-2.7.6.1-18.el8.x86_64                       1/2 
  Cleanup          : man-db-2.7.6.1-17.el8.x86_64                       2/2 
  Running scriptlet: man-db-2.7.6.1-17.el8.x86_64                       2/2 
  Running scriptlet: man-db-2.7.6.1-18.el8.x86_64                       2/2 
  Verifying        : man-db-2.7.6.1-18.el8.x86_64                       1/2 
  Verifying        : man-db-2.7.6.1-17.el8.x86_64                       2/2 
Installed products updated.

Upgraded:
  man-db-2.7.6.1-18.el8.x86_64                                              

Complete!
//對其進行升級
[root@lnh ~]# dnf info man-db
Last metadata expiration check: 101 ago on Sat 09 Jul 2022 0155 AM CST.
Installed Packages
Name         : man-db
Version      : 2.7.6.1
Release      : 18.el8
Architecture : x86_64
Size         : 1.9 M
Source       : man-db-2.7.6.1-18.el8.src.rpm
Repository   : @System
From repo    : base
Summary      : Tools for searching and reading man pages
URL          : http://www.nongnu.org/man-db/
License      : GPLv2+ and GPLv3+
Description  : The man-db package includes five tools for browsing
             : man-pages: man, whatis, apropos, manpath and lexgrog. man
             : formats and displays manual pages. whatis searches the manual
             : page names. apropos searches the manual page names and
             : descriptions. manpath determines search path for manual
             : pages. lexgrog directly reads header information in manual
             : pages.

//列出軟件包的信息相當(dāng)于rpm包里面的用rpm -qi 包查看信息

與歷史記錄相關(guān)的命令

[root@lnh ~]# dnf history 
ID     | Command line             | Date and time    | Action(s)      | Altered
-------------------------------------------------------------------------------
    21 | -y update man-db         | 2022-07-09 02:13 | Upgrade        |    1  <
    20 | update                   | 2022-07-09 01:53 | I, U           |  261 >#
    19 | -q install wget          | 2022-07-09 01:30 | Install        |    1   
    18 | -y remove wget           | 2022-07-09 01:29 | Removed        |    1   
    17 | -y install --nogpgcheck  | 2022-07-09 01:28 | Install        |    1   
    16 | -y remove wget           | 2022-07-09 01:28 | Removed        |    1   
    15 | -y install vim           | 2022-07-09 01:11 | Install        |    4   
    14 | -y remove vim            | 2022-07-09 01:10 | Removed        |    4  <
    13 | -y install sudo          | 2022-07-04 15:36 | Upgrade        |    1 > 
    12 | -y install iotop         | 2022-07-04 05:35 | Install        |    1   
    11 | -y install htop          | 2022-07-04 04:57 | Install        |    1   
    10 | -y install psmisc        | 2022-07-03 22:03 | Install        |    1   
     9 | -y install tar           | 2022-06-30 08:58 | Install        |    1   
     8 | -y install zip           | 2022-06-30 04:45 | Install        |    1   
     7 | -y install unzip         | 2022-06-30 02:17 | Install        |    1   
     6 | -y install bzip2         | 2022-06-30 02:15 | Install        |    1   
     5 | -y install tree          | 2022-06-28 04:31 | Install        |    1   
     4 | -y install bash-completi | 2022-06-27 22:10 | Install        |    5   
     3 | -y install epel-release  | 2022-06-27 22:09 | Install        |    1   
     2 | -y install vim           | 2022-06-27 21:17 | Install        |    4   
     1 |                          | 2022-06-27 21:06 | Install        |  425 EE
//最后一個空白處表示我們剛剛安裝系統(tǒng)時的
其他的但是系統(tǒng)安裝好后用下載命令進行下載安裝包的記錄
[root@lnh ~]# dnf history info   2
Transaction ID : 2
Begin time     : Mon 27 Jun 2022 0923 PM CST
Begin rpmdb    : 423:cac03573ad9f7d066e36879b5909fe1b1f0fff31
End time       : Mon 27 Jun 2022 0928 PM CST (5 seconds)
End rpmdb      : 427:8e6c64e107fb4b38d247b4e55187de6b5ea05370
User           : root 
Return-Code    : Success
Releasever     : 8
Command Line   : -y install vim
Comment        : 
Packages Altered:
    Install gpm-libs-1.20.7-17.el8.x86_64                @appstream
    Install vim-common-2:8.0.1763-16.el8_5.12.x86_64     @appstream
    Install vim-enhanced-2:8.0.1763-16.el8_5.12.x86_64   @appstream
    Install vim-filesystem-2:8.0.1763-16.el8_5.12.noarch @appstream
//查詢歷史執(zhí)行yum命令2的詳細信息
[root@lnh ~]# dnf history undo 20
//撤銷歷史執(zhí)行過yum命令里面第20個

grouplist,groups mark install

[root@lnh ~]# dnf grouplist 
Last metadata expiration check: 1:33:17 ago on Sat 09 Jul 2022 01:11:55 AM CST.
Available Environment Groups:
   Server with GUI
   Server
   Workstation
   Custom Operating System
   Virtualization Host
Installed Environment Groups:
   Minimal Install
Available Groups:
   Legacy UNIX Compatibility
   Container Management
   Development Tools
   .NET Core Development
   Graphical Administration Tools
   Headless Management
   Network Servers
   RPM Development Tools
   Scientific Support
   Security Tools
   Smart Card Support
   System Tools
//列出可用的組包或者
[root@lnh ~]# dnf groups mark install -y "System Tools"
Last metadata expiration check: 1:37:35 ago on Sat 09 Jul 2022 01:11:55 AM CST.
Dependencies resolved.
===================================================================================================================================================================
 Package                                Architecture                          Version                                 Repository                              Size
===================================================================================================================================================================
Installing Groups:
 System Tools                                                                                                                                                     

Transaction Summary
===================================================================================================================================================================

Complete!
//將"System Tools"標(biāo)記為安裝組包。表面上感覺它很快就安裝好了,實際上它在后臺進行安裝,所以看起來安裝速度快。
[root@lnh ~]# dnf grouplist -y
Last metadata expiration check: 1:42:32 ago on Sat 09 Jul 2022 01:11:55 AM CST.
Available Environment Groups:
   Server with GUI
   Server
   Workstation
   Custom Operating System
   Virtualization Host
Installed Environment Groups:
   Minimal Install
Installed Groups:
   System Tools
Available Groups:
   Legacy UNIX Compatibility
   Container Management
   Development Tools
   .NET Core Development
   Graphical Administration Tools
   Headless Management
   Network Servers
   RPM Development Tools
   Scientific Support
   Security Tools
   Smart Card Support
//查看已經(jīng)安裝的組包

reinstall 重新安裝

[root@lnh ~]# dnf list installed | grep wget
wget.x86_64                                   1.19.5-10.el8                         @AppStream
//重新安裝
[root@lnh ~]# rpm -qc wget
/etc/wgetrc
//查看安裝wget產(chǎn)生了哪些配置文件
[root@lnh ~]# rm -f /etc/wgetrc 
[root@lnh ~]# ls /etc/ |grep wgetrc
[root@lnh ~]# 
//誤刪除了這個
[root@lnh ~]# dnf -y reinstall wget
Last metadata expiration check: 245 ago on Sat 09 Jul 2022 0155 AM CST.
Dependencies resolved.
============================================================================
 Package      Architecture   Version                Repository         Size
============================================================================
Reinstalling:
 wget         x86_64         1.19.5-10.el8          AppStream         734 k

Transaction Summary
============================================================================

Total download size: 734 k
Installed size: 2.8 M
Downloading Packages:
wget-1.19.5-10.el8.x86_64.rpm               5.9 MB/s | 734 kB     00:00    
----------------------------------------------------------------------------
Total                                       5.8 MB/s | 734 kB     00:00     
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
  Preparing        :                                                    1/1 
  Reinstalling     : wget-1.19.5-10.el8.x86_64                          1/2 
  Running scriptlet: wget-1.19.5-10.el8.x86_64                          1/2 
  Running scriptlet: wget-1.19.5-10.el8.x86_64                          2/2 
  Cleanup          : wget-1.19.5-10.el8.x86_64                          2/2 
  Running scriptlet: wget-1.19.5-10.el8.x86_64                          2/2 
  Verifying        : wget-1.19.5-10.el8.x86_64                          1/2 
  Verifying        : wget-1.19.5-10.el8.x86_64                          2/2 
Installed products updated.

Reinstalled:
  wget-1.19.5-10.el8.x86_64                                                 

Complete!
//重新下載
[root@lnh ~]# ls /etc/ |grep wgetrc
wgetrc
//發(fā)現(xiàn)又生成了一份配置文件

下載但不安裝
將其rpm包安裝到指定的目錄中

[root@lnh ~]# dnf -y install --downloadonly --downloaddir /tushanbu/ zshd
Last metadata expiration check: 2:28:26 ago on Sat 09 Jul 2022 01:11:55 AM CST.
No match for argument: zshd
Error: Unable to find a match: zshd
[root@lnh ~]# dnf -y install --downloadonly --downloaddir /tushanbu/ zstd
Last metadata expiration check: 2:28:38 ago on Sat 09 Jul 2022 01:11:55 AM CST.
Dependencies resolved.
============================================================================
 Package      Architecture   Version                Repository         Size
============================================================================
Installing:
 zstd         x86_64         1.4.4-1.el8            AppStream         393 k

Transaction Summary
============================================================================
Install  1 Package

Total download size: 393 k
Installed size: 1.5 M
DNF will only download packages for the transaction.
Downloading Packages:
zstd-1.4.4-1.el8.x86_64.rpm                 111 kB/s | 393 kB     00:03    
----------------------------------------------------------------------------
Total                                       111 kB/s | 393 kB     00:03     
Complete!
The downloaded packages were saved in cache until the next successful transaction.
You can remove cached packages by executing 'dnf clean packages'.
//將zstd安裝需要的rpm包全部下載到tushanbu這個目錄里面,但是zstd沒有進行安裝(此處是在本地rpm包里面進行下載的,網(wǎng)絡(luò)上下載的也和這個差不多)

聲明:本文內(nèi)容及配圖由入駐作者撰寫或者入駐合作網(wǎng)站授權(quán)轉(zhuǎn)載。文章觀點僅代表作者本人,不代表電子發(fā)燒友網(wǎng)立場。文章及其配圖僅供工程師學(xué)習(xí)之用,如有內(nèi)容侵權(quán)或者其他違規(guī)問題,請聯(lián)系本站處理。 舉報投訴
  • 網(wǎng)絡(luò)
    +關(guān)注

    關(guān)注

    14

    文章

    7795

    瀏覽量

    90623
  • 工具
    +關(guān)注

    關(guān)注

    4

    文章

    314

    瀏覽量

    28225
  • 鏡像
    +關(guān)注

    關(guān)注

    0

    文章

    178

    瀏覽量

    11173

原文標(biāo)題:yum 工具使用大全:從安裝到更新,輕松管理軟件包

文章出處:【微信號:magedu-Linux,微信公眾號:馬哥Linux運維】歡迎添加關(guān)注!文章轉(zhuǎn)載請注明出處。

收藏 人收藏
加入交流群
微信小助手二維碼

掃碼添加小助手

加入工程師交流群

  • jf_699711251

評論

相關(guān)推薦
熱點推薦

【RA4L1-SENSOR】RA4L1-SENSOR開發(fā)版開箱評測+e2studio軟件安裝

和調(diào)試的開發(fā)工具。 e2 studio 基于開源Eclipse IDE和與之相關(guān)的C/C++開發(fā)工具(CDT)。 e2 studio 托管了瑞薩的FSP靈活配置軟件包,這是一個用于支持瑞薩MCU開發(fā)
發(fā)表于 06-12 23:23

瑞薩電子RA系列微控制器的可擴展性強的配置軟件包 (FSP)安裝下載與使用指南

瑞薩電子RA系列微控制器的可擴展性強的配置軟件包 (FSP)安裝下載與使用指南
的頭像 發(fā)表于 06-11 17:21 ?491次閱讀

Helm倉庫管理常用配置

Helm 倉庫(Repository)是存儲 Helm 圖表(Chart)的地方,類似于軟件包管理器的倉庫(如 apt、yum 倉庫)。
的頭像 發(fā)表于 06-07 09:27 ?236次閱讀

RT-Thread Studio更新軟件包為什么不成功呢?

RT-Thread Studio更新軟件包出現(xiàn) MESSAGE cmd_package_update 462 WARNING Error message : local variable
發(fā)表于 05-27 06:53

CFA科普系列01|EDA工具裝不上?可能不是你技術(shù)差,而是少了這兩個命令

(Yellowdog Updater Modified)是基于 RPM 包管理的增強型工具,它能自動解析依賴關(guān)系、軟件源下載所需文件,一次性完成所有
發(fā)表于 05-09 15:27

用一套Linux系統(tǒng),撐起整個芯片設(shè)計平臺?CFA團隊教你如何搭好EDA智算平臺的技術(shù)底座

時間,則可以選擇 Ubuntu。 軟件包管理RPM到YUM,讓EDA工具“一鍵上崗” 在對Linux系統(tǒng)的使用和操作過程中,需要經(jīng)常安裝
發(fā)表于 05-07 14:44

RFID固定資產(chǎn)管理軟件如何優(yōu)化服裝倉儲管理效率

在服裝行業(yè)數(shù)字化轉(zhuǎn)型浪潮中,RFID固定資產(chǎn)管理軟件與智能倉儲系統(tǒng)的結(jié)合,正成為企業(yè)降本增效的核心工具。本文RFID技術(shù)應(yīng)用場景出發(fā),解析其在服裝庫存盤點、資產(chǎn)追蹤及倉儲流程優(yōu)化中的關(guān)鍵技術(shù)價值。
的頭像 發(fā)表于 03-21 12:44 ?229次閱讀

無法在Raspberry Pi 4中通過PyPI OpenVINO?安裝2022年運行時軟件包,為什么?

無法在 Raspberry* Pi 4 中通過 PyPI* 安裝OpenVINO? 2022 運行時軟件包。
發(fā)表于 03-05 07:31

ShiMetaOS | 怎樣調(diào)用ShiMeta通行管理軟件打造各類通行管理終端

顯著減少了用戶的運營成本,提供了一款既經(jīng)濟又高效的通行解決方案。本文將詳細介紹如何調(diào)用ShiMeta通行管理軟件,助您輕松打造通行管理終端。一怎樣調(diào)用ShiMetaOS
的頭像 發(fā)表于 02-20 16:03 ?440次閱讀
ShiMetaOS  | 怎樣調(diào)用ShiMeta通行<b class='flag-5'>管理軟件</b>打造各類通行<b class='flag-5'>管理</b>終端

i.MX8M Yocto工程更新第三方軟件包

NXPi.MX8M系列依托于Yocto工程進行簡單快捷的配置,可以方便增刪第三方軟件包以及更改內(nèi)核、Uboot源碼等。目前有些客戶希望能夠升級Yocto自帶軟件版本,這里就以我司
的頭像 發(fā)表于 02-12 08:11 ?565次閱讀
i.MX8M Yocto工程<b class='flag-5'>更新</b>第三方<b class='flag-5'>軟件包</b>

在Linux下安裝軟件有哪些方法

在Linux下安裝軟件,可以有哪些方法? 首先是最簡單的,使用軟件包管理工具。 如果是ubuntu或者debian系統(tǒng),可以使用apt;如果是紅帽或者centos,可以使用yum。 所
的頭像 發(fā)表于 02-08 09:41 ?589次閱讀

極海半導(dǎo)體推出AUTOSAR MCAL軟件包和配置工具

針對G32A14XX系列汽車通用MCU,極海正式推出具備獨立知識產(chǎn)權(quán)、完全自主開發(fā)的?AUTOSAR MCAL軟件包和配置工具,這標(biāo)志著極海已具備完善的、高水準(zhǔn)的、獨立自主的AUTOSAR軟件
的頭像 發(fā)表于 11-17 16:42 ?951次閱讀
極海半導(dǎo)體推出AUTOSAR MCAL<b class='flag-5'>軟件包</b>和配置<b class='flag-5'>工具</b>

Jtti:如何查看yum命令的錯誤日志來診斷問題?

history 命令來查看Yum事務(wù)的歷史記錄,這包括了事務(wù)ID、執(zhí)行操作的用戶、操作發(fā)生的日期和時間、實際操作以及任何錯誤的附加信息。例如,要查看完整的Yum歷史記錄,可以使用以下命令: 要查看涉及特定軟件包的事務(wù)詳情,可以
的頭像 發(fā)表于 10-14 15:51 ?686次閱讀

LIMS實驗室管理軟件在汽車零部件行業(yè)的應(yīng)用

LIMS實驗室管理軟件在汽車零部件行業(yè)的應(yīng)用不僅提高了生產(chǎn)效率和產(chǎn)品質(zhì)量,還促進了企業(yè)的可持續(xù)發(fā)展和合規(guī)性管理。隨著技術(shù)的不斷進步和汽車行業(yè)對質(zhì)量管理的日益重視,LIMS實驗室管理軟件
的頭像 發(fā)表于 08-20 14:58 ?833次閱讀

基于ebian發(fā)行版的AvaotaOS下的dpkg和apt工具使用方法詳解

和已安裝軟件包進行管理。 該機制最早由 Debian Linux 社區(qū)開發(fā)。通過dpkg的機制,Debian提供的軟件能夠輕松
發(fā)表于 07-03 14:59

電子發(fā)燒友

中國電子工程師最喜歡的網(wǎng)站

  • 2931785位工程師會員交流學(xué)習(xí)
  • 獲取您個性化的科技前沿技術(shù)信息
  • 參加活動獲取豐厚的禮品