标签:程序
CentOS系统上程序rpm包管理:
安装、升级、卸载、查询、检验
通过rpm命令完成
安装:
rpm {-i|--install} [install-options] PACKAGE_FILE1...
-h: hash,以#来表示安装进度;
-v, --verbose:显示安装过程中的详细信息;
-vv:
-vvv:
安装时常用的组合: -ivh, -ivvh
--test:不执行真正的安装过程,而仅报告依赖关系及冲突信息等;
忽略依赖关系:
副作用:能安装成功,但未必能成功运行;
--nodeps
覆盖安装:重新安装并覆盖原有的文件
--replacepkgs
强制安装:
--force
升级:
rpm {-U|--upgrade} [install-options] PACKAGE_FILE ...
-U: 升级或安装
rpm {-F|--freshen} [install-options] PACKAGE_FILE ...
-F:升级
组合:-Uvh, -Fvh
--test
--nodeps
--force
--oldpackage:降级到旧版本
移除已经安装的程序包
rpm {-e|--erase} [--allmatches] [--nodeps] [--test] PACKAGE_NAME ...
简单用法:rpm -e PACKAGE_NAME...
--nodeps:忽略依赖关系;
--test: 测试卸载;dry-run模式;
--allmatches: 如果一个程序包同时安装多个版本,则此选项一次全部卸载之
rpm {-q|--query} [select-options] [query-options]
[select-options]:
1、查询某包或某些包是否安装:
rpm -q PACKAGE_NAME...
2、查询已经安装的所有包:
rpm -qa
3、查询某文件是由哪个包安装生成:
rpm -qf /PATH/TO/SOMEFILE
4、查询尚未安装的包文件的相关信息
-p
# rpm -qpi PACKAGE_FILE
[query-options]:
1、查询某包的简要说明信息:
rpm -qi PACKAGE_NAME
2、查询某包安装生成的文件列表:
rpm -ql PACKAGE_NAME
3、查询某包安装完成后生成的所有配置文件:
rpm -qc PACKAGE_NAME
4、查询某包安装完成后生成的所有帮助文件:
rpm -qd PACKAGE_NAME
5、查看某包制作时随版本变化的changelog信息:
rpm -q --changelog PACKAGE_NAME
6、查询某包提供的capabilities:
rpm -q --provides PACKAGE_NAME
7、查询某包所依赖的capabilities:
rpm -q --requires PACKAGE_NAME
8、查询某包安装或卸载时执行脚本:
rpm -q --scripts PACKAGE_NAME
[root@localhost ~]# rpm -q --scripts nginx preinstall scriptlet (using /bin/sh): # Add the "nginx" user getent group nginx >/dev/null || groupadd -r nginx getent passwd nginx >/dev/null || useradd -r -g nginx -s /sbin/nologin -d /var/cache/nginx -c "nginx user" nginx exit 0 postinstall scriptlet (using /bin/sh): # Register the nginx service if [ $1 -eq 1 ]; then /sbin/chkconfig --add nginx # print site info cat <<BANNER ---------------------------------------------------------------------- Thanks for using nginx! Please find the official documentation for nginx here: * http://nginx.org/en/docs/ Commercial subscriptions for nginx are available on: * http://nginx.com/products/ ---------------------------------------------------------------------- BANNER # Touch and set permisions on default log files on installation if [ -d /var/log/nginx ]; then if [ ! -e /var/log/nginx/access.log ]; then touch /var/log/nginx/access.log /bin/chmod 640 /var/log/nginx/access.log /bin/chown nginx:adm /var/log/nginx/access.log fi if [ ! -e /var/log/nginx/error.log ]; then touch /var/log/nginx/error.log /bin/chmod 640 /var/log/nginx/error.log /bin/chown nginx:adm /var/log/nginx/error.log fi fi fi preuninstall scriptlet (using /bin/sh): if [ $1 -eq 0 ]; then /sbin/service nginx stop > /dev/null 2>&1 /sbin/chkconfig --del nginx fi postuninstall scriptlet (using /bin/sh): if [ $1 -ge 1 ]; then /sbin/service nginx status >/dev/null 2>&1 || exit 0 /sbin/service nginx upgrade >/dev/null 2>&1 || echo "Binary upgrade failed, please check nginx‘s error.log" fi [root@localhost ~]#
标签:程序
原文地址:http://987665432.blog.51cto.com/9154574/1633102