yum 軟件管理器


yum軟件管理器

yum是一個強大的軟件包管理器,能夠自動解決安裝時rpm包之間的依賴關系。

一、使用yum管理軟件包

1、使用命令 yum help 查看使用方法

[root@majinhai ~]# yum help
已加載插件:fastestmirror, langpacks
Usage: yum [options] COMMAND
 
List of Commands:
 
check 檢查 RPM 數據庫問題
check-update 檢查是否有可用的軟件包更新
clean 刪除緩存數據
deplist 列出軟件包的依賴關系
distribution-synchronization 已同步軟件包到最新可用版本
downgrade 降級軟件包
erase 從系統中移除一個或多個軟件包
fs Acts on the filesystem data of the host, mainly for removing docs/lanuages for minimal hosts.
fssnapshot Creates filesystem snapshots, or lists/deletes current snapshots.
groups 顯示或使用、組信息
help 顯示用法提示
history 顯示或使用事務歷史
info 顯示關於軟件包或組的詳細信息
install 向系統中安裝一個或多個軟件包
langavailable Check available languages
langinfo List languages information
langinstall Install appropriate language packs for a language
langlist List installed languages
langremove Remove installed language packs for a language
list 列出一個或一組軟件包
load-transaction 從文件名中加載一個已存事務
makecache 創建元數據緩存
provides 查找提供指定內容的軟件包
reinstall 覆蓋安裝軟件包
repo-pkgs 將一個源當作一個軟件包組,這樣我們就可以一次性安裝/移除全部軟件包。
repolist 顯示已配置的源
search 在軟件包詳細信息中搜索指定字符串
shell 運行交互式的 yum shell
swap Simple way to swap packages, instead of using shell
update 更新系統中的一個或多個軟件包
update-minimal Works like upgrade, but goes to the 'newest' package match which fixes a problem that affects your system
updateinfo Acts on repository update information
upgrade 更新軟件包同時考慮軟件包取代關系
version 顯示機器和/或可用的源版本。
 
 
Options:
- h, --help 顯示此幫助消息並退出
-t, --tolerant 忽略錯誤
-C, --cacheonly 完全從系統緩存運行,不升級緩存
-c [config file], --config=[config file]
配置文件路徑
- R [minutes], --randomwait=[minutes]
命令最長等待時間
- d [debug level], --debuglevel=[debug level]
調試輸出級別
- -showduplicates 在 list/search 命令下,顯示源里重復的條目
-e [error level], --errorlevel=[error level]
錯誤輸出級別
- -rpmverbosity=[debug level name]
RPM 調試輸出級別
- q, --quiet 靜默執行
-v, --verbose 詳盡的操作過程
-y, --assumeyes 回答全部問題為是
--assumeno 回答全部問題為否
--version 顯示 Yum 版本然后退出
--installroot=[path] 設置安裝根目錄
--enablerepo=[repo] 啟用一個或多個軟件源(支持通配符)
--disablerepo=[repo] 禁用一個或多個軟件源(支持通配符)
-x [package], --exclude=[package]
采用全名或通配符排除軟件包
- -disableexcludes=[repo]
禁止從主配置,從源或者從任何位置排除
- -disableincludes=[repo]
disable includepkgs for a repo or for everything
- -obsoletes 更新時處理軟件包取代關系
--noplugins 禁用 Yum 插件
--nogpgcheck 禁用 GPG 簽名檢查
--disableplugin=[plugin]
禁用指定名稱的插件
- -enableplugin=[plugin]
啟用指定名稱的插件
- -skip-broken 忽略存在依賴關系問題的軟件包
--color=COLOR 配置是否使用顏色
--releasever=RELEASEVER
在 yum 配置和 repo 文件里設置 $releasever 的值
- -downloadonly 僅下載而不更新
--downloaddir=DLDIR 指定一個其他文件夾用於保存軟件包
--setopt=SETOPTS 設置任意配置和源選項
--bugfix Include bugfix relevant packages, in updates
--security Include security relevant packages, in updates
--advisory=ADVS, --advisories=ADVS
Include packages needed to fix the given advisory, in
updates
- -bzs=BZS Include packages needed to fix the given BZ, in
updates
- -cves=CVES Include packages needed to fix the given CVE, in
updates
- -sec-severity=SEVS, --secseverity=SEVS
Include security relevant packages matching the
severity, in updates

2、使用yum search ‘字符串’ 在軟件包詳細信息中搜索指定字符串 
例如:yum search ifconfig 查看ifconfig屬於哪個包

[root@majinhai ~]# yum search ifconfig
已加載插件:fastestmirror, langpacks
Loading mirror speeds from cached hostfile
* base: mirrors.aliyun. com
* extra s: mirrors.aliyun.com
* updates: mirrors.aliyun.com
===================================== 匹配:ifconfig ======================================
net-tools.x86_64 : Basic networking tools
[root@majinhai ~]#

3、使用yum install ‘包名’ 向系統中安裝一個或多個軟件包 
上面查到net-tools這個包里面包含了ifconfig這個命令,接下來我們安裝這個包 
輸入yum install -y net-tools ( -y, –assumeyes 回答全部問題為是)

[root@majinhai ~]# yum install -y net-tools
已加載插件:fastestmirror, langpacks
Loading mirror speeds from cached hostfile
* base: mirrors.aliyun.com
* extras: mirrors.aliyun.com
* updates: mirrors.aliyun.com
base | 3.6 kB 00:00:00
extras | 3.4 kB 00:00:00
updates | 3.4 kB 00:00:00
正在解決依賴關系
--> 正在檢查事務
---> 軟件包 net-tools.x86 _64.0.2.0-0.22.20131004git.el7 將被 安裝
--> 解決依賴關系完成
 
依賴關系解決
 
===========================================================================================
Package 架構 版本 源 大小
===========================================================================================
正在安裝:
net-tools x86_64 2.0-0.22.20131004git.el7 base 305 k
 
事務概要
===========================================================================================
安裝 1 軟件包
 
總下載量:305 k
安裝大小:917 k
Downloading packages:
No Presto metadata available for base
net-tools-2.0-0.22.20131004git.el7.x86 _64.rpm | 305 kB 00:00:00
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
正在安裝 : net-tools-2.0-0.22.20131004git.el7.x86_64 1/1
驗證中 : net-tools-2.0-0.22.20131004git.el7.x86_64 1/1
 
已安裝:
net-tools.x86_64 0:2.0-0.22.20131004git.el7
 
完畢!

4、yum info ‘包名’ info 顯示關於軟件包或組的詳細信息 
查看net-tools包的詳細信息 
鍵入 yum info net-tools

[root@majinhai ~] # yum info net-tools
已加載插件:fastestmirror, langpacks
Loading mirror speeds from cached hostfile
* base: mirrors.aliyun.com
* extras: mirrors.aliyun.com
* updates: mirrors.aliyun.com
可安裝的軟件包
名稱 :net-tools
架構 :x86_64
版本 :2.0
發布 :0.22.20131004git.el7
大小 :305 k
源 :base/7/x86_64
簡介 : Basic networking tools
網址 :http://sourceforge.net/projects/net-tools/
協議 : GPLv2+
描述 : The net-tools package contains basic networking tools,
: including ifconfig, netstat, route, and others.
: Most of them are obsolete. For replacement check iproute package.

5、yum provides ‘路徑’ provides 查找提供指定內容的軟件包。也就是說,查看指定目錄與那些軟件包有關系 
鍵入yum provides /etc/yum.repos.d/

[root@majinhai ~]# yum provides /etc/yum.repos.d/
已加載插件:fastestmirror, langpacks
Loading mirror speeds from cached hostfile
* base: mirrors.aliyun.com
* extras: mirrors.aliyun.com
* updates: mirrors.aliyun.com
yum- 3.4.3-158.el7.centos.noarch : RPM package installer/updater/manager
源 :base
匹配來源:
文件名 :/etc/yum.repos.d/
yum- 3.4.3-158.el7.centos.noarch : RPM package installer/updater/manager
源 :@anaconda
匹配來源:
文件名 :/etc/yum.repos.d/

6、yum list ‘字符串’ list 列出一個或一組軟件包,查看已安裝的和可用的軟件包, 
例如:查詢yum相關的軟件包 
鍵入 yum list yum

[root@majinhai yum.repos.d]# yum list yum
已加載插件: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
* base: mirrors.aliyun.com
* extras: mirrors.aliyun.com
* updates: mirrors.aliyun.com
已安裝的軟件包
yum.noarch 3.4.3-158.el7.centos @anaconda

7、yum update 獲取並安裝更新版本的軟件包,包括依賴關系;通常情況下yum uptate嘗試保留原版本的配置文件,但在某些情況下,如果打包廠商認為舊版本的配置文件在更新后將無法使用,則會對其進行重命名;如果不加參數直接運行yum uptate 將會安裝所有更新。

二、使用yum管理組軟件

yum 另一個強大的功能就是具有組的概念,就是針對某個目的而一起安裝的相關軟件的集合。如;一次性安裝gnome桌面等 
1、yum grouplist 命令將列出已安裝和可用的組的名稱。 
命令yum grouplist

[root@majinhai ~]# yum grouplist
已加載插件: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
* base: mirrors.aliyun.com
* extras: mirrors.aliyun.com
* updates: mirrors.aliyun.com
已安裝環境分組:
GNOME 桌面
可用的環境分組:
最小安裝
基礎設施服務器
計算節點
文件及打印服務器
基本網頁服務器
虛擬化主機
GUI 的服務器
KDE Plasma Workspaces
開發及生成工作站
可用組:
傳統 UNIX 兼容性
兼容性程序庫
圖形管理工具
安全性工具
開發工具
控制台互聯網工具
智能卡支持
科學記數法支持
系統管理
系統管理工具
完成

2、yum groupinstall ‘字符串’安裝某個指定的組 
命令yum groupinstall ‘GNOME 桌面’ 安裝GNOME圖形化界面

假裝此處是正常的
[root@majinhai ~]# yum groupinstall 'GNOME 桌面'
已加載插件:fastestmirror, langpacks
Loading mirror speeds from cached hostfile
* base: mirrors.aliyun. com
* extra s: mirrors.aliyun.com
* updates: mirrors.aliyun.com

3、yum groupinfo ‘字符串’ 顯示該組的詳細信息。它將列出比選、默認和可選軟件包或組ID前面可能標有標記; 
示例:列出GNOME 桌面 軟件組詳細信息

標記 含義
= 軟件包已安裝,以作為該組的一部分安裝
+ 軟件包未安裝,將在安裝或更新該組時安裝
- 軟件包未安裝,不會再安裝或更新該組時安裝
未標記 軟件包已安裝,但不是通過該組安裝的

yum groupinfo ’GNOME桌面‘

[root@majinhai ~]# yum groupinfo 'GNOME 桌面'
已加載插件:fastestmirror, langpacks
Loading mirror speeds from cached hostfile
* base: mirrors.aliyun.com
* extras: mirrors.aliyun.com
* updates: mirrors.aliyun.com
 
環境分組:GNOME 桌面
環境 ID:gnome-desktop-environment
描述:GNOME 是一個非常直觀且用戶友好的桌面環境。
必備組:
= base
=core
=desktop-debugging
=dial-up
=directory-client
=fonts
=gnome-desktop
=guest-agents
=guest-desktop-agents
=input-methods
=internet-browser
=java-platform
=multimedia
=network-file-system-client
=networkmanager-submodules
=print-client
=x11
可選組:
+backup-client
+gnome-apps
+internet-applications
+legacy-x
+office-suite
+remote-desktop-clients
+smart-card

三、查看歷史事件及記錄

所有操作及安裝和刪除的操作記錄都會保存在/var/log/yum.log中。

1、查看/var/log/yum.log最后10行

tail -10 /var/log/yum.log

[root@majinhai ~]# tail -10 /var/log/yum.log
Aug 04 16:21:19 Installed: 1:pnm2ppa-1.04-28.el7.x86_64
Aug 04 16:21:22 Installed: man-pages-3.53-5.el7.noarch
Aug 04 16:21:22 Installed: kpatch-0.4.0-3.el7.noarch
Aug 04 16:21:22 Installed: 10:qemu-guest-agent-2.8.0-2.el7.x86_64
Aug 04 16:21:22 Installed: 2:mtr-0.85-7.el7.x86_64
Aug 04 16:21:22 Installed: rfkill-0.4-9.el7.x86_64
Aug 04 16:21:22 Installed: net-tools-2.0-0.22.20131004git.el7.x86_64
Aug 04 16:21:22 Installed: words-3.0-22.el7.noarch
Aug 04 16:21:23 Installed: tcsh-6.18.01-15.el7.x86_64
Aug 04 20:55:16 Erased: net-tools-2.0-0.22.20131004git.el7.x86_64

2、yum history 查看安裝和刪除操作記錄的摘要 
yum history

[root @majinhai ~]# yum history
已加載插件:fastestmirror, langpacks
ID | 登錄用戶 | 日期和時間 | 操作 | 變更數
-------------------------------------------------------------------------------
3 | root <root> | 2018-08-04 20:55 | Erase | 1
2 | root <root> | 2018-08-04 16:16 | I, U | 1068 EE
1 | 系統 <空> | 2018-08-03 17:10 | Install | 307
history list

3、yum history undo ’字符串‘ 撤銷事件。 
例如:撤銷 ID為2的操作 
yum history undo 2

[root @majinhai ~]# yum history undo 2

4、yum localinstall ’*rpm‘ 安裝本地RPM包。

[root @majinhai ~]# yum localinstall 123.rpm
 
 
 
 
 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM