http://flycars001.iteye.com/blog/1949085
YUM到底是啥東東?
YUM(Yellowdog Updater Modified)是一款開(kāi)源命令行及圖形化軟件包管理工具,面向基于RPM(紅帽軟件包管理器)的Linux系統(tǒng)。 它讓廣大用戶(hù)和系統(tǒng)管理員可以在系統(tǒng)上輕松地安裝、更新、移除或搜索軟件包。它由Seth Vidal開(kāi)發(fā)和發(fā)布,采用了GPL(通用公共許可證),是一款開(kāi)源工具。這意味著,誰(shuí)都可以下載和訪問(wèn)代碼,以修復(fù)軟件錯(cuò)誤,開(kāi)發(fā)定制的軟件包。YUM 通過(guò)解決軟件包的依賴(lài)項(xiàng)問(wèn)題,使用眾多的第三方軟件庫(kù)來(lái)自動(dòng)安裝軟件包。
1. 使用Yum安裝軟件包
想安裝一個(gè)名為Firefox 14的軟件包,只要運(yùn)行下面這個(gè)命令,它會(huì)自動(dòng)尋找并安裝Firefox瀏覽器的所有必要依賴(lài)項(xiàng)。
#?yum?install?firefox?Loaded?plugins:?fastestmirror?Dependencies?Resolved?====================================?Package????????????????????Arch????????Version????????????????????Repository????????????Size?====================================Updating:?firefox????????????????????????i686????????10.0.6-1.el6.centos?????updates?????????????20?M?Updating?for?dependencies:?xulrunner?????????????????????i686????????10.0.6-1.el6.centos?????updates?????????????12?M?Transaction?Summary?===========================================Install???????0?Package(s)?Upgrade???????2?Package(s)?Total?download?size:?32?M?Is?this?ok?[y/N]:?y?Downloading?Packages:?(1/2):?firefox-10.0.6-1.el6.centos.i686.rpm????????????????????????????????|??20?MB???01:10?(2/2):?xulrunner-10.0.6-1.el6.centos.i686.rpm??????????????????????????????|??12?MB???00:52?------------------------------------------------------------------------------------------------?Total???????????????????????????????????????????????????????????63?kB/s?|??32?MB???02:04?Updated:?firefox.i686?0:10.0.6-1.el6.centos?Dependency?Updated:?xulrunner.i686?0:10.0.6-1.el6.centos?Complete!?上述命令會(huì)先要求予以確認(rèn),然后再將任何軟件包安裝到你的系統(tǒng)上。如果你不要求任何確認(rèn),就想自動(dòng)安裝軟件包,可使用選項(xiàng)-y,如下例所示。
#?yum?-y?install?firefox?2. 使用Yum移除軟件包
想完全移除軟件包連同所有依賴(lài)項(xiàng),只要運(yùn)行下面這個(gè)命令,如下所示。
#?yum?remove?firefox?Loaded?plugins:?fastestmirror?Setting?up?Remove?Process?Resolving?Dependencies?-->?Running?transaction?check?--->?Package?firefox.i686?0:10.0.6-1.el6.centos?set?to?be?erased?-->?Finished?Dependency?Resolution?Dependencies?Resolved?===========================================Package????????????????????Arch????????Version????????????????????????Repository????????????Size?===========================================Removing:?firefox????????????????????i686????????10.0.6-1.el6.centos????????????@updates??????????????23?M?Transaction? Summary?===========================================Remove???????1?Package(s)?Reinstall???? ?0?Package(s)?Downgrade?????0?Package(s)?Is?this?ok?[y/N]:?y?Downloading?Packages:?Running?rpm_check_debug?Running?Transaction?Test?Transaction?Test?Succeeded?Running?Transaction?Erasing:firefox-10.0.6-1.el6.centos.i686???????????????????????????????????1/1?Removed:?firefox.i686?0:10.0.6-1.el6.centos?Complete!?同樣,上述命令會(huì)先要求予以確認(rèn),然后再移除軟件包。想禁用確認(rèn)提示,只要添加選項(xiàng)-y,如下所示。
?
#?yum?-y?remove?firefox?3. 使用Yum更新軟件包
假設(shè)你有過(guò)時(shí)版本的MySQL軟件包,想把它更新到最新的穩(wěn)定版本。只要運(yùn)行下面這個(gè)命令,它就會(huì)自動(dòng)解決所有的依賴(lài)項(xiàng)問(wèn)題,并安裝依賴(lài)項(xiàng)。
#?yum?update?mysql?Loaded?plugins:?fastestmirror?Dependencies?Resolved?===========================================Package????????????Arch????????????????Version????????????Repository?????????Size?===========================================Updating:?vsftpd?????????????i386??????????2.0.5-24.el5_8.1???????????updates???????????????144?k?Transaction? Summary?Install???????0?Package(s)?Upgrade?????1?Package(s)?Total?size:?144?k?Is?this?ok?[y/N]:?y?Downloading?Packages:?Running?rpm_check_debug?Running?Transaction?Test?Finished?Transaction?Test?Transaction?Test?Succeeded?Running?Transaction?Updating???????:?vsftpd??????????????????????????????????1/2?Cleanup????????:?vsftpd??????????????????????????????????2/2?Updated:?vsftpd.i386?0:2.0.5-24.el5_8.1?Complete!?4. 使用Yum列出軟件包
使用list函數(shù),可搜索帶名稱(chēng)的特定軟件包。比如說(shuō),想搜索一個(gè)名為openssh的軟件包,使用該命令。
#?yum?list?openssh?Loaded?plugins:?fastestmirror?Loading?mirror?speeds?from?cached?hostfile?*?base:?mirror.neu.edu.cn?*?epel:?mirror.neu.edu.cn?*?extras:?mirror.neu.edu.cn?*?rpmforge:?mirror.nl.leaseweb.net?*?updates:?mirror.nus.edu.sg?Installed?Packages?openssh.i386? ??4.3p2-72.el5_6.3???????????????????????????installed?Available?Packages?? 4.3p2-82.el5??????????????????????????base?想讓你的搜索更精確,明確軟件包名稱(chēng)的版本,如果你知道的話。比如說(shuō),想搜索軟件包的特定版本openssh-4.3p2 ,使用該命令。
#?yum?list?openssh-4.3p2?5. 使用Yum搜索軟件包
要是你不記得軟件包的確切名稱(chēng),那么可以使用search函數(shù),搜索與指定軟件包的名稱(chēng)相匹配的所有可用軟件包。比如說(shuō),想搜索與vsftpd這個(gè)單詞匹配的所有軟件包。
#?yum?search?vsftpd?Loaded?plugins:?fastestmirror?Loading?mirror?speeds?from?cached?hostfile?*?base:?mirror.neu.edu.cn?*?epel:?mirror.neu.edu.cn?*?extras:?mirror.neu.edu.cn?*?rpmforge:?mirror.nl.leaseweb.net?*?updates:?ftp.iitm.ac.in?==============================?Matched:?vsftpd?========================?ccze.i386?:?A?robust?log?colorizer?pure-ftpd-selinux.i386?:?SELinux?support?for?Pure-FTPD?vsftpd.i386?:?vsftpd?-?Very?Secure?Ftp?Daemon?6. 使用Yum獲取軟件包信息
假設(shè)你想在安裝軟件包之前先知道它的信息。想獲得某軟件包的信息,只要執(zhí)行下面這個(gè)命令。
#?yum?info?firefox?Loaded?plugins:?fastestmirror?Loading?mirror?speeds?from?cached?hostfile?*?base:?mirror.neu.edu.cn?*?epel:?mirror.neu.edu.cn?*?extras:?mirror.neu.edu.cn?*?rpmforge:?mirror.nl.leaseweb.net?*?updates:?ftp.iitm.ac.in?Available?Packages?Name??????:?firefox?Arch???????:?i386?Version?????:?10.0.6?Release?????:?1.el5.centos?Size????????:?20?M?Repo???????:?updates?Summary????:?Mozilla?Firefox?Web?browser?URL???????:?http://www.mozilla.org/projects/firefox/?License?????:?MPLv1.1?or?GPLv2+?or?LGPLv2+?Description??:?Mozilla?Firefox?is?an?open-source?web?browser,?designed?for?standards?:?compliance,?performance?and?portability.?7. 使用Yum列出所有的可用軟件包
想列出Yum數(shù)據(jù)庫(kù)中所有的可用軟件包,使用下面這個(gè)命令。
#?yum?list?|?less?8. 使用Yum列出所有的已安裝軟件包
想列出系統(tǒng)上所有的已安裝軟件包,只要執(zhí)行下面這個(gè)命令,它會(huì)顯示所有的已安裝軟件包。
#?yum?list?installed?|?less?9. Yum Provides函數(shù)
Yum provides函數(shù)用于查找某個(gè)特定文件屬于哪個(gè)軟件包。比如說(shuō),如果你想知道含有/etc/httpd/conf/httpd.conf文件的軟件包的名稱(chēng)。
#?yum?provides?/etc/httpd/conf/httpd.conf?Loaded?plugins:?fastestmirror?httpd-2.2.3-63.el5.centos.i386?:?Apache?HTTP?Server?Repo????????:?base?Matched?from:?Filename????:?/etc/httpd/conf/httpd.conf?httpd-2.2.3-63.el5.centos.1.i386?:?Apache?HTTP?Server?Repo????????:?updates?Matched?from:?Filename????:?/etc/httpd/conf/httpd.conf?httpd-2.2.3-65.el5.centos.i386?:?Apache?HTTP?Server?Repo????????:?updates?Matched?from:?Filename????:?/etc/httpd/conf/httpd.conf?httpd-2.2.3-53.el5.centos.1.i386?:?Apache?HTTP?Server?Repo????????:?installed?Matched?from:?Other???????:?Provides-match:?/etc/httpd/conf/httpd.conf?10. 使用Yum檢查可用更新版
想找出你系統(tǒng)上有多少已安裝軟件包有可用更新版,只要使用下面這個(gè)命令。
#?yum?check-update?11. 使用Yum更新系統(tǒng)
想確保系統(tǒng)版本最新,打上了所有的安全補(bǔ)丁和二進(jìn)制軟件包更新,只要運(yùn)行下面這個(gè)命令。它會(huì)為你的系統(tǒng)安裝所有最新的補(bǔ)丁和安全更新版。
#?yum?update?12. 列出所有的可用群組軟件包
在Linux中,軟件包數(shù)量與特定群組捆綁在一起。你可以安裝某個(gè)群組,它就會(huì)安裝屬于該群組的所有相關(guān)軟件包,用不著使用Yum安裝單個(gè)軟件包。比如說(shuō),想列出所有的可用群組,只要執(zhí)行下面這個(gè)命令。
?
#?yum?grouplist?Installed?Groups:?Administration?Tools?DNS?Name?Server?Dialup?Networking?Support?Editors?Engineering?and?Scientific?FTP?Server?Graphics?Java?Development?Legacy?Network?Server?Available?Groups:?Authoring?and?Publishing?Base?Beagle?Cluster?Storage?Clustering?Development?Libraries?Development?Tools?Eclipse?Educational?Software?KDE?(K?Desktop?Environment)?KDE?Software?Development?13. 安裝群組軟件包
想安裝某個(gè)軟件包群組,我們使用選項(xiàng)groupinstall。比如說(shuō),想安裝"MySQL Database",只要執(zhí)行下面這個(gè)命令。
#?yum?groupinstall?'MySQL?Database'?Dependencies?Resolved?==================================================================Package????Arch??????Version???Repository????????Size?==================================================================Updating:?unixODBC???????????????????????????i386??????2.2.11-10.el5??????base??????????????290?k?Installing?for?dependencies:?unixODBC-libs??????????????????????i386??????2.2.11-10.el5??????base??????????????551?k?Transaction?Summary?==================================================================Install???????1?Package(s)?Upgrade???????1?Package(s)?Total?size:?841?k?Is?this?ok?[y/N]:?y?Downloading?Packages:?Running?rpm_check_debug?Running?Transaction?Test?Finished?Transaction?Test?Transaction?Test?Succeeded?Running?Transaction?Installing?????:?unixODBC-libs??1/3?Updating???????:?unixODBC?????????2/3?Cleanup????????:?unixODBC?????????3/3?Dependency?Installed:?unixODBC-libs.i386?0:2.2.11-10.el5?Updated:?unixODBC.i386?0:2.2.11-10.el5?Complete!?14. 更新群組軟件包
想更新任何現(xiàn)有的已安裝群組軟件包,只要運(yùn)行下面這個(gè)命令,如下所示。
#?yum?groupupdate?'DNS?Name?Server'?Dependencies?Resolved?==================================================================Package????Arch???????????Version??Repository???????????Size?==================================================================?Updating:?bind???????????????????????????i386????????????30:9.3.6-20.P1.el5_8.2??????????updates??????????????981?k?bind-chroot????????????????????i386????????????30:9.3.6-20.P1.el5_8.2??????????updates??????????????47?k?Updating?for?dependencies:?bind-libs??????????????????????i386????????????30:9.3.6-20.P1.el5_8.2??????????updates??????????????864?k?bind-utils?????????????????????i386????????????30:9.3.6-20.P1.el5_8.2??????????updates??????????????174?k?Transaction?Summary?Install???????0?Package(s)?Upgrade???????4?Package(s)?Total?size:?2.0?M?Is?this?ok?[y/N]:?y?Downloading?Packages:?Running?rpm_check_debug?Running?Transaction?Test?Finished?Transaction?Test?Transaction?Test?Succeeded?Running?Transaction?Updating???????:?bind-libs????????????1/8?Updating???????:?bind?????????????????2/8?Updating???????:?bind-chroot??????????3/8?Updating???????:?bind-utils???????????4/8?Cleanup????????:?bind?????????????????5/8?Cleanup????????:?bind-chroot??????????6/8?Cleanup????????:?bind-utils???????????7/8?Cleanup????????:?bind-libs????????????8/8?Updated:?bind.i386?30:9.3.6-20.P1.el5_8.2??????????????????bind-chroot.i386?30:9.3.6-20.P1.el5_8.2?Dependency?Updated:?bind-libs.i386?30:9.3.6-20.P1.el5_8.2?????????????bind-utils.i386?30:9.3.6-20.P1.el5_8.2?Complete!?15. 移除群組軟件包
想從系統(tǒng)刪除或移除任何現(xiàn)有的已安裝群組軟件包,只要使用下面這個(gè)命令。
?
#?yum?groupremove?'DNS?Name?Server'?Dependencies?Resolved?==========================================Package????????????????Arch??????????????Version?????????????????????????Repository??????????Size?==========================================Removing:?bind???????????????????i386??????????????30:9.3.6-20.P1.el5_8.2?????????installed???????????2.1?M?bind-chroot?????? ?????i386??????????????30:9.3.6-20.P1.el5_8.2?????????installed???????????0.0?Transaction?Summary?==========================================Remove????????2?Package(s)?Reinstall?????0?Package(s)?Downgrade?????0?Package(s)?Is?this?ok?[y/N]:?y?Downloading?Packages:?Running?rpm_check_debug?Running?Transaction?Test?Finished?Transaction?Test?Transaction?Test?Succeeded?Running?Transaction?Erasing????????:?bind???????????????????????????????????????????????????1/2?warning:?/etc/sysconfig/named?saved?as?/etc/sysconfig/named.rpmsave?Erasing????????:?bind-chroot????????????????????????????????????????????2/2?Removed:?bind.i386?30:9.3.6-20.P1.el5_8.2????????????????????????????????????????bind-chroot.i386?30:9.3.6-20.P1.el5_8.2?Complete!?16. 列出啟用的Yum軟件庫(kù)
列出系統(tǒng)里面所有啟用的Yum軟件庫(kù),使用下面這個(gè)選項(xiàng)。
#?yum?repolist?repo?id?????????????????????repo?name????????????????????????????????????????????status?base???????????????????????CentOS-5?-?Base????????????????????????????? ????????enabled:??2,725?epel???????????????????????Extra?Packages?for?Enterprise?Linux?5?-?i386????? ??? ?enabled:??5,783?extras??????????????????????CentOS-5?-?Extras??????????????????????????????????????enabled:????282?mod-pagespeed??????????????mod-pagespeed????????????????????????????????????????enabled:??????1?rpmforge???????????????????RHEL?5?-?RPMforge.net?-?dag?????????????????????????????enabled:?11,290?updates????????????????????CentOS-5?-?Updates?????????????????????????????????????enabled:????743?repolist:?20,824?17. 列出所有啟用和禁用的Yum軟件庫(kù)
下面這個(gè)命令會(huì)顯示系統(tǒng)上所有啟用和禁用的yum軟件庫(kù)。
#?yum?repolist?all?repo?id?????????????????????repo?name????????????????????????????????????????????status?C5.0-base???????????????????CentOS-5.0?-?Base?????????????????????????????????????disabled?C5.0-centosplus??????????????CentOS-5.0?-?Plus??????????????????????????????????????disabled?C5.0-extras??????????????????CentOS-5.0?-?Extras????????????????????????????????????disabled?base????????????????????????CentOS-5?-?Base??????????????????????????????????????enabled:??2,725?epel????????????????????????Extra?Packages?for?Enterprise?Linux?5?-?i386????????????????enabled:??5,783?extras??????????????????????CentOS-5?-?Extras??????????????????????????????????????enabled:????282?repolist:?20,824?18. 安裝來(lái)自特定軟件庫(kù)的軟件包
想安裝來(lái)自某個(gè)啟用或禁用的軟件庫(kù)的某個(gè)軟件包,必須在yum命令中使用-enablerepo選項(xiàng)。比如,想安裝PhpMyAdmin 3.5.2軟件包,只要執(zhí)行這個(gè)命令。
?
#?yum?--enablerepo=epel?install?phpmyadmin?Dependencies?Resolved?==================================================================?Package????????????????Arch???????????Version????????????Repository???????????Size?==================================================================Installing:?phpMyAdmin?????????????noarch?????????3.5.1-1.el6????????epel?????????????????4.2?M?Transaction?Summary?==================================================================Install???????1?Package(s)?Total?download?size:?4.2?M?Installed?size:?17?M?Is?this?ok?[y/N]:?y?Downloading?Packages:?phpMyAdmin-3.5.1-1.el6.noarch.rpm???????????????????????|?4.2?MB?????00:25?Running?rpm_check_debug?Running?Transaction?Test?Transaction?Test?Succeeded?Running?Transaction?Installing?:?phpMyAdmin-3.5.1-1.el6.noarch?????????????1/1?Verifying??:?phpMyAdmin-3.5.1-1.el6.noarch?????????????1/1?Installed:?phpMyAdmin.noarch?0:3.5.1-1.el6?Complete!?19. 交互式Y(jié)um外殼
Yum實(shí)用工具提供了一個(gè)自定義外殼,你可以在這個(gè)環(huán)境下執(zhí)行多個(gè)命令。
#?yum?shell?Loaded?plugins:?fastestmirror?Setting?up?Yum?Shell?>?update?httpd?Loading?mirror?speeds?from?cached?hostfile?*?base:?mirrors.sin3.sg.voxel.net?*?epel:?ftp.riken.jp?*?extras:?mirrors.sin3.sg.voxel.net?*?updates:?mirrors.sin3.sg.voxel.net?Setting?up?Update?Process?>?20. 清理Yum緩存內(nèi)容
默 認(rèn)情況下,yum將所有軟件庫(kù)中啟用軟件包的數(shù)據(jù),連同每個(gè)子目錄保存在/var/cache/yum/中,想清除啟用軟件庫(kù)中的所有緩存文件,你要定期 運(yùn)行下面這個(gè)命令,清理所有緩存內(nèi)容,并確保沒(méi)有任何東西在使用不必要的存儲(chǔ)空間。我們不想給出下面這個(gè)命令的輸出結(jié)果,因?yàn)槲覀兿氡3志彺鏀?shù)據(jù)的原來(lái)樣 子。
#?yum?clean?all?21. 查看Yum的歷史記錄
想查看Yum命令的所有過(guò)去的事務(wù),只要使用下面這個(gè)命令。
#?yum?history?Loaded?plugins:?fastestmirror?ID?????|?Login?user???????????????|?Date?and?time????|?Action(s)??????|?Altered?------------------------------------------------------------------?10?|?root???????????????|?2012-08-11?15:19?|?Install????????|????3?9?|?root???????????????|?2012-08-11?15:11?|?Install????????|????1?8?|?root???????????????|?2012-08-11?15:10?|?Erase??????????|????1?EE?7?|?root???????????????|?2012-08-10?17:44?|?Install????????|????1?6?|?root???????????????|?2012-08-10?12:19?|?Install????????|????2?5?|?root???????????????|?2012-08-10?12:14?|?Install????????|????3?4?|?root???????????????|?2012-08-10?12:12?|?I,?U???????????|???13?E<?3?|?root???????????????|?2012-08-09?13:01?|?Install????????|????1?>?2?|?root???????????????|?2012-08-08?20:13?|?I,?U???????????|??292?EE?1?|?System????????????|?2012-08-08?17:15?|?Install????????|??560?history?list?我們?cè)噲D探討所有基本面,給出了每個(gè)Yum命令的示例。要是遺漏了與Yum命令有關(guān)的任何內(nèi)容,請(qǐng)?jiān)诖肆粞愿嬷覀?#xff0c;以便我們根據(jù)收到的反饋,不斷更新內(nèi)容。
轉(zhuǎn)載于:https://www.cnblogs.com/davidwang456/p/3346963.html
總結(jié)
以上是生活随笔為你收集整理的用于软件包管理的21个Linux YUM命令 转载的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
如果覺(jué)得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。