YUM 是一個基於 RPM 的linux 包管理工具。他可以幫助咱們自動升級軟件,包括依賴的資源升級,也能夠安裝,卸載軟件包。 這裏是一些 YUM 的使用實例。但願你們更加的瞭解這款管理工具。linux
安裝一個軟件包,並安裝與其相關的依賴軟件。web
示例:apache
[root@localhost ~]# yum install httpd centos
Loaded plugins: fastestmirror, refresh-packagekit, security
Loading mirror speeds from cached hostfile
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package httpd.x86_64 0:2.2.15-26.el6.centos will be updated
---> Package httpd.x86_64 0:2.2.15-29.el6.centos will be an update
--> Processing Dependency: httpd-tools = 2.2.15-29.el6.centos for package: httpd-2.2.15-29.el6.centos.x86_64
--> Running transaction check
---> Package httpd-tools.x86_64 0:2.2.15-26.el6.centos will be updated
---> Package httpd-tools.x86_64 0:2.2.15-29.el6.centos will be an update
--> Finished Dependency Resolution 工具
若是未指定更新的軟件包, yum 將更新全部軟件。當咱們進行指定, Yum 將會更新咱們指定的軟件spa
[root@localhost ~]# yum update httpd.net
Loaded plugins: fastestmirror, refresh-packagekit, security Loading mirror speeds from cached hostfile Setting up Update Processserver
與update相似,能夠添加一些參數,過期的軟件若是須要處理(如刪掉)能夠添加 --obsolete 參數,或者使用 upgrade。若是須要更自動化一些的操做(避免回答一些問題)還能夠增長一些參數,如: yum -y upgrade對象
[root@localhost ~]# yum upgrade httpdip
Loaded plugins: fastestmirror,refresh-packagekit, security Loading mirror speeds from cached hostfile Setting up Upgrade Process
用於咱們卸載一些無用軟件。也會刪除依賴咱們們卸載軟件的相關軟件。
[root@localhost ~]# yum remove httpd
Loaded plugins: fastestmirror,refresh-packagekit, security Setting up Remove Process Resolving Dependencies --> Running transaction check ---> Package httpd.x86_64 0:2.2.15-29.el6.centos will be erased --> Processing Dependency: httpd-mmn = 20051115 for package: mod_perl-2.0.4-10.el6.x86_64 --> Processing Dependency: httpd >= 2.2.0 for package: gnome-user-share-2.28.2-3.el6.x86_64 --> Running transaction check ---> Package gnome-user-share.x86_64 0:2.28.2-3.el6 will be erased ---> Package mod_perl.x86_64 0:2.0.4-10.el6 will be erased --> Finished Dependency Resolution
[root@localhost ~]# yum list httpd
Loaded plugins: fastestmirror, refresh-packagekit, security Loading mirror speeds from cached hostfile Installed Packages httpd.x86_64 2.2.15-29.el6.centos @base
[root@localhost ~]# yum info httpd
Loaded plugins: fastestmirror, refresh-packagekit, security
Loading mirror speeds from cached hostfile
Installed Packages
Name : httpd
Arch : x86_64
Version : 2.2.15
Release : 29.el6.centos
Size : 2.9 M
Repo : installed
From repo : base
Summary : Apache HTTP Server
URL : http://httpd.apache.org/
License : ASL 2.0
Description : The Apache HTTP Server is a powerful, efficient, and extensible web server.
得到一切能找到的與 rpm 相關的程序,搜索的對象是每一個程序的描述部分。
更詳細的參數說明請查閱相關的 man pages。在 yum-utils 裏面能夠找到叫 yumdownloader 的程序。使用它能夠方便下載,如 srpm 等包
yum search
yum search all
8.清楚無用的 rpm 若是作完一次系統級的升級,將會下載大量 rpm 等等東西,這將佔用較多的硬盤,能夠使用
[root@localhost ~]# yum clean all
Loaded plugins: fastestmirror, refresh-packagekit, security
Cleaning repos: Security-Updates base epel extras spacewalk-client updates
Cleaning up Everything
Cleaning up list of fastest mirrors
You have new mail in /var/spool/mail/root
[root@localhost ~]# yum repolist
Loaded plugins: fastestmirror, refresh-packagekit, security
Loading mirror speeds from cached hostfile
repo id repo name status
Security-Updates security-updates 1,154
base base 7,965
epel epel 14,597
extras extras 14
spacewalk-client spacewalk-client 21
updates updates 1,871
repolist: 25,622
yum grouplist:個相關的軟件包會被放在一個特定的組內。你們安裝某個軟件組,這樣就會安裝該組全部的軟件包。
yum groupinstall 'groupname': 安裝某個指定軟件組
yum groupremove 'groupname': 刪除指定軟件組
yum groupinfo 'groupname': 列出指定軟件組信息
yum groupupdate 'groupname':升級指定軟件組相關軟件