安裝及移除套件-YUM

20121120新增指令

YUM 與 RPM 皆可安裝、移除、查詢及升級套件,差別在於 YUM 可透過網路自動下載安裝與升級的套件。

本人常用的三個伺服器
  1. 中華電信:http://mirror01.idc.hinet.net/CentOS/6.3/os/x86_64/
  2. 台灣高品質學術研究網路:http://ftp.twaren.net/Linux/CentOS/6.3/os/x86_64/
  3. 國立中山大學:ftp://ftp.nsysu.edu.tw/Unix-like/CentOS/6.3/os/x86_64/
yum 組態檔設定:以中山大學伺服器為例
# vim /etc/yum.repos.d/nsysu.repo
  [nsysu]
  name=nsysu
  baseurl=ftp://ftp.nsysu.edu.tw/Unix-like/CentOS/6.3/os/i386/
  enabled=1
  gpgcheck=1
  gpgkey=ftp://ftp.nsysu.edu.tw/Unix-like/CentOS/6.3/os/i386//RPM-GPG-KEY-EPEL-6

upgrade/downgrade:升級/降級套件
範例:升級 rpm 套件
# yum upgrade [-y] rpm  // -y 自動安裝
 Loaded plugins: fastestmirror, refresh-packagekit, security
 Loading mirror speeds from cached hostfile
 * base: mirror01.idc.hinet.net
 * epel: mirror01.idc.hinet.net
 * extras: mirror01.idc.hinet.net
 * updates: centosa5.centos.org
  ......
 Dependencies Resolved
   ==================================================================================
 Package   Arch  Version    Repository  Size
 ==================================================================================
 Updating:
 rpm      i686  4.8.0-27.el6         base         898 k
 Updating for dependencies:
 rpm-libs    i686  4.8.0-27.el6         base          313 k
 rpm-python  i686  4.8.0-27.el6        base          53 k
 Transaction Summary
 ==================================================================================
 Upgrade 3 Package(s)
 Total download size: 1.2 M
 Is this ok [y/N]: 詢問是否安裝

info:查詢套件資訊
範例:查詢 vsftpd 套件資訊
# yum info vsftpd
 Loaded plugins: fastestmirror, refresh-packagekit, security
 Loading mirror speeds from cached hostfile
 * base: mirror01.idc.hinet.net
 * epel: mirror01.idc.hinet.net
 * extras: mirror01.idc.hinet.net
 * updates: centosa5.centos.org
 Installed Packages
 Name : vsftpd
 Arch : i686
 Version : 2.2.2
 Release : 11.el6
 Size : 344 k
 Repo : installed
 From 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.

search:搜尋套件
範例:搜尋 vsftpd 套件
# yum search vsftpd
 Loaded plugins: fastestmirror, refresh-packagekit, security
 Loading mirror speeds from cached hostfile
 * base: mirror01.idc.hinet.net
 * epel: mirror01.idc.hinet.net
 * extras: mirror01.idc.hinet.net
 * updates: centosa5.centos.org
 ============================= N/S Matched: vsftpd ============================
 vsftpd.i686 : Very Secure Ftp Daemon
 Name and summary matches only, use "search all" for everything.

provides查詢檔案位於屬於哪個套件
範例:查詢 sshd_config 屬於哪個套件
# yum provides */sshd_config
 Loaded plugins: fastestmirror, refresh-packagekit, security
 Loading mirror speeds from cached hostfile
 * base: mirror01.idc.hinet.net
 * epel: mirror01.idc.hinet.net
 * extras: mirror01.idc.hinet.net
 * updates: centosa5.centos.org
 openssh-server-5.3p1-81.el6.i686 : An open source SSH server daemon
 Repo : base
 Matched from:
 Filename : /etc/ssh/sshd_config

clean:清除 repolist 資料
# yum clean all
 Loaded plugins: fastestmirror, refresh-packagekit, security
 Cleaning repos: base epel extras isu updates
 Cleaning up Everything
 Cleaning up list of fastest mirrors

reinstall:重新安裝
# yum reinstall vsftpd
update/check-update:更新
# yum check-update openssh
erase/remove:移除
# yum remove vsftpd
localinstall:本地套件安裝
# yum localinstall vsftpd
群組安裝相關指令
grouplist
groupinstall
grouperase
groupinfo

沒有留言:

張貼留言