yum對于使用linux系統(tǒng)服務(wù)器的朋友估計并不陌生了,今天我們給各位介紹linux中yum軟件包管理例子,希望下文可以幫助到各位.
Yum(全稱為 Yellow dog Updater, Modified)是一個在Fedora、RedHat、CentOS中的Shell前端軟件包管理器,基于RPM包管理,能夠從指定的服務(wù)器自動下載RPM包并且安裝,可以自動處理依賴性關(guān)系,并且一次安裝所有依賴的軟件包,下面總結(jié)下yum的常用參數(shù).
yum的命令形式一般是如下:yum [options] [command] [package ...]
其中的[options]是可選的,選項包括-h(幫助),-y(當(dāng)安裝過程提示選擇全部為"yes"),-q(不顯示安裝的過程)等等,[command]為所要進行的操作,[package ...]是操作的對象.
概括了部分常用的命令包括:
自動搜索最快鏡像插件:yum install yum-fastestmirror
安裝yum圖形窗口插件:yum install yumex
查看可能批量安裝的列表:yum grouplist
1、yum安裝軟件包
#yum install curl 或 #yum -y install curl 或 不加y參數(shù)時是交互式的安裝,需要按提示確認(rèn)后才能安裝,而加-y是靜默模式,直接進行安裝.
2、yum移除軟件包
完全移除軟件包及所有依賴包.
#yum remove curl 或 #yum -y remove curl
3、yum更新軟件包
# yum update mysql
4、列出軟件包
使用list函數(shù),可搜索帶名稱的特定軟件包,比如說,想搜索一個名為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
想讓你的搜索更精確,明確軟件包名稱的版本,如果你知道的話,比如說,想搜索軟件包的特定版本openssh-4.3p2,使用該命令.
# yum list openssh-4.3p2
5、Yum搜索軟件包
要是你不記得軟件包的確切名稱,那么可以使用search或search all,搜索與指定軟件包的名稱相匹配的所有可用軟件包,比如說,想搜索與vsftpd這個單詞匹配的所有軟件包.
- [root@api test]# yum search vsftpd
- Loaded plugins: fastestmirror, security
- Determining fastest mirrors
- * base: mirrors.yun-idc.com
- * extras: mirrors.yun-idc.com
- * updates: mirrors.yun-idc.com
- base | 3.7 kB 00:00
- extras | 3.4 kB 00:00
- updates | 3.4 kB 00:00
- updates/primary_db | 2.1 MB 00:02
- =============================== N/S Matched: vsftpd ===================================
- vsftpd.x86_64 : Very Secure Ftp Daemon
- Name and summary matches only, use "search all" for everything.
- [root@api test]# yum search all vsftpd
- Loaded plugins: fastestmirror, security
- Loading mirror speeds from cached hostfile
- * base: mirrors.yun-idc.com --Vevb.com
- * extras: mirrors.yun-idc.com
- * updates: mirrors.yun-idc.com
- ==============================================Matched: vsftpd ==========================
- vsftpd.x86_64 : Very Secure Ftp Daemon
6、Yum獲取軟件包信息
假設(shè)你想在安裝軟件包之前先知道它的信息,想獲得某軟件包的信息,只要執(zhí)行下面這個命令.
- [root@api test]# yum info vsftpd
- Loaded plugins: fastestmirror, security
- Loading mirror speeds from cached hostfile
- * base: mirrors.yun-idc.com
- * extras: mirrors.yun-idc.com
- * updates: mirrors.yun-idc.com
- Installed Packages
- Name : vsftpd
- Arch : x86_64
- Version : 2.2.2
- Release : 11.el6
- Size : 331 k
- Repo : installed
- From repo : anaconda-CentOS-201207061011.x86_64
- Summary : Very Secure Ftp Daemon
- URL : http://vsftpd.beasts.org/
- License : GPLv2 with exceptions
- Description : vsftpd is a Very Secure FTP daemon. It was written completely from
- : scratch.
- Available Packages
- Name : vsftpd
- Arch : x86_64
- Version : 2.2.2
- Release : 11.el6_4.1
- Size : 151 k
- Repo : base
- Summary : Very Secure Ftp Daemon
- URL : http://vsftpd.beasts.org/
- License : GPLv2 with exceptions
- Description : vsftpd is a Very Secure FTP daemon. It was written completely from
- : scratch.
7、列出軟件
列出所有軟件:# yum list | less
只列出已經(jīng)安裝的軟件:# yum list installed | less
8、查看文件歸屬
- [root@api test]# yum provides /etc/httpd/conf/httpd.conf
- Loaded plugins: fastestmirror, security
- Loading mirror speeds from cached hostfile
- * base: mirrors.yun-idc.com
- * extras: mirrors.yun-idc.com
- * updates: mirrors.yun-idc.com
- httpd-2.2.15-29.el6.centos.x86_64 : Apache HTTP Server
- Repo : base
- Matched from:
- Filename : /etc/httpd/conf/httpd.conf
- httpd-2.2.15-15.el6.centos.1.x86_64 : Apache HTTP Server
- Repo : installed
- Matched from:
- Other : Provides-match: /etc/httpd/conf/httpd.conf
9、檢查可用版本更新
# yum check-update
10、系統(tǒng)更新
想確保系統(tǒng)版本最新,打上了所有的安全補丁和二進制軟件包更新,只要運行下面這個命令,它會為你的系統(tǒng)安裝所有最新的補丁和安全更新版.
# yum update
11、列出所有的可用群組軟件包
# yum grouplist
注:如果語言環(huán)境設(shè)置的是中文,列出的是組句會是中文名稱.
12、群組安裝
# yum groupinstall 'MySQL Database' 以上是安裝mysql數(shù)據(jù)庫。
13、更新群組軟件包
# yum groupupdate 'DNS Name Server'
14、移除群組軟件包
# yum groupremove 'DNS Name Server'
15、列出啟用的Yum軟件庫
- [root@api test]# yum repolist
- Loaded plugins: fastestmirror, security
- Loading mirror speeds from cached hostfile
- * base: mirrors.yun-idc.com
- * extras: mirrors.yun-idc.com
- * updates: mirrors.yun-idc.com
- repo id repo name status
- base CentOS-6 - Base 6,367
- extras CentOS-6 - Extras 14
- updates CentOS-6 - Updates 609
- repolist: 6,990
16、列出所有啟用或禁用的yum軟件庫
# yum repolist all
17、使用特定軟件庫安裝軟件
想安裝來自某個啟用或禁用的軟件庫的某個軟件包,必須在yum命令中使用-enablerepo選項,比如,想安裝PhpMyAdmin 3.5.2軟件包,只要執(zhí)行這個命令.
# yum --enablerepo=epel install phpmyadmin
18、交互式Y(jié)um shell
- # 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
- >
19、yum緩存清理
默認(rèn)情況下,yum將所有軟件庫中啟用軟件包的數(shù)據(jù),連同每個子目錄保存在/var/cache/yum/中,想清除啟用軟件庫中的所有緩存文件,你要定期運行下面這個命令,清理所有緩存內(nèi)容,并確保沒有任何東西在使用不必要的存儲空間,我們不想給出下面這個命令的輸出結(jié)果,因為我們想保持緩存數(shù)據(jù)的原來樣子.
# yum clean all
20、查看yum的歷史記錄
- [root@api test]# yum history
- Loaded plugins: fastestmirror, security
- ID | Login user | Date and time | Action(s) | Altered
- -------------------------------------------------------------------------------
- 19 | root <root> | 2011-12-19 11:54 | Install | 1
- 18 | root <root> | 2011-11-28 17:18 | I, U | 2
- 17 | root <root> | 2011-11-11 14:26 | Install | 1
- 16 | root <root> | 2011-09-27 17:11 | Install | 1
- 15 | root <root> | 2011-09-23 10:50 | Update | 2
- 14 | root <root> | 2011-09-23 10:48 | Update | 4
- 13 | root <root> | 2011-08-28 11:45 | Update | 1
- 12 | root <root> | 2011-08-21 13:27 | Install | 8
- 11 | root <root> | 2011-08-21 13:19 | Install | 2
- 10 | root <root> | 2011-07-12 16:33 | I, O, U | 43
- 9 | root <root> | 2011-03-12 15:15 | I, U | 3
- 8 | root <root> | 2011-03-12 15:12 | I, U | 13
- 7 | root <root> | 2011-03-06 08:11 | Install | 6
- 6 | root <root> | 2011-03-05 22:55 | Install | 7
- 5 | root <root> | 2011-03-05 22:16 | Install | 1
- 4 | root <root> | 2011-03-05 22:11 | I, U | 10
- 3 | root <root> | 2011-03-05 22:07 | I, U | 9
- 2 | root <root> | 2011-03-05 22:04 | Install | 1
- 1 | System <unset> | 2011-03-05 18:37 | Install | 648
- history list
新聞熱點
疑難解答
圖片精選