程序包的管理:rpm及yum

rpm包:
html

RPM 全名是『 RedHat Package Manager 』簡稱則爲 RPM。RPM 是以一種數據庫記錄的方式來將你所須要的套件安裝到你的 Linux 主機的一套管理程序。他最大的特色就是將您要安裝的套件先編譯過( 若是須要的話 )而且打包好了,透過包裝好的套件裏頭預設的數據庫記錄,記錄這個套件要安裝的時候必需要的相依屬性模塊( 就是你的 Linux 主機須要先存在的幾個必須的套件 ),當安裝在你的 Linux 主機時, RPM 會先依照套件裏頭的紀錄數據查詢 Linux 主機的相依屬性套件是否知足, 若知足則予以安裝,若不知足則不予安裝。那麼安裝的時候就將該套件的信息整個寫入 RPM 的數據庫中,以便將來的查詢、驗證與反安裝!這樣一來的優勢是:node

1. 因爲已經編譯完成而且打包完畢,因此安裝上很方便( 不須要再從新編譯 );python

2. 因爲套件的信息都已經記錄在 Linux 主機的數據庫上,很方便查詢、升級與反安裝;git

缺點是:shell

1. 安裝的環境必須與打包時的環境需求一致或至關;數據庫

2. 須要知足套件的相依屬性需求;vim

3. 反安裝時須要特別當心,最底層的套件不可先移除,不然可能形成整個系統的問題!centos

程序包的組成部分:緩存

二進制程序:/bin, /sbin,/ /usr/bin, /usr/sbin,安全

庫文件:/lib64, /usr/lib64

配置文件:/etc

幫助文件:manual, info, 

分包機制:

     testapp-VERSION.tar.gz

     核心包:testapp-VERSION

     支包:testapp-devel-VERSION

     VERSION:major.minor.release

          base-4.2.4.tar.gz

rpm包的命名機制:

name-VERSION-RELEASE.ARCH.rpm

zsh-5.0.2-7.el7.x86_64.rpm
zsh:包的名字
5.0.2:版本號
7.e17:這個軟件包的發行商版本,本包爲rhel7或者centos7上使用
x86_64:支持系統硬件平臺
rpm:包的類型.rpm是編譯好的二進制包,可用rpm命令直接安裝;.src.rpm表示是源

bash-devel-4.2.4-1.el7.x86_64.rpm

devel:爲開發版本
除此以外,還有其餘的幾個參數選項:
 noarch:說明這樣的軟件包能夠在任何平臺上安裝,不須要特定的硬件平臺。在任何硬件平臺上均可以運行。
 manual 手冊文檔。

 RELEASE: rpm release

包和包之間:有可能存在依賴關係:

     X --> Y x包是Y包安裝的先決條件

[root@bogon Packages]# rpm -ivh samba-python-4.1.12-21.el7_1.x86_64.rpm 
warning: samba-python-4.1.12-21.el7_1.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID fd431d51: NOKEY
error: Failed dependencies:
	samba = 4.1.12-21.el7_1 is needed by samba-python-0:4.1.12-21.el7_1.x86_64
[root@bogon Packages]# 
[root@bogon Packages]# rpm -ivh samba-4.1.12-21.el7_1.x86_64.rpm 
warning: samba-4.1.12-21.el7_1.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID fd431d51: NOKEY
Preparing...                          ################################# [100%]
Updating / installing...
   1:samba-0:4.1.12-21.el7_1          ################################# [100%]
[root@bogon Packages]# rpm -ivh samba-python-4.1.12-21.el7_1.x86_64.rpm 
warning: samba-python-4.1.12-21.el7_1.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID fd431d51: NOKEY
Preparing...                          ################################# [100%]
Updating / installing...
   1:samba-python-0:4.1.12-21.el7_1   ################################# [100%]
[root@bogon Packages]#

rpm數據庫:/var/lib/rpm/

如何獲取rpm包:

    一、發行版提供的程序包;通常在光盤鏡像的Packages文件夾下

[root@bogon Packages]# pwd
/home/aa/Packages  #home/aa 爲我cdrom 的掛載目錄

    二、Fedora-EPEL ==》自由版本,開源的,網友根據本人自身特色打的我的包

    三、項目的官方站點

    四、搜索引擎

        http://rpmfind.net

        http://rpm.pbone.net

        http://pkgs.org

CentOS識別光盤用的設備文件:/dev/cdrom

基於rpm命令實現程序包管理:

安裝:

    rpm {-i|--install} [install-options] PACKAGE_FILE ...

        -i:

            -v:顯示詳細過程,-vv, -vvv

            -h:每一個rpm包都提供一個或多個capabilities


        --nodeps:忽略依賴關係安裝

        --replacepkgs:重裝程序包

wKiom1X01xzCpRTGAAJ1We-4reQ108.jpg

[root@bogon Packages]# rpm -e samba-client
[root@bogon Packages]# rpm -ivh samba-client-4.1.12-21.el7_1.x86_64.rpm --nodes
rpm: --nodes: unknown option
[root@bogon Packages]# rpm -ivh samba-client-4.1.12-21.el7_1.x86_64.rpm --nodeps
warning: samba-client-4.1.12-21.el7_1.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID fd431d51: NOKEY
Preparing...                          ################################# [100%]
Updating / installing...
   1:samba-client-0:4.1.12-21.el7_1   ################################# [100%]
[root@bogon Packages]# grep -qa samba-client
^C
[root@bogon Packages]# rpm -qa|grep samba-client
samba-client-4.1.12-21.el7_1.x86_64
[root@bogon Packages]# rpm -ivh samba-client-4.1.12-21.el7_1.x86_64.rpm --replacepkgs
warning: samba-client-4.1.12-21.el7_1.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID fd431d51: NOKEY
Preparing...                          ################################# [100%]
Updating / installing...
   1:samba-client-0:4.1.12-21.el7_1   ################################# [100%]
[root@bogon Packages]#

升級:

    rpm {-U|--upgrade} [install-options] PACKAGE_FILE ...

    rpm {-F|--freshen} [install-options] PACKAGE_FILE ...


        -Uvh: 若是有舊版程序包,則升級之;若是沒有,則安裝之;

        -Fvh: 若是有舊版程序包,則升級之;若是沒有,則不安裝;


        --nodeps

        --oldpackage:降級;

        --force:

wKiom1X02FDhHSlrAAJu_v6uNmU862.jpg

卸載:

    rpm {-e|--erase} [--nodeps] [--noscripts] [--notriggers] [--test] PACKAGE_NAME ...

wKioL1X02wCToXQJAAEuRNgWlgU006.jpg

查詢:

    rpm {-q|--query} [select-options] [query-options]


    查詢選項:

        -qa: 查詢本機已經安裝的全部程序包;

[root@localhost Packages]# rpm -qa vsftpd
vsftpd-3.0.2-9.el7.x86_64
[root@localhost Packages]#

        -qf /PATH/TO/SOMEFILE: 查詢此處的文件由哪一個程序包安裝生成;


        -qc: 查詢指定程序包安裝生成的配置文件

[root@localhost Packages]# rpm -qc vsftpd
/etc/logrotate.d/vsftpd
/etc/pam.d/vsftpd
/etc/vsftpd/ftpusers
/etc/vsftpd/user_list
/etc/vsftpd/vsftpd.conf

        -qd: 查詢指定的程序包安裝生成的文檔

[root@localhost Packages]# rpm -qd vsftpd
/usr/share/doc/vsftpd-3.0.2/AUDIT
/usr/share/doc/vsftpd-3.0.2/BENCHMARKS
/usr/share/doc/vsftpd-3.0.2/BUGS
/usr/share/doc/vsftpd-3.0.2/COPYING
/usr/share/doc/vsftpd-3.0.2/Changelog
/usr/share/doc/vsftpd-3.0.2/EXAMPLE/INTERNET_SITE/README
/usr/share/doc/vsftpd-3.0.2/EXAMPLE/INTERNET_SITE/README.configuration
/usr/share/doc/vsftpd-3.0.2/EXAMPLE/INTERNET_SITE/vsftpd.conf
/usr/share/doc/vsftpd-3.0.2/EXAMPLE/INTERNET_SITE/vsftpd.xinetd
/usr/share/doc/vsftpd-3.0.2/EXAMPLE/INTERNET_SITE_NOINETD/README
/usr/share/doc/vsftpd-3.0.2/EXAMPLE/INTERNET_SITE_NOINETD/README.configuration
/usr/share/doc/vsftpd-3.0.2/EXAMPLE/INTERNET_SITE_NOINETD/vsftpd.conf
/usr/share/doc/vsftpd-3.0.2/EXAMPLE/PER_IP_CONFIG/README
/usr/share/doc/vsftpd-3.0.2/EXAMPLE/PER_IP_CONFIG/README.configuration
/usr/share/doc/vsftpd-3.0.2/EXAMPLE/PER_IP_CONFIG/hosts.allow
/usr/share/doc/vsftpd-3.0.2/EXAMPLE/README
/usr/share/doc/vsftpd-3.0.2/EXAMPLE/VIRTUAL_HOSTS/README
/usr/share/doc/vsftpd-3.0.2/EXAMPLE/VIRTUAL_USERS/README
/usr/share/doc/vsftpd-3.0.2/EXAMPLE/VIRTUAL_USERS/README.configuration
/usr/share/doc/vsftpd-3.0.2/EXAMPLE/VIRTUAL_USERS/logins.txt
/usr/share/doc/vsftpd-3.0.2/EXAMPLE/VIRTUAL_USERS/vsftpd.conf
/usr/share/doc/vsftpd-3.0.2/EXAMPLE/VIRTUAL_USERS/vsftpd.pam
/usr/share/doc/vsftpd-3.0.2/EXAMPLE/VIRTUAL_USERS_2/README
/usr/share/doc/vsftpd-3.0.2/FAQ
/usr/share/doc/vsftpd-3.0.2/INSTALL
/usr/share/doc/vsftpd-3.0.2/LICENSE
/usr/share/doc/vsftpd-3.0.2/README
/usr/share/doc/vsftpd-3.0.2/README.security
/usr/share/doc/vsftpd-3.0.2/REWARD
/usr/share/doc/vsftpd-3.0.2/SECURITY/DESIGN
/usr/share/doc/vsftpd-3.0.2/SECURITY/IMPLEMENTATION
/usr/share/doc/vsftpd-3.0.2/SECURITY/OVERVIEW
/usr/share/doc/vsftpd-3.0.2/SECURITY/TRUST
/usr/share/doc/vsftpd-3.0.2/SIZE
/usr/share/doc/vsftpd-3.0.2/SPEED
/usr/share/doc/vsftpd-3.0.2/TODO
/usr/share/doc/vsftpd-3.0.2/TUNING
/usr/share/doc/vsftpd-3.0.2/vsftpd.xinetd
/usr/share/man/man5/vsftpd.conf.5.gz
/usr/share/man/man8/vsftpd.8.gz

        -qi: 查詢指定的程序包的相關信息;

[root@localhost Packages]# rpm -qi vsftpd
Name        : vsftpd
Version     : 3.0.2
Release     : 9.el7
Architecture: x86_64
Install Date: Sun 13 Sep 2015 01:41:34 PM CST
Group       : System Environment/Daemons
Size        : 351462
License     : GPLv2 with exceptions
Signature   : RSA/SHA256, Thu 03 Apr 2014 05:54:58 AM CST, Key ID 199e2f91fd431d51
Source RPM  : vsftpd-3.0.2-9.el7.src.rpm
Build Date  : Fri 07 Mar 2014 05:58:22 PM CST
Build Host  : x86-025.build.eng.bos.redhat.com
Relocations : (not relocatable)
Packager    : Red Hat, Inc. <http://bugzilla.redhat.com/bugzilla>
Vendor      : Red Hat, Inc.
URL         : https://security.appspot.com/vsftpd.html
Summary     : Very Secure Ftp Daemon
Description :
vsftpd is a Very Secure FTP daemon. It was written completely from
scratch.

        -ql: 查詢程序包安裝生成的全部文件的列表;

[root@localhost Packages]# rpm -ql vsftpd
/etc/logrotate.d/vsftpd
/etc/pam.d/vsftpd
/etc/vsftpd
/etc/vsftpd/ftpusers
/etc/vsftpd/user_list
/etc/vsftpd/vsftpd.conf
/etc/vsftpd/vsftpd_conf_migrate.sh
/usr/lib/systemd/system-generators/vsftpd-generator
/usr/lib/systemd/system/vsftpd.service
/usr/lib/systemd/system/vsftpd.target
/usr/lib/systemd/system/vsftpd@.service
/usr/sbin/vsftpd
/usr/share/doc/vsftpd-3.0.2
/usr/share/doc/vsftpd-3.0.2/AUDIT
/usr/share/doc/vsftpd-3.0.2/BENCHMARKS
/usr/share/doc/vsftpd-3.0.2/BUGS
/usr/share/doc/vsftpd-3.0.2/COPYING
/usr/share/doc/vsftpd-3.0.2/Changelog
/usr/share/doc/vsftpd-3.0.2/EXAMPLE
/usr/share/doc/vsftpd-3.0.2/EXAMPLE/INTERNET_SITE
/usr/share/doc/vsftpd-3.0.2/EXAMPLE/INTERNET_SITE/README
/usr/share/doc/vsftpd-3.0.2/EXAMPLE/INTERNET_SITE/README.configuration
/usr/share/doc/vsftpd-3.0.2/EXAMPLE/INTERNET_SITE/vsftpd.conf
/usr/share/doc/vsftpd-3.0.2/EXAMPLE/INTERNET_SITE/vsftpd.xinetd
/usr/share/doc/vsftpd-3.0.2/EXAMPLE/INTERNET_SITE_NOINETD
/usr/share/doc/vsftpd-3.0.2/EXAMPLE/INTERNET_SITE_NOINETD/README
/usr/share/doc/vsftpd-3.0.2/EXAMPLE/INTERNET_SITE_NOINETD/README.configuration
/usr/share/doc/vsftpd-3.0.2/EXAMPLE/INTERNET_SITE_NOINETD/vsftpd.conf
/usr/share/doc/vsftpd-3.0.2/EXAMPLE/PER_IP_CONFIG
/usr/share/doc/vsftpd-3.0.2/EXAMPLE/PER_IP_CONFIG/README
/usr/share/doc/vsftpd-3.0.2/EXAMPLE/PER_IP_CONFIG/README.configuration
/usr/share/doc/vsftpd-3.0.2/EXAMPLE/PER_IP_CONFIG/hosts.allow
/usr/share/doc/vsftpd-3.0.2/EXAMPLE/README
/usr/share/doc/vsftpd-3.0.2/EXAMPLE/VIRTUAL_HOSTS
/usr/share/doc/vsftpd-3.0.2/EXAMPLE/VIRTUAL_HOSTS/README
/usr/share/doc/vsftpd-3.0.2/EXAMPLE/VIRTUAL_USERS
/usr/share/doc/vsftpd-3.0.2/EXAMPLE/VIRTUAL_USERS/README
/usr/share/doc/vsftpd-3.0.2/EXAMPLE/VIRTUAL_USERS/README.configuration
/usr/share/doc/vsftpd-3.0.2/EXAMPLE/VIRTUAL_USERS/logins.txt
/usr/share/doc/vsftpd-3.0.2/EXAMPLE/VIRTUAL_USERS/vsftpd.conf
/usr/share/doc/vsftpd-3.0.2/EXAMPLE/VIRTUAL_USERS/vsftpd.pam
/usr/share/doc/vsftpd-3.0.2/EXAMPLE/VIRTUAL_USERS_2
/usr/share/doc/vsftpd-3.0.2/EXAMPLE/VIRTUAL_USERS_2/README
/usr/share/doc/vsftpd-3.0.2/FAQ
/usr/share/doc/vsftpd-3.0.2/INSTALL
/usr/share/doc/vsftpd-3.0.2/LICENSE
/usr/share/doc/vsftpd-3.0.2/README
/usr/share/doc/vsftpd-3.0.2/README.security
/usr/share/doc/vsftpd-3.0.2/REWARD
/usr/share/doc/vsftpd-3.0.2/SECURITY
/usr/share/doc/vsftpd-3.0.2/SECURITY/DESIGN
/usr/share/doc/vsftpd-3.0.2/SECURITY/IMPLEMENTATION
/usr/share/doc/vsftpd-3.0.2/SECURITY/OVERVIEW
/usr/share/doc/vsftpd-3.0.2/SECURITY/TRUST
/usr/share/doc/vsftpd-3.0.2/SIZE
/usr/share/doc/vsftpd-3.0.2/SPEED
/usr/share/doc/vsftpd-3.0.2/TODO
/usr/share/doc/vsftpd-3.0.2/TUNING
/usr/share/doc/vsftpd-3.0.2/vsftpd.xinetd
/usr/share/man/man5/vsftpd.conf.5.gz
/usr/share/man/man8/vsftpd.8.gz
/var/ftp
/var/ftp/pub

        -q --scripts:查詢程序包相關的腳本:

            preinstall: 安裝前腳本

            postinstall:安裝後腳本

            preuninstall: 卸載前腳本

            postuninstall: 卸載後腳本


        -p: 查詢針對是未安裝的程序包文件;


校驗:

    rpm {-V|--verify} [select-options] [verify-options]

       S file Size differs

       M Mode differs (includes permissions and file type)

       5 digest (formerly MD5 sum) differs

       D Device major/minor number mismatch

       L readLink(2) path mismatch

       U User ownership differs

       G Group ownership differs

       T mTime differs

       P caPabilities differ

[root@localhost Packages]# rpm --verify vsftpd
[root@localhost Packages]# rpm -ql vsftpd
/etc/logrotate.d/vsftpd
/etc/pam.d/vsftpd
/etc/vsftpd
/etc/vsftpd/ftpusers
/etc/vsftpd/user_list
/etc/vsftpd/vsftpd.conf
/etc/vsftpd/vsftpd_conf_migrate.sh
/usr/lib/systemd/system-generators/vsftpd-generator
/usr/lib/systemd/system/vsftpd.service
/usr/lib/systemd/system/vsftpd.target
/usr/lib/systemd/system/vsftpd@.service
/usr/sbin/vsftpd
/usr/share/doc/vsftpd-3.0.2
/usr/share/doc/vsftpd-3.0.2/AUDIT
/usr/share/doc/vsftpd-3.0.2/BENCHMARKS
/usr/share/doc/vsftpd-3.0.2/BUGS
/usr/share/doc/vsftpd-3.0.2/COPYING
/usr/share/doc/vsftpd-3.0.2/Changelog
/usr/share/doc/vsftpd-3.0.2/EXAMPLE
/usr/share/doc/vsftpd-3.0.2/EXAMPLE/INTERNET_SITE
/usr/share/doc/vsftpd-3.0.2/EXAMPLE/INTERNET_SITE/README
/usr/share/doc/vsftpd-3.0.2/EXAMPLE/INTERNET_SITE/README.configuration
/usr/share/doc/vsftpd-3.0.2/EXAMPLE/INTERNET_SITE/vsftpd.conf
/usr/share/doc/vsftpd-3.0.2/EXAMPLE/INTERNET_SITE/vsftpd.xinetd
/usr/share/doc/vsftpd-3.0.2/EXAMPLE/INTERNET_SITE_NOINETD
/usr/share/doc/vsftpd-3.0.2/EXAMPLE/INTERNET_SITE_NOINETD/README
/usr/share/doc/vsftpd-3.0.2/EXAMPLE/INTERNET_SITE_NOINETD/README.configuration
/usr/share/doc/vsftpd-3.0.2/EXAMPLE/INTERNET_SITE_NOINETD/vsftpd.conf
/usr/share/doc/vsftpd-3.0.2/EXAMPLE/PER_IP_CONFIG
/usr/share/doc/vsftpd-3.0.2/EXAMPLE/PER_IP_CONFIG/README
/usr/share/doc/vsftpd-3.0.2/EXAMPLE/PER_IP_CONFIG/README.configuration
/usr/share/doc/vsftpd-3.0.2/EXAMPLE/PER_IP_CONFIG/hosts.allow
/usr/share/doc/vsftpd-3.0.2/EXAMPLE/README
/usr/share/doc/vsftpd-3.0.2/EXAMPLE/VIRTUAL_HOSTS
/usr/share/doc/vsftpd-3.0.2/EXAMPLE/VIRTUAL_HOSTS/README
/usr/share/doc/vsftpd-3.0.2/EXAMPLE/VIRTUAL_USERS
/usr/share/doc/vsftpd-3.0.2/EXAMPLE/VIRTUAL_USERS/README
/usr/share/doc/vsftpd-3.0.2/EXAMPLE/VIRTUAL_USERS/README.configuration
/usr/share/doc/vsftpd-3.0.2/EXAMPLE/VIRTUAL_USERS/logins.txt
/usr/share/doc/vsftpd-3.0.2/EXAMPLE/VIRTUAL_USERS/vsftpd.conf
/usr/share/doc/vsftpd-3.0.2/EXAMPLE/VIRTUAL_USERS/vsftpd.pam
/usr/share/doc/vsftpd-3.0.2/EXAMPLE/VIRTUAL_USERS_2
/usr/share/doc/vsftpd-3.0.2/EXAMPLE/VIRTUAL_USERS_2/README
/usr/share/doc/vsftpd-3.0.2/FAQ
/usr/share/doc/vsftpd-3.0.2/INSTALL
/usr/share/doc/vsftpd-3.0.2/LICENSE
/usr/share/doc/vsftpd-3.0.2/README
/usr/share/doc/vsftpd-3.0.2/README.security
/usr/share/doc/vsftpd-3.0.2/REWARD
/usr/share/doc/vsftpd-3.0.2/SECURITY
/usr/share/doc/vsftpd-3.0.2/SECURITY/DESIGN
/usr/share/doc/vsftpd-3.0.2/SECURITY/IMPLEMENTATION
/usr/share/doc/vsftpd-3.0.2/SECURITY/OVERVIEW
/usr/share/doc/vsftpd-3.0.2/SECURITY/TRUST
/usr/share/doc/vsftpd-3.0.2/SIZE
/usr/share/doc/vsftpd-3.0.2/SPEED
/usr/share/doc/vsftpd-3.0.2/TODO
/usr/share/doc/vsftpd-3.0.2/TUNING
/usr/share/doc/vsftpd-3.0.2/vsftpd.xinetd
/usr/share/man/man5/vsftpd.conf.5.gz
/usr/share/man/man8/vsftpd.8.gz
/var/ftp
/var/ftp/pub
[root@localhost Packages]# vi /etc/vsftpd/user_list
[root@localhost Packages]# rpm --verify vsftpd
S.5....T.  c /etc/vsftpd/user_list

包校驗:

來源合法性驗正:非對稱加密

完整性驗正:單向加密


導入密鑰:rpm --import /PATH/TO/KEY_FILE

校驗:rpm -K /PATH/TO/RPM_FILE


YUM: Yellowdog Updater Modified


yum repositories:

文件服務器:

    ftp://hostname/PATH/TO/REPO

    http://hostname/PATH/TO/REPO

    file:///PATH/TO/REPO


yum程序的配置文件:

/etc/yum.conf

    定義全局配置:對全部倉庫都適用的配置

[root@iZ28qzns9m4Z ~]# vim /etc/yum.conf 

[main]
cachedir=/var/cache/yum/$basearch/$releasever #yum緩存的目錄,yum在此存儲下載的rpm包和數據庫
keepcache=0  #緩存是否保存,1保存,0不保存。
debuglevel=2 #除錯級別,0──10,默認是2
logfile=/var/log/yum.log #yum的日誌文件,默認是/var/log/yum.log
exactarch=1  #在更新的時候,是否容許更新不一樣版本的RPM包,好比是否在i386上更新i686的RPM包。
obsoletes=1 #這是一個update的參數,容許更新陳舊的RPM包。
gpgcheck=1   #是否檢查GPG(GNU Private Guard),一種密鑰方式簽名
plugins=1   #是否容許使用插件,默認是0不容許
installonly_limit=5  #容許保留多少個內核包。
bugtracker_url=   #yum的鏈接地址 
distroverpkg=centos-release  #密鑰

/etc/yum.repos.d/*.repo

    一個文件一般用於一個或一組功能相近或相關的倉庫

[base-source] #方括號裏面的是軟件源的名稱,將被yum取得並識別
name=CentOS-$releasever - Base Sources  #這裏也定義了軟件 倉庫的名稱,一般是爲了方便閱讀配置文件,通常沒什麼做用,$releasever變量定義了發行版本,一般是8,9,10等數字,如下同
baseurl= #指定一個baseurl(源的鏡像服務器地址) 
gpgcheck=1 #這個選項表示這個repo中下載的rpm將進行gpg的校驗,已肯定rpm包的來源是有效和安全的
enabled=0 #這個選項表示這個repo中定義的源是啓用的,0爲禁用
gpgkey= #定義用於校驗的gpg密鑰,就是數位簽章的公鑰檔所在位置!使用預設值便可

yum命令及參數:

yum [options] [command] [package ...]


    命令:

        安裝:install

[root@localhost Packages]# rpm -e vsftpd
warning: /etc/vsftpd/user_list saved as /etc/vsftpd/user_list.rpmsave
[root@localhost Packages]# yum install -y vsftp
Loaded plugins: langpacks, product-id, subscription-manager
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
No package vsftp available.
Error: Nothing to do
[root@localhost Packages]# yum install -y vsftp*
Loaded plugins: langpacks, product-id, subscription-manager
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
Examining vsftpd-3.0.2-9.el7.x86_64.rpm: vsftpd-3.0.2-9.el7.x86_64
Marking vsftpd-3.0.2-9.el7.x86_64.rpm to be installed
Resolving Dependencies
There are unfinished transactions remaining. You might consider running yum-complete-transaction, or "yum-complete-transaction --cleanup-only" and "yum history redo last", first to finish them. If those don't work you'll have to try removing/installing packages by hand (maybe package-cleanup can help).
--> Running transaction check
---> Package vsftpd.x86_64 0:3.0.2-9.el7 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

===========================================================================
 Package   Arch      Version           Repository                     Size
===========================================================================
Installing:
 vsftpd    x86_64    3.0.2-9.el7       /vsftpd-3.0.2-9.el7.x86_64    343 k

Transaction Summary
===========================================================================
Install  1 Package

Total size: 343 k
Installed size: 343 k
Downloading packages:
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Installing : vsftpd-3.0.2-9.el7.x86_64                               1/1 
  Verifying  : vsftpd-3.0.2-9.el7.x86_64                               1/1 

Installed:
  vsftpd.x86_64 0:3.0.2-9.el7                                              

Complete!
[root@localhost Packages]#

        卸載:remove

[root@localhost ~]# yum remove vsftpd -y
Loaded plugins: langpacks, product-id, subscription-manager
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
Resolving Dependencies
There are unfinished transactions remaining. You might consider running yum-complete-transaction, or "yum-complete-transaction --cleanup-only" and "yum history redo last", first to finish them. If those don't work you'll have to try removing/installing packages by hand (maybe package-cleanup can help).
--> Running transaction check
---> Package vsftpd.x86_64 0:3.0.2-9.el7 will be erased
--> Finished Dependency Resolution
yum                                                 | 4.1 kB     00:00     
yum/group_gz                                        | 134 kB     00:00     
yum/primary_db                                      | 3.4 MB     00:00     

Dependencies Resolved

===========================================================================
 Package   Arch      Version          Repository                      Size
===========================================================================
Removing:
 vsftpd    x86_64    3.0.2-9.el7      @/vsftpd-3.0.2-9.el7.x86_64    343 k

Transaction Summary
===========================================================================
Remove  1 Package

Installed size: 343 k
Downloading packages:
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Erasing    : vsftpd-3.0.2-9.el7.x86_64                               1/1 
  Verifying  : vsftpd-3.0.2-9.el7.x86_64                               1/1 

Removed:
  vsftpd.x86_64 0:3.0.2-9.el7                                              

Complete!
[root@localhost ~]#

        升級:update

[root@localhost Packages]# yum update vsftpd* -y
Loaded plugins: langpacks, product-id, subscription-manager
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
Examining vsftpd-3.0.2-9.el7.x86_64.rpm: vsftpd-3.0.2-9.el7.x86_64
vsftpd-3.0.2-9.el7.x86_64.rpm: does not update installed package.
No packages marked for update
[root@localhost Packages]#

    

            search KEYWORD

            list all|installed|availiable

            provides /PATH/TO/SOMEFILE: 查詢指定文件由哪一個包安裝生成

        從新安裝:reinstall

        降級:downgrade

        清理緩存:clean [ packages | metadata | expire-cache | rpmdb | plugins | all ]

        生動生成緩存:makecache


        包組:

            grouplist

[root@iZ28qzns9m4Z ~]# yum grouplist
Loaded plugins: langpacks
There is no installed groups file.
Maybe run: yum groups mark convert (see man yum)
Available environment groups:
   Minimal Install
   Compute Node
   Infrastructure Server
   File and Print Server
   MATE Desktop
   Basic Web Server
   Virtualization Host
   Server with GUI
   GNOME Desktop
   KDE Plasma Workspaces
   Development and Creative Workstation
Available Groups:
   CIFS file server
   Compatibility Libraries
   Console Internet Tools
   Desktop
   Desktop Platform
   Desktop Platform Development
   Development Tools
   Eclipse
   Educational Software
   Electronic Lab
   FCoE Storage Client
   Fedora Packager
   General Purpose Desktop
   Graphical Administration Tools
   Haskell
   Legacy UNIX Compatibility
   Messaging Client Support
   Messaging Server Support
   Milkymist
   MySQL Database client
   MySQL Database server
   NFS file server
   Network Storage Server
   SNMP Support
   Scientific Support
   Security Tools
   Server Platform
   Server Platform Development
   Smart Card Support
   Storage Availability Tools
   System Administration Tools
   System Management
   TeX support
   TurboGears application framework
   Virtualization
   Web-Based Enterprise Management
   Xfce
   iSCSI Storage Client
Done
[root@iZ28qzns9m4Z ~]#

            groupinfo "GRP_NAME"

            groupinstall "GRP_NAME"

            groupremove "GRP_NAME"


        倉庫:

            repolist [all|enabled|disabled]

            repoinfo [all|enabled|disabled]

yum install createrepo

[root@localhost yum.repos.d]# yum install createrepo
Loaded plugins: langpacks, product-id, subscription-manager
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
Package createrepo-0.9.9-23.el7.noarch already installed and latest version
Nothing to do
[root@localhost yum.repos.d]#



createrepo /PATH/TO/RPMFILES/

check-update       檢查可提供的包升級
[root@iZ28qzns9m4Z yum.repos.d]# yum check-update
Loaded plugins: langpacks

NetworkManager.x86_64      1:1.0.0-16.git20150121.b4ea599c.el7_1    updates
NetworkManager-glib.x86_64 1:1.0.0-16.git20150121.b4ea599c.el7_1    updates
NetworkManager-tui.x86_64  1:1.0.0-16.git20150121.b4ea599c.el7_1    updates
abrt.x86_64                2.1.11-22.el7.centos.0.1                 updates
abrt-addon-ccpp.x86_64     2.1.11-22.el7.centos.0.1                 updates
abrt-addon-kerneloops.x86_64
                           2.1.11-22.el7.centos.0.1                 updates
clean              刪除緩存數據
deplist            列出包依賴相關
[root@iZ28qzns9m4Z yum.repos.d]# yum deplist samba
Loaded plugins: langpacks
package: samba.x86_64 4.1.12-23.el7_1
  dependency: /bin/sh
   provider: bash.x86_64 4.2.46-12.el7
  dependency: /usr/sbin/groupadd
   provider: shadow-utils.x86_64 2:4.1.5.1-18.el7
  dependency: libCHARSET3.so()(64bit)
   provider: samba-libs.x86_64 4.1.12-23.el7_1
erase              移除一個或多個包從你的系統
[root@localhost yum.repos.d]# yum erase samba-client
Loaded plugins: fastestmirror, langpacks
Resolving Dependencies
--> Running transaction check
---> Package samba-client.x86_64 0:4.1.12-21.el7_1 will be erased
--> Finished Dependency Resolution

Dependencies Resolved

===========================================================================
 Package           Arch        Version                Repository      Size
===========================================================================
Removing:
 samba-client      x86_64      4.1.12-21.el7_1        @anaconda      1.3 M

Transaction Summary
===========================================================================
Remove  1 Package

Installed size: 1.3 M
Is this ok [y/N]: y
Downloading packages:
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Warning: RPMDB altered outside of yum.
  Erasing    : samba-client-4.1.12-21.el7_1.x86_64                     1/1 
  Verifying  : samba-client-4.1.12-21.el7_1.x86_64                     1/1 

Removed:
  samba-client.x86_64 0:4.1.12-21.el7_1                                    

Complete!
groupinfo          顯示關於包組的細節
groupinstall       從組裏安裝軟件包到你的系統
grouplist          列出當前的組
groupremove        在一個組中移除包從您的系統
help               顯示幫助用法信息
info               顯示關於包或一組包的細節信息
[root@localhost yum.repos.d]# yum info samba-client
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
 * base: mirrors.zju.edu.cn
 * epel: ftp.cuhk.edu.hk
 * extras: mirrors.cqu.edu.cn
 * remi-safe: remi.kazukioishi.net
 * updates: mirrors.pubyun.com
Available Packages
Name        : samba-client
Arch        : x86_64
Version     : 4.1.12
Release     : 23.el7_1
Size        : 515 k
Repo        : updates/7/x86_64
Summary     : Samba client programs
URL         : http://www.samba.org/
License     : GPLv3+ and LGPLv3+
Description : The samba4-client package provides some SMB/CIFS clients to
            : complement the built-in SMB/CIFS filesystem in Linux. These
            : clients allow access of SMB/CIFS shares and printing to
            : SMB/CIFS printers.
install            安裝一個或多個軟件包在你的系統
list               列出一個包或某組的包
localinstall       安裝本地 RPM
makecache          生成原數據緩存
provides           Find what package provides the given value
reinstall          從新安裝一個包
repolist           顯示軟件倉庫的配置
resolvedep         決定哪一個包提供了給定的依賴
search             查找包細節居給定的字符串
shell              運行交互式的yum shell
update             更新一個或多個包在你的系統
upgrade            Update packages taking obsoletes into account
Options:
-h, --help                show this help message and exit
-t, --tolerant            be tolerant of errors
-C                        從緩衝中運行,而不是升級緩存
-c  [config file]         config file location
-R  [minutes]             最大化的命令等待時間
-d  [debug level]         調試輸出級別
--showduplicates          顯示覆制, 在repo,list/search命令下
-e  [error level]         錯誤輸出級別
-q, --quiet               安靜的操做
-v, --verbose             verbose operation
-y                        回答全部的問題爲是
--version                 顯示 YUM版本信息並退出
--installroot=[path]  設置爲root安裝
--enablerepo=[repo]       激活一個或多個倉庫(支持通配符)
--disablerepo=[repo]  禁掉一個或多個倉庫(支持通配符)
-x [package], --exclude=[package] 在名稱或glob不包含包。
--disableexcludes=[repo]       disable exclude from main, for a repo or for everything
--obsoletes               enable obsoletes processing during updates
--noplugins               禁掉yum插件
--nogpgcheck              禁掉GPG驗證檢查
--disableplugin=[plugin]       用名稱禁掉插件
--enableplugin=[plugin]   enable plugins by name
--skip-broken             忽略包的依賴問題
--color=COLOR             control whether color is used

。。。。內容太多,不在此一一列舉

製做一個本地yum 源,最簡單的,配置文件以下

[root@localhost ~]# mount /dev/cdrom /mnt/
[root@localhost ~]# cd /mnt/
[root@localhost ~]#cp -r * /home/yum/
[root@localhost ~]#vi /etc/yum.repos.d/yum.repo
[root@localhost ~]# cat /etc/yum.repos.d/yum.repo 
[yum]
name=yum
baseurl=file:///home/yum/
gpgcheck=0
enable=1
[root@localhost ~]#
相關文章
相關標籤/搜索