歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
您现在的位置: Linux教程網 >> UnixLinux >  >> Linux基礎 >> Linux教程

CentOS軟件包管理之YUM

YUM(全稱為Yellow dog Updater, Modified)是一個在RHEL系操作系統中的Shell前端軟件包管理器。基於RPM包管理,能夠從指定的服務器自動下載RPM包並且安裝,可以自動處理依賴性關系,並且一次安裝所有依賴的軟件包,無須頻繁地一次次下載、安裝。

-------------------------------------------------------------------------------
YUM軟件包倉庫配置:

  YUM軟件包管理器針對軟件包的操作都要依賴yum的倉庫來實現。而yum倉庫的配置可以編輯yum的配置文件(/etc/yum.conf、/etc/yum.repos.d/*repo)來實現。 一般情況/etc/yum.conf下主要是yum的主配置文件,/etc/yum.repos.d/*.repo主要是各個軟件倉庫的配置文件。

/etc/yum.conf:

/etc/yum.repos.d/media.repo:


--------------------------------------------------------------------------------

YUM安裝、升級和刪除軟件包:
# yum {install | update | remove} PACKAGE_NAME ...

示例 1:
軟件包的安裝:

示例 2:
軟件包的升級:

備注:yum update 後面跟隨軟件包名,是只檢測指定的軟件的更新

備注:yum update 命令檢測系統上所有已安裝軟件的更新


示例 3:
軟件包的刪除:

--------------------------------------------------------------------------------
YUM安裝、升級和刪除軟件包組:

# yum {groupinstall | groupupdate | groupremove} PACKAGEGROUP_NAME ...
// 安裝打印服務包組
// 包組名稱之間如果有空格,需要用引號引起來
[root@localhost ~]# yum groupinstall "Print Server"
// 升級打印服務包組
[root@localhost ~]# yum groupupdate "Print Server"
// 刪除打印服務包組
[root@localhost ~]# yum groupremove "Print Server"


--------------------------------------------------------------------------------
YUM其他的選項:
# yum list [all | installed | updates | available]
# yum grouplist


//列出所有的軟件包
//all可以省略
[root@localhost ~]# yum list all
[root@localhost ~]# yum list
//列出所有已安裝的軟件包
[root@localhost ~]# yum list installed
//列出所有需要更新的軟件包
[root@localhost ~]# yum list updates
//列出所有可用軟件包
[root@localhost ~]# yum list available
//列出所有包組
[root@localhost ~]# yum grouplist

 

# yum repolist [all | enabled | disabled]
//yum repolist默認顯示所有enabled軟件倉庫列表
[root@localhost ~]# yum repolist
//也可以手動指定enabled選項
[root@localhost ~]# yum repolist enabled
//列出所有disabled軟件倉庫列表
[root@localhost ~]# yum repolist disabled
//列出全部軟件倉庫列表
[root@localhost ~]# yum repolist all

 

# yum info [all | installed | updates | available | PACKAGE_NAME]
//顯示lftp軟件包信息
[root@localhost ~]# yum info lftp
Loaded plugins: fastestmirror, security
Loading mirror speeds from cached hostfile
 * base: mirrors.hustunique.com
 * extras: mirrors.hustunique.com
 * updates: mirrors.hustunique.com
Installed Packages
Name        : lftp
Arch        : x86_64
Version    : 4.0.9
Release    : 1.el6_5.1
Size        : 2.5 M
Repo        : installed
From repo  : updates
Summary    : A sophisticated file transfer program
URL        : http://lftp.yar.ru/
License    : GPLv3+
Description : LFTP is a sophisticated ftp/http file transfer program. Like bash, it has job
            : control and uses the readline library for input. It has bookmarks, built-in
            : mirroring, and can transfer several files in parallel. It is designed with
            : reliability in mind.
Available Packages
Name        : lftp
Arch        : i686
Version    : 4.0.9
Release    : 1.el6_5.1
Size        : 735 k
Repo        : updates
Summary    : A sophisticated file transfer program
URL        : http://lftp.yar.ru/
License    : GPLv3+
Description : LFTP is a sophisticated ftp/http file transfer program. Like bash, it has job
            : control and uses the readline library for input. It has bookmarks, built-in
            : mirroring, and can transfer several files in parallel. It is designed with
            : reliability in mind.
//其他選項可以顯示所有installed、updates、available和全部軟件包的信息

 

# yum groupinfo "PACKAGE_GROUP_NAME"

//顯示"Print Server"包組信息
[root@localhost ~]# yum groupinfo "Print Server"
Loaded plugins: fastestmirror, security
Setting up Group Process
Loading mirror speeds from cached hostfile
 * base: ftp.stu.edu.tw
 * extras: mirrors.hustunique.com
 * updates: mirrors.hustunique.com
Group: Print Server
 Description: Allows the system to act as a print server. //描述
 Mandatory Packages:    //必須安裝的包
  cups
  printer-filters
 Default Packages:      //默認安裝的包
  foomatic-db-ppds
  gutenprint
  gutenprint-cups
  hpijs
  paps

 

# yum clean [ packages | metadata | expire-cache | rpmdb | plugins | all ]
# yum makecache

 

//清除軟件包緩沖
[root@localhost ~]# yum clean packages
Loaded plugins: fastestmirror, security
Cleaning repos: base extras updates
0 package files removed
//清除軟件包元數據緩沖
[root@localhost ~]# yum clean metadata
Loaded plugins: fastestmirror, security
Cleaning repos: base extras updates
13 metadata files removed
9 sqlite files removed
0 metadata files removed
//清除過期緩沖
[root@localhost ~]# yum clean expire-cache
Loaded plugins: fastestmirror, security
Cleaning repos: base extras updates
0 metadata files removed
//清除rpmdb數據庫
[root@localhost ~]# yum clean rpmdb
Loaded plugins: fastestmirror, security
Cleaning repos: base extras updates
4 rpmdb files removed
//清除補丁緩沖
[root@localhost ~]# yum clean plugins
Loaded plugins: fastestmirror, security
Cleaning repos: base extras updates
//清除所有緩沖
[root@localhost ~]# yum clean all
Loaded plugins: fastestmirror, security
Cleaning repos: base extras updates
Cleaning up Everything
//重建緩沖
[root@localhost ~]# yum makecache
Loaded plugins: fastestmirror, security
Loading mirror speeds from cached hostfile
 * base: mirrors.163.com
 * extras: mirrors.163.com
 * updates: mirrors.163.com
base                                                                                  | 3.7 kB    00:00   
base/group_gz                                                                        | 220 kB    00:01   
base/filelists_db                                                                    | 5.9 MB    00:44   
base/primary_db                                                                      | 4.4 MB    00:29   
base/other_db                                                                        | 2.8 MB    00:25   
extras                                                                                | 3.4 kB    00:00   
extras/filelists_db                                                                  |  11 kB    00:00   
extras/prestodelta                                                                    |  907 B    00:00   
extras/primary_db                                                                    |  19 kB    00:00   
extras/other_db                                                                      | 5.8 kB    00:00   
updates                                                                              | 3.4 kB    00:00   
updates/filelists_db                                                                  | 1.5 MB    00:17   
updates/prestodelta                                                                  | 156 kB    00:01   
updates/primary_db                                                                    | 2.1 MB    00:19   
updates/other_db                                                                      | 244 kB    00:01   
Metadata Cache Created

 

# yum check-update
# yum update [PACKAGE_NAME] ...
//檢測系統已安裝軟件包是否有更新
[root@localhost ~]# yum check-update
Loaded plugins: fastestmirror, security
Loading mirror speeds from cached hostfile
 * base: mirrors.163.com
 * extras: mirrors.163.com
 * updates: mirrors.163.com
initscripts.x86_64                                    9.03.40-2.el6.CentOS.1                        updates
libtiff.x86_64                                        3.9.4-10.el6_5                                updates
phonon-backend-gstreamer.x86_64                        1:4.6.2-28.el6_5                              updates
postfix.x86_64                                        2:2.6.6-6.el6_5                                updates
psmisc.x86_64                                          22.6-19.el6_5                                  updates
upstart.x86_64                                        0.6.5-13.el6_5.2                              updates
//更新軟件包"postfix"
[root@localhost ~]# yum update postfix
//更新所有可更新的軟件包
[root@localhost ~]# yum update

 

# yum reinstall PACKAGE_NAME ...

//重新安裝軟件包
[root@localhost ~]# yum reinstall lftp
Loaded plugins: fastestmirror, security
Setting up Reinstall Process
Loading mirror speeds from cached hostfile
 * base: mirrors.163.com
 * extras: mirrors.163.com
 * updates: mirrors.163.com
Resolving Dependencies
--> Running transaction check
---> Package lftp.x86_64 0:4.0.9-1.el6_5.1 will be reinstalled
--> Finished Dependency Resolution

 

# yum history
//查看此前yum操作歷史
[root@localhost ~]# yum history
Loaded plugins: fastestmirror, security
ID    | Login user              | Date and time    | Action(s)      | Altered
-------------------------------------------------------------------------------
    11 | root <root>              | 2014-03-01 23:31 | Install        |  30 
    10 | root <root>              | 2014-03-01 20:59 | Install        |    1 
    9 | root <root>              | 2014-03-01 20:50 | Erase          |    1 
    8 | root <root>              | 2014-03-01 20:47 | Install        |    1 
    7 | root <root>              | 2014-03-01 20:42 | Erase          |    1 EE
    6 | root <root>              | 2014-03-01 20:41 | Update        |    1  <
    5 | root <root>              | 2014-02-28 17:06 | Install        |    1 ><
    4 | root <root>              | 2014-02-28 15:56 | Install        |    8 >
    3 | root <root>              | 2014-02-28 13:09 | I, U          |  115 
    2 | root <root>              | 2014-02-17 17:20 | I, U          |  54 
    1 | System <unset>          | 2014-02-17 23:36 | Install        |  621 
history list

推薦閱讀

RedHat Linux 本地yum源的配置 http://www.linuxidc.com/Linux/2013-08/88217.htm

RedHat 6.2 Linux修改yum源免費使用CentOS源 http://www.linuxidc.com/Linux/2013-07/87383.htm

配置EPEL YUM源 http://www.linuxidc.com/Linux/2012-10/71850.htm

Redhat 本地yum源配置 http://www.linuxidc.com/Linux/2012-11/75127.htm

yum的配置文件說明 http://www.linuxidc.com/Linux/2013-04/83298.htm

RedHat 6.1下安裝yum(圖文) http://www.linuxidc.com/Linux/2013-06/86535.htm

YUM 安裝及清理 http://www.linuxidc.com/Linux/2013-07/87163.htm

Copyright © Linux教程網 All Rights Reserved