RPM default installation path
Generally speaking, when installing an RPM type file, the configuration parameters recorded in the file will be read first, and then the data will be used to compare the Linux system environment to find out if there are property-dependent software issues that have not been installed.
For example, Openssh depends on the encryption software Openssl, so you must first install openssl before installing openssh. If openssl is not present in your environment, you cannot install openssh.
If the environment check passes, the RPM file will be installed on the Linux system. After the installation is completed, software-related information will be written to the database file in the /var/lib/rpm/ directory. The directory /var/lib/rpm/ is very important. Any future software upgrade requirements and version comparisons will come from this database. If you want to query installed software, you can also perform the corresponding query from here.
The installation location of the corresponding files in the software is as follows:
/etc & **& Some man page files
RPM installation
Note that installation requires root permissions.
If you want to install a file named rp-pppoe-3.5-32.1.i386.rpm, the simplest command can be:
[root@www ~]# rpm -i rp-pppoe-3.5-32.1.i386.rpm
However, such an installation will not display the corresponding Progress information, in order to easily check the installation status, you can write:
[root@www ~]# rpm -ivh package_name选项与参数: -i :install 的意思 -v :察看更细部的安装资讯画面 -h :以安装资讯列显示安装进度 范例一:安装 rp-pppoe-3.5-32.1.i386.rpm [root@www ~]# rpm -ivh rp-pppoe-3.5-32.1.i386.rpmPreparing... ####################################### [100%] 1:rp-pppoe ####################################### [100%] 范例二、一口气安装两个以上的软件时: [root@www ~]# rpm -ivh a.i386.rpm b.i386.rpm *.rpm# 后面直接接上许多的软件文件!范例三、直接由网络上面的某个文件安装,以网址来安装: [root@www ~]# rpm -ivh http://website.name/path/pkgname.rpm
Other installation parameters are as follows:
RPM upgrade Upgrading with RPM is so easy! Just use -Uvh or -Fvh to upgrade. The options and parameters available for -Uvh and -Fvh are the same as install. However, the meanings of -U and -F are still different. The basic difference is as follows:-Uvh 后面接的软件即使没有安装过,则系统将予以直接安装; 若后面接的软件有安装过旧版,则系统自动升级至新版; -Fvh 如果后面接的软件并未安装到你的 Linux 系统上,则该软件不会被安装;亦即只有已安装至你 Linux 系统内的软件会被『升级』!From the above description, if you want to upgrade a large number of old version of the system software, It is better to use -Fvh, because uninstalled software will not be accidentally installed into the system. However, it should be noted that if you are using -Fvh and this software is not yet available on your machine, then sorry, the software will not be installed on your Linux host, so please install it again with ivh Bar!
RPM Query
RPM When querying, the query is actually the database file in the /var/lib/rpm/ directory! In addition, RPM can also query the information in uninstalled RPM files! How to check it? Let’s start by talking about what are the options available?
[root@www ~]# rpm -qa <==已安装软件 [root@www ~]# rpm -q[licdR] 已安装的软件名称 <==已安装软件 [root@www ~]# rpm -qf 存在於系统上面的某个档名 <==已安装软件 [root@www ~]# rpm -qp[licdR] 未安装的某个文件名称 <==查阅RPM文件选项与参数: 查询已安装软件的资讯: -q :仅查询,后面接的软件名称是否有安装; -qa :列出所有的,已经安装在本机 Linux 系统上面的所有软件名称; -qi :列出该软件的详细资讯 (information),包含开发商、版本与说明等; -ql :列出该软件所有的文件与目录所在完整档名 (list); -qc :列出该软件的所有配置档 (找出在 /etc/ 底下的档名而已) -qd :列出该软件的所有说明档 (找出与 man 有关的文件而已) -qR :列出与该软件有关的相依软件所含的文件 (Required 的意思) -qf :由后面接的文件名称,找出该文件属於哪一个已安装的软件; 查询某个 RPM 文件内含有的资讯: -qp[icdlR]:注意 -qp 后面接的所有参数以上面的说明一致。但用途仅在於找出 某个 RPM 文件内的资讯,而非已安装的软件资讯!注意!
In the query part, all parameters need to be preceded by -q to be called a query! The query is mainly divided into two parts. One is to check the software information that has been installed on the system. This part of the information is provided by /var/lib/rpm/. The other is to check the contents of a certain rpm file, which is equivalent to finding some information to be written into the database from the RPM file. For this part, you must use -qp (p means package). Let’s take a look at a few simple examples!
范例一:找出你的 Linux 是否有安装 logrotate 这个软件? [root@www ~]# rpm -q logrotatelogrotate-3.7.4-8 [root@www ~]# rpm -q logrotatingpackage logrotating is not installed# 注意到,系统会去找是否有安装后面接的软件名称。注意, # 不必要加上版本喔!至於显示的结果,一看就知道有没有安装啦!范例二:列出上题当中,属於该软件所提供的所有目录与文件: [root@www ~]# rpm -ql logrotate/etc/cron.daily/logrotate /etc/logrotate.conf ....(以下省略)....# 可以看出该软件到底提供了多少的文件与目录,也可以追踪软件的数据。范例三:列出 logrotate 这个软件的相关说明数据: [root@www ~]# rpm -qi logrotateName : logrotate Relocations: (not relocatable) Version : 3.7.4 Vendor: CentOS Release : 8 Build Date: Sun 02 Dec 2007 08:38:06 AM CST Install Date: Sat 09 May 2009 11:59:05 PM CST Build Host: builder6 Group : System Environment/Base Source RPM: logrotate-3.7.4-8.src.rpm Size : 53618 License: GPL Signature : DSA/SHA1, Sun 02 Dec 2007 09:10:01 AM CST, Key ID a8a447dce8562897 Summary : Rotates, compresses, removes and mails system log files. Description : The logrotate utility is designed to simplify the administration oflog files on a system which generates a lot of log files. Logrotate allows for the automatic rotation compression, removal and mailing oflog files. Logrotate can be set to handle a log file daily, weekly, monthly or when the log file gets to a certain size. Normally, logrotate runs as a daily cron job. Install the logrotate package if you need a utility to deal with thelog files on your system. # 列出该软件的 information (资讯),里面的资讯可多著呢,包括了软件名称、 # 版本、开发商、SRPM文件名称、打包次数、简单说明资讯、软件打包者、 # 安装日期等等!如果想要详细的知道该软件的数据,用这个参数来了解一下范例四:分别仅找出 logrotate 的配置档与说明档 [root@www ~]# rpm -qc logrotate[root@www ~]# rpm -qd logrotate范例五:若要成功安装 logrotate ,他还需要什么文件的帮忙? [root@www ~]# rpm -qR logrotate/bin/sh config(logrotate) = 3.7.4-8libc.so.6....(以下省略).... # 由这里看起来,呵呵~还需要很多文件的支持才行喔!范例六:由上面的范例五,找出 /bin/sh 是那个软件提供的? [root@www ~]# rpm -qf /bin/shbash-3.2-21.el5 # 这个参数后面接的可是『文件』呐!不像前面都是接软件喔! # 这个功能在查询系统的某个文件属於哪一个软件所有的。范例七:假设我有下载一个 RPM 文件,想要知道该文件的需求文件,该如何? [root@www ~]# rpm -qpR filename.i386.rpm# 加上 -qpR ,找出该文件需求的数据!
要特别说明的是,在查询本机上面的 RPM 软件相关资讯时, 不需要加上版本的名称,只要加上软件名称即可!因为他会由 /var/lib/rpm 这个数据库里面去查询, 所以我们可以不需要加上版本名称。但是查询某个 RPM 文件就不同了,我们必须要列出整个文件的完整档名才行~ 这一点朋友们常常会搞错。底下我们就来做几个简单的练习吧!
RPM 卸载
解安装的过程一定要由最上一级往下解除以 rp-pppoe 为例,这一个软件主要是依据 ppp 这个软件来安装的,所以当你要解除 ppp 的时候,就必须要先解除 rp-pppoe 才行!否则就会发生结构上的问题啦!这个可以由建筑物来说明, 如果你要拆除五、六楼,那么当然要由六楼拆起,否则先拆的是第五楼时,那么上面的楼层难道会悬空?
移除的选项很简单,就透过 -e 即可移除。不过,很常发生软件属性相依导致无法移除某些软件的问题! 我们以底下的例子来说明:
# 1. 找出与 pam 有关的软件名称,并尝试移除 pam 这个软件:[root@www ~]# rpm -qa | grep pampam-devel-0.99.6.2-3.27.el5 pam_passwdqc-1.0.2-1.2.2pam_pkcs11-0.5.3-23pam_smb-1.1.7-7.2.1pam-0.99.6.2-3.27.el5 pam_ccreds-3-5pam_krb5-2.2.14-1[root@www ~]# rpm -e pamerror: Failed dependencies: <==这里提到的是相依性的问题 libpam.so.0 is needed by (installed) coreutils-5.97-14.el5.i386 libpam.so.0 is needed by (installed) libuser-0.54.7-2.el5.5.i386 ....(以下省略)....# 2. 若仅移除 pam-devel 这个之前范例安装上的软件呢? [root@www ~]# rpm -e pam-devel <==不会出现任何信息! [root@www ~]# rpm -q pam-devel package pam-devel is not installed
从范例一我们知道 pam 所提供的函式库是让非常多其他软件使用的,因此你不能移除 pam ,除非将其他相依软件一口气也全部移除!你当然也能加 --nodeps 来强制移除, 不过,如此一来所有会用到 pam 函式库的软件,都将成为无法运行的程序,我想,你的主机也只好准备停机休假了吧! 至於范例二中,由於 pam-devel 是依附於 pam 的开发工具,你可以单独安装与单独移除。
由於 RPM 文件常常会安装/移除/升级等,某些动作或许可能会导致 RPM 数据库 /var/lib/rpm/ 内的文件破损。果真如此的话,那你该如何是好?别担心,我们可以使用 --rebuilddb 这个选项来重建一下数据库喔! 作法如下:
[root@www ~]# rpm --rebuilddb <==重建数据库
以上就是笔记005 RRM软件管理程序的内容,更多相关内容请关注PHP中文网(www.php.cn)!