标签:软件包、rpm、yum
大纲
一、软件包组成部分
二、rpm详解
三、yum详解
一、软件包组成部分
软件包组成部分
①二进制程序,例如/bin /sbin
②库,例如/lib
③配置文件,例如/etc
④帮助文档,例如/usr/share/man
二、rpm详解
rpm - RPM Package Manager # RPM包管理器 SYNOPSIS QUERYING AND VERIFYING PACKAGES:-q、-V、--import、-K INSTALLING, UPGRADING, AND REMOVING PACKAGES:-i、-U、-F、-e MISCELLANEOUS:--initdb、--addsign、--querytags、--setperms
1、安装
rpm -i /PATH/TO/PACKAGE_FILE -h: 以#显示进度;每个#表示2%; -v: 显示详细过程 -vv: 更详细的过程
(1)、安装时显示详细信息:-v
[root@soysauce test]# ls corosync-1.4.7-2.el6.x86_64.rpm vsftpd-2.2.2-14.el6.x86_64.rpm [root@soysauce test]# rpm -ivh vsftpd-2.2.2-14.el6.x86_64.rpm # 这个包没有依赖关系,顺利安装 Preparing... ########################################### [100%] 1:vsftpd ########################################### [100%]
(2)、安装时忽略依赖关系:--nodeps
[root@soysauce test]# rpm -ivh corosync-1.4.7-2.el6.x86_64.rpm # 这个包有依赖关系,装不上 Preparing... ########################################### [100%] package corosync-1.4.7-2.el6.x86_64 is already installed [root@soysauce test]# rpm -ivh --nodeps corosync-1.4.7-2.el6.x86_64.rpm # --nodeps忽略依赖关系 Preparing... ########################################### [100%] package corosync-1.4.7-2.el6.x86_64 is already installed # 虽然装上去了,但是可能无法使用
(3)、重新安装某个已经安装过的软件:--replacepkgs
[root@soysauce test]# rpm -ivh vsftpd-2.2.2-14.el6.x86_64.rpm Preparing... ########################################### [100%] package vsftpd-2.2.2-14.el6.x86_64 is already installed # 此时提示已经安装过了 [root@soysauce test]# rpm -ivh --replacepkgs vsftpd-2.2.2-14.el6.x86_64.rpm # 替换安装 Preparing... ########################################### [100%] 1:vsftpd ########################################### [100%]
(4)、强制安装:--force
[root@soysauce test]# rpm -ivh vsftpd-2.2.2-14.el6.x86_64.rpm Preparing... ########################################### [100%] package vsftpd-2.2.2-14.el6.x86_64 is already installed # 此时提示已经安装过了 [root@soysauce test]# rpm -ivh --force vsftpd-2.2.2-14.el6.x86_64.rpm # 强制安装 Preparing... ########################################### [100%] 1:vsftpd ########################################### [100%]
(5)、测试能否安装:--test
[root@soysauce test]# rpm -e vsftpd # 先卸载此rpm包 [root@soysauce test]# rpm -ivh --test vsftpd-2.2.2-14.el6.x86_64.rpm # 此时并没有安装,只是测试 Preparing... ########################################### [100%] [root@soysauce test]# rpm -q vsftpd # 查询是否安装此rpm包 package vsftpd is not installed
二、查询
rpm -q PACKAGE_NAME
1、查询指定的包是否已经安装 rpm -q
[root@soysauce test]# rpm -q vsftpd vsftpd-2.2.2-14.el6.x86_64
2、查询已经安装的所有包 rpm -qa
[root@soysauce test]# rpm -qa | grep "vsftpd" vsftpd-2.2.2-14.el6.x86_64
3 、查询指定包的说明信息 rpm -qi
[root@soysauce test]# rpm -qi vsftpd package vsftpd is not installed [root@soysauce test]# rpm -ivh vsftpd-2.2.2-14.el6.x86_64.rpm Preparing... ########################################### [100%] 1:vsftpd ########################################### [100%] [root@soysauce test]# rpm -qi vsftpd Name : vsftpd Relocations: (not relocatable) Version : 2.2.2 Vendor: CentOS Release : 14.el6 Build Date: Fri 24 Jul 2015 08:49:50 AM CST Install Date: Sun 29 Nov 2015 08:32:19 PM CST Build Host: c6b8.bsys.dev.centos.org Group : System Environment/Daemons Source RPM: vsftpd-2.2.2-14.el6.src.rpm Size : 339540 License: GPLv2 with exceptions Signature : RSA/SHA1, Sat 25 Jul 2015 04:41:15 AM CST, Key ID 0946fca2c105b9de Packager : CentOS BuildSystem <http://bugs.centos.org> URL : http://vsftpd.beasts.org/ Summary : Very Secure Ftp Daemon Description : vsftpd is a Very Secure FTP daemon. It was written completely from scratch.
4、查询指定包安装后生成的文件列表 rpm -ql
[root@soysauce test]# rpm -ql vsftpd |head -10 /etc/logrotate.d/vsftpd /etc/pam.d/vsftpd /etc/rc.d/init.d/vsftpd /etc/vsftpd /etc/vsftpd/ftpusers /etc/vsftpd/user_list /etc/vsftpd/vsftpd.conf /etc/vsftpd/vsftpd_conf_migrate.sh /usr/sbin/vsftpd /usr/share/doc/vsftpd-2.2.2
5、查询指定包安装的配置文件 rpm -qc
[root@soysauce test]# rpm -qc vsftpd /etc/logrotate.d/vsftpd /etc/pam.d/vsftpd /etc/vsftpd/ftpusers /etc/vsftpd/user_list /etc/vsftpd/vsftpd.conf
6、查询指定包安装的帮助文件 rpm -qd
[root@soysauce test]# rpm -qd vsftpd /usr/share/doc/vsftpd-2.2.2/AUDIT /usr/share/doc/vsftpd-2.2.2/BENCHMARKS /usr/share/doc/vsftpd-2.2.2/BUGS /usr/share/doc/vsftpd-2.2.2/COPYING /usr/share/doc/vsftpd-2.2.2/Changelog /usr/share/doc/vsftpd-2.2.2/EXAMPLE/INTERNET_SITE/README /usr/share/doc/vsftpd-2.2.2/EXAMPLE/INTERNET_SITE/README.configuration /usr/share/doc/vsftpd-2.2.2/EXAMPLE/INTERNET_SITE/vsftpd.conf /usr/share/doc/vsftpd-2.2.2/EXAMPLE/INTERNET_SITE/vsftpd.xinetd /usr/share/doc/vsftpd-2.2.2/EXAMPLE/INTERNET_SITE_NOINETD/README /usr/share/doc/vsftpd-2.2.2/EXAMPLE/INTERNET_SITE_NOINETD/README.configuration /usr/share/doc/vsftpd-2.2.2/EXAMPLE/INTERNET_SITE_NOINETD/vsftpd.conf /usr/share/doc/vsftpd-2.2.2/EXAMPLE/PER_IP_CONFIG/README /usr/share/doc/vsftpd-2.2.2/EXAMPLE/PER_IP_CONFIG/README.configuration /usr/share/doc/vsftpd-2.2.2/EXAMPLE/PER_IP_CONFIG/hosts.allow /usr/share/doc/vsftpd-2.2.2/EXAMPLE/README /usr/share/doc/vsftpd-2.2.2/EXAMPLE/VIRTUAL_HOSTS/README /usr/share/doc/vsftpd-2.2.2/EXAMPLE/VIRTUAL_USERS/README /usr/share/doc/vsftpd-2.2.2/EXAMPLE/VIRTUAL_USERS/README.configuration /usr/share/doc/vsftpd-2.2.2/EXAMPLE/VIRTUAL_USERS/logins.txt /usr/share/doc/vsftpd-2.2.2/EXAMPLE/VIRTUAL_USERS/vsftpd.conf /usr/share/doc/vsftpd-2.2.2/EXAMPLE/VIRTUAL_USERS/vsftpd.pam /usr/share/doc/vsftpd-2.2.2/EXAMPLE/VIRTUAL_USERS_2/README /usr/share/doc/vsftpd-2.2.2/FAQ /usr/share/doc/vsftpd-2.2.2/INSTALL /usr/share/doc/vsftpd-2.2.2/LICENSE /usr/share/doc/vsftpd-2.2.2/README /usr/share/doc/vsftpd-2.2.2/README.security /usr/share/doc/vsftpd-2.2.2/REWARD /usr/share/doc/vsftpd-2.2.2/SECURITY/DESIGN /usr/share/doc/vsftpd-2.2.2/SECURITY/IMPLEMENTATION /usr/share/doc/vsftpd-2.2.2/SECURITY/OVERVIEW /usr/share/doc/vsftpd-2.2.2/SECURITY/TRUST /usr/share/doc/vsftpd-2.2.2/SIZE /usr/share/doc/vsftpd-2.2.2/SPEED /usr/share/doc/vsftpd-2.2.2/TODO /usr/share/doc/vsftpd-2.2.2/TUNING /usr/share/doc/vsftpd-2.2.2/vsftpd.xinetd /usr/share/man/man5/vsftpd.conf.5.gz /usr/share/man/man8/vsftpd.8.gz
7、查询指定包中包含的脚本 rpm -q --scripts
[root@soysauce test]# rpm -q --scripts vsftpd postinstall scriptlet (using /bin/sh): /sbin/chkconfig --add vsftpd preuninstall scriptlet (using /bin/sh): if [ $1 = 0 ]; then /sbin/service vsftpd stop > /dev/null 2>&1 /sbin/chkconfig --del vsftpd fi
8、查询指定的文件是由哪个rpm包安装生成的 rpm -qf
[root@soysauce test]# rpm -qf /usr/share/man/man5/vsftpd.conf.5.gz vsftpd-2.2.2-14.el6.x86_64
9、rpm包尚未安装 rpm -qpi
[root@soysauce test]# ls corosync-1.4.7-2.el6.x86_64.rpm vsftpd-2.2.2-14.el6.x86_64.rpm [root@soysauce test]# rpm -q corosync package corosync is not installed [root@soysauce test]# rpm -qi corosync-1.4.7-2.el6.x86_64.rpm package corosync-1.4.7-2.el6.x86_64.rpm is not installed [root@soysauce test]# rpm -qpi corosync-1.4.7-2.el6.x86_64.rpm Name : corosync Relocations: (not relocatable) Version : 1.4.7 Vendor: CentOS Release : 2.el6 Build Date: Fri 24 Jul 2015 07:12:34 AM CST Install Date: (not installed) Build Host: c6b9.bsys.dev.centos.org Group : System Environment/Base Source RPM: corosync-1.4.7-2.el6.src.rpm Size : 448791 License: BSD Signature : RSA/SHA1, Sat 25 Jul 2015 04:38:44 AM CST, Key ID 0946fca2c105b9de Packager : CentOS BuildSystem <http://bugs.centos.org> URL : http://ftp.corosync.org Summary : The Corosync Cluster Engine and Application Programming Interfaces Description : This package contains the Corosync Cluster Engine Executive, several default APIs and libraries, default configuration files, and an init script.
三、升级
1、如果装有老版本的,则升级;否则,则安装
[root@soysauce test]# rpm -ivh vsftpd-2.3.5-1.el6.x86_64.rpm Preparing... ########################################### [100%] file /etc/logrotate.d/vsftpd from install of vsftpd-2.3.5-1.el6.x86_64 conflicts with file from package vsftpd-2.2.2-14.el6.x86_64 file /etc/pam.d/vsftpd from install of vsftpd-2.3.5-1.el6.x86_64 conflicts with file from package vsftpd-2.2.2-14.el6.x86_64 file /etc/rc.d/init.d/vsftpd from install of vsftpd-2.3.5-1.el6.x86_64 conflicts with file from package vsftpd-2.2.2-14.el6.x86_64 file /usr/sbin/vsftpd from install of vsftpd-2.3.5-1.el6.x86_64 conflicts with file from package vsftpd-2.2.2-14.el6.x86_64 file /etc/vsftpd/ftpusers from install of vsftpd-2.3.5-1.el6.x86_64 conflicts with file from package vsftpd-2.2.2-14.el6.x86_64 file /etc/vsftpd/user_list from install of vsftpd-2.3.5-1.el6.x86_64 conflicts with file from package vsftpd-2.2.2-14.el6.x86_64 file /etc/vsftpd/vsftpd.conf from install of vsftpd-2.3.5-1.el6.x86_64 conflicts with file from package vsftpd-2.2.2-14.el6.x86_64 file /etc/vsftpd/vsftpd_conf_migrate.sh from install of vsftpd-2.3.5-1.el6.x86_64 conflicts with file from package vsftpd-2.2.2-14.el6.x86_64 file /usr/share/man/man5/vsftpd.conf.5.gz from install of vsftpd-2.3.5-1.el6.x86_64 conflicts with file from package vsftpd-2.2.2-14.el6.x86_64 file /usr/share/man/man8/vsftpd.8.gz from install of vsftpd-2.3.5-1.el6.x86_64 conflicts with file from package vsftpd-2.2.2-14.el6.x86_64 [root@soysauce test]# rpm -Uvh vsftpd-2.3.5-1.el6.x86_64.rpm Preparing... ########################################### [100%] 1:vsftpd ########################################### [100%] [root@soysauce test]# rpm -q vsftpd vsftpd-2.3.5-1.el6.x86_64
2、如果装有老版本的,则升级;否则,退出
[root@soysauce test]# rpm -q lftp package lftp is not installed [root@soysauce test]# rpm -Fvh lftp-4.0.9-6.el6.x86_64.rpm [root@soysauce test]# rpm -q lftp package lftp is not installed [root@soysauce test]# rpm -q vsftpd vsftpd-2.2.2-14.el6.x86_64 [root@soysauce test]# rpm -Fvh vsftpd-2.3.5-1.el6.x86_64.rpm Preparing... ########################################### [100%] 1:vsftpd ########################################### [100%] [root@soysauce test]# rpm -q vsftpd vsftpd-2.3.5-1.el6.x86_64
3、降级
[root@soysauce test]# rpm -q vsftpd vsftpd-2.3.5-1.el6.x86_64 [root@soysauce test]# rpm -Uvh vsftpd-2.2.2-14.el6.x86_64.rpm Preparing... ########################################### [100%] package vsftpd-2.3.5-1.el6.x86_64 (which is newer than vsftpd-2.2.2-14.el6.x86_64) is already installed [root@soysauce test]# rpm -Uvh --oldpackage vsftpd-2.2.2-14.el6.x86_64.rpm Preparing... ########################################### [100%] 1:vsftpd ########################################### [100%] [root@soysauce test]# rpm -q vsftpd vsftpd-2.2.2-14.el6.x86_64
四、卸载
[root@soysauce test]# rpm -q vsftpd vsftpd-2.2.2-14.el6.x86_64 [root@soysauce test]# rpm -e vsftpd [root@soysauce test]# rpm -q vsftpd package vsftpd is not installed
五、校验
[root@soysauce test]# rpm -V vsftpd [root@soysauce test]# rpm -qc vsftpd /etc/logrotate.d/vsftpd /etc/pam.d/vsftpd /etc/vsftpd/ftpusers /etc/vsftpd/user_list /etc/vsftpd/vsftpd.conf [root@soysauce test]# echo "A new line" >> /etc/vsftpd/vsftpd.conf [root@soysauce test]# rpm -V vsftpd S.5....T. c /etc/vsftpd/vsftpd.conf 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
六、重建数据库
七、检验来源合法性,及软件包完整性
rpm -K /PAPT/TO/PACKAGE_FILE
本文出自 “Hello,Linux” 博客,请务必保留此出处http://soysauce93.blog.51cto.com/7589461/1717953
标签:软件包、rpm、yum
原文地址:http://soysauce93.blog.51cto.com/7589461/1717953