第3章管理软件包安装
1、查询rpm信息(注意:红字)
1) rpm -qpi
[root@teachers ~]# rpm -qpi wpa_supplicant-0.7.3-4.el6_3.x86_64.rpm
warning: wpa_supplicant-0.7.3-4.el6_3.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID fd431d51: NOKEY
Name : wpa_supplicant Relocations: (not relocatable)
Version : 0.7.3 Vendor: Red Hat, Inc.
Release : 4.el6_3 Build Date: Thu 25 Oct 2012 03:58:29 AM EDT
Install Date: (not installed) Build Host: x86-002.build.bos.redhat.com
Group : System Environment/Base Source RPM: wpa_supplicant-0.7.3-4.el6_3.src.rpm
Size : 960335 License: BSD
Signature : RSA/8, Mon 03 Dec 2012 06:04:50 AM EST, Key ID 199e2f91fd431d51
Packager : Red Hat, Inc. <http://bugzilla.redhat.com/bugzilla>
URL : http://w1.fi/wpa_supplicant/
Summary : WPA/WPA2/IEEE 802.1X Supplicant
Description :
wpa_supplicant is a WPA Supplicant for Linux, BSD and Windows with support
for WPA and WPA2 (IEEE 802.11i / RSN). Supplicant is the IEEE 802.1X/WPA
component that is used in the client stations. It implements key negotiation
with a WPA Authenticator and it controls the roaming and IEEE 802.11
authentication/association of the wlan driver.
以上红字代表数字签名,如果没有数字签名的包也是可以安装的,但是会出现warning警告
2) rpm -qf
[root@teachers ~]# rpm -qf wpa_supplicant-0.7.3-4.el6_3.x86_64.rpm
查询软件包有哪些文件
3) rpm -qc
[root@teachers ~]# rpm -qc httpd
/etc/httpd/conf.d/welcome.conf
/etc/httpd/conf/httpd.conf
/etc/httpd/conf/magic
/etc/logrotate.d/httpd
/etc/sysconfig/htcacheclean
/etc/sysconfig/httpd
/var/www/error/HTTP_BAD_GATEWAY.html.var
/var/www/error/HTTP_BAD_REQUEST.html.var
/var/www/error/HTTP_FORBIDDEN.html.var
/var/www/error/HTTP_GONE.html.var
/var/www/error/HTTP_INTERNAL_SERVER_ERROR.html.var
/var/www/error/HTTP_LENGTH_REQUIRED.html.var
/var/www/error/HTTP_METHOD_NOT_ALLOWED.html.var
/var/www/error/HTTP_NOT_FOUND.html.var
/var/www/error/HTTP_NOT_IMPLEMENTED.html.var
/var/www/error/HTTP_PRECONDITION_FAILED.html.var
/var/www/error/HTTP_REQUEST_ENTITY_TOO_LARGE.html.var
/var/www/error/HTTP_REQUEST_TIME_OUT.html.var
/var/www/error/HTTP_REQUEST_URI_TOO_LARGE.html.var
/var/www/error/HTTP_SERVICE_UNAVAILABLE.html.var
/var/www/error/HTTP_UNAUTHORIZED.html.var
/var/www/error/HTTP_UNSUPPORTED_MEDIA_TYPE.html.var
/var/www/error/HTTP_VARIANT_ALSO_VARIES.html.var
/var/www/error/contact.html.var
/var/www/error/include/bottom.html
/var/www/error/include/spacer.html
/var/www/error/include/top.html
以上查询安装rpm包的配置文件
4) rpm -qd
[root@teachers ~]# rpm -qd httpd
/usr/share/doc/httpd-2.2.15/ABOUT_APACHE
/usr/share/doc/httpd-2.2.15/CHANGES
/usr/share/doc/httpd-2.2.15/LICENSE
/usr/share/doc/httpd-2.2.15/NOTICE
/usr/share/doc/httpd-2.2.15/README
/usr/share/doc/httpd-2.2.15/VERSIONING
/usr/share/man/man8/apachectl.8.gz
/usr/share/man/man8/htcacheclean.8.gz
/usr/share/man/man8/httpd.8.gz
/usr/share/man/man8/rotatelogs.8.gz
/usr/share/man/man8/suexec.8.gz
以上查询安装rpm包的帮助文档
5) 查看rpm数据库路径(/var/lib/rpm)
[root@teachers ~]# cd /var/lib/rpm/
[root@teachers rpm]# ls
Basenames __db.001 __db.003 Dirnames Group Name Packages Provideversion Requirename Sha1header Triggername
Conflictname __db.002 __db.004 Filedigests Installtid Obsoletename Providename Pubkeys Requireversion Sigmd5
[root@teachers rpm]# pwd
/var/lib/rpm
6) rpm --initdb (初始化rpm包数据库)
7) rpm --rebuilddb(恢复rpm包数据库)
8) rpm -V (校验软件包)
[root@teachers ~]# rpm -V httpd
S.5....T. c /etc/httpd/conf/httpd.conf
校验某个文件或者某个包,检验其状态和安装时的变化情况
2、通过KEY验证软件包的合法性
1)KEY的所存放的位置
[root@teachers rpm-gpg]# pwd
/etc/pki/rpm-gpg
2)KEY导入位置
[root@teachers rpm-gpg]# rpm --import RPM-GPG-KEY-redhat-release ---导入key
[root@teachers rpm-gpg]# rpm -qa|grep gpg-pubkey ---查询导入的key
gpg-pubkey-2fa658e0-45700c69
gpg-pubkey-fd431d51-4ae0493b
[root@teachers rpm-gpg]# ll /root/.gnupg/ ---查询key导入的位置
total 12
-rw-------. 1 root root 7856 Jan 16 10:16 gpg.conf
-rw-------. 1 root root 0 Jan 16 10:16 pubring.gpg
-rw-------. 1 root root 0 Jan 16 10:16 secring.gpg
-rw-------. 1 root root 40 Jan 16 10:16 trustdb.gpg
3)KEY删除
[root@teachers rpm-gpg]# rpm -e gpg-pubkey-2fa658e0-45700c69
[root@teachers rpm-gpg]# rpm -e gpg-pubkey-fd431d51-4ae0493b
4) rpm -vvK(“-K”是否是红帽官方提供的,验证包的安全)
[root@teachers ~]# rpm -vvK wpa_supplicant-0.7.3-4.el6_3.x86_64.rpm 2> /dev/null
wpa_supplicant-0.7.3-4.el6_3.x86_64.rpm:
Header V3 RSA/SHA256 Signature, key ID fd431d51: NOKEY
Header SHA1 digest: OK (b52f9919343fe5ca32fd0bd33ea56abe65f26e2f)
V3 RSA/SHA256 Signature, key ID fd431d51: NOKEY
MD5 digest: OK (4398e24ce42bd0c70e5e3053c6cbf812)
5) rpm -q --scripts httpd (“--scripts”安装的包执行过那些脚本.,验证脚本的安全)
[root@teachers ~]# rpm -q --scripts httpd
preinstall scriptlet (using /bin/sh):
# Add the "apache" user
getent group apache >/dev/null || groupadd -g 48 -r apache
getent passwd apache >/dev/null || \
useradd -r -u 48 -g apache -s /sbin/nologin \
-d /var/www -c "Apache" apache
exit 0
postinstall scriptlet (using /bin/sh):
# Register the httpd service
/sbin/chkconfig --add httpd
/sbin/chkconfig --add htcacheclean
preuninstall scriptlet (using /bin/sh):
if [ $1 = 0 ]; then
/sbin/service httpd stop > /dev/null 2>&1
/sbin/chkconfig --del httpd
/sbin/service htcacheclean stop > /dev/null 2>&1
/sbin/chkconfig --del htcacheclean
fi
posttrans scriptlet (using /bin/sh):
test -f /etc/sysconfig/httpd-disable-posttrans || \
/sbin/service httpd condrestart >/dev/null 2>&1 || :
安装“preinstall” 前先创建了组和用户,给apache创建用户并创建目录,接着添加服务。
卸载“preuninstall”先停止服务并卸载服务。