Summary of rpm commonly used commands-installation, upgrade, query, verification, uninstall

1 RPM installation (install)

[root@study ~]$ rpm -ivh package_name

选项与参数:
-i :install 安装的意思
-v :察看更详细的安装信息
-h :显示安装进度

范例一:安装 rp-pppoe 软件
[root@study ~]$ rpm -ivh rp-pppoe-3.11-5.el7.x86_64.rpm

范例二、一口气安装两个以上的软件时:
[root@study ~]$ rpm -ivh a.i386.rpm b.i386.rpm *.rpm
# 后面直接接上许多的软件文件!

范例三、直接由网络上面的某个文件安装,以网址来安装:
[root@study ~]$ rpm -ivh http://website.name/path/pkgname.rpm

Common options and parameter descriptions during rpm installation

Options Representative meaning
--nodeps When to use : When a software attribute dependency problem occurs and you cannot install it, but you insist on installing it is
dangerous : The reason for the software dependency is that each other uses each other’s mechanisms or functions. If you force the installation, regardless of the software’s attribute dependency , It may cause the software to be unable to use normally!
--replacefiles When to use : If the message "a file has been installed on your system" appears during the installation process, or if there is a message that the version does not match (confilcting files), you can use this parameter to directly overwrite the file.
Danger : The action of covering is irreversible! Therefore, you must know very clearly that the overwritten file can really be overwritten! Otherwise you will cry without tears!
--replacepkgs When to use : Reinstall a software that has already been installed! If you want to install a bunch of RPM software files, you can use rpm -ivh *.rpm, but if some software has already been installed, the system will display the message "some software is already installed" at this time, making it impossible to continue the installation. At this time, you can use this option to repeat the installation!
--force Timing : This parameter is actually a combination of --replacefiles and --replacepkgs!
--test When to use : I want to test whether the software can be installed in the user's Linux environment, and find out whether there is an attribute dependency problem. The example is: rpm -ivh pkgname.i386.rpm --test
--justdb When to use : When the RPM database is damaged or an error occurs for some reason, you can use this option to update the software's related information in the database.
--nosignature When to use : You can use this option when you want to skip the check of the digital signature.
--prefix new path When to use : When you want to install the software to other informal directories. For example, if you want to install certain software to /usr/local instead of the regular /bin, /etc and other directories, you can use "--prefix/usr/local" to deal with it.
--noscripts When to use : I don't want the software to execute certain system commands by itself during the installation process.
Note : The advantage of RPM is that in addition to placing the file in the location, it can also automatically execute some pre-work instructions, such as the initialization of the database. If you don't want RPM to automatically execute this type of instruction for you, just add it!

2 RPM upgrade and update (upgrade/freshen)

Options Representative meaning
--Uvh Even if the following software has not been installed, the system will install it directly; if the following software has an old version installed, the system will automatically update to the new version;
--Fvh If the following software is not installed on your Linux system, the software will not be installed; only the software that has been installed on your Linux system will be "upgraded"!

3 RPM query (query)

[root@study ~]$ rpm -qa										<==已安装软件
[root@study ~]$ rpm -q[licdR] 已安装的软件名称 				<==已安装软件
[root@study ~]$ rpm -qf 存在于系统上面的某个文件名 				<==已安装软件
[root@study ~]$ rpm -qp[licdR] 未安装的某个文件名称 			<==查阅RPM文件

选项与参数:
查询已安装软件的信息:
-q :仅查询,后面接的软件名称是否有安装;
-qa :列出所有的,已经安装在本机 Linux 系统上面的所有软件名称;
-qi :列出该软件的详细信息 (information),包含开发商、版本与说明等;
-ql :列出该软件所有的文件与目录所在完整文件名 (list);
-qc :列出该软件的所有配置文件 (找出在 /etc/ 下面的文件名而已)
-qd :列出该软件的所有说明文档 (找出与 man 有关的文件而已)
-qR :列出与该软件有关的相依软件所含的文件 (Required 的意思)
-qf :由后面接的文件名称,找出该文件属于哪一个已安装的软件;
-q --scripts:列出是否含有安装后需要执行的脚本档,可用以 debug 喔!
查询某个 RPM 文件内含有的信息:
-qp[icdlR]:注意 -qp 后面接的所有参数以上面的说明一致。但用途仅在于找出某个 RPM 文件内的信息,而非已安装的软件信息!注意!

4 RPM verification

[root@study ~]$ rpm -Va
[root@study ~]$ rpm -V 已安装的软件名称
[root@study ~]$ rpm -Vp 某个 RPM 文件的文件名
[root@study ~]$ rpm -Vf 在系统上面的某个文件
选项与参数:
-V :后面加的是软件名称,若该软件所含的文件被更动过,才会列出来;
-Va :列出目前系统上面所有可能被更动过的文件;
-Vp :后面加的是文件名称,列出该软件内可能被更动过的文件;
-Vf :列出某个文件是否被更动过~

example

范例一:列出你的 Linux 内的 logrotate 这个软件是否被更动过?
[root@study ~]$ rpm -V logrotate
# 如果没有出现任何讯息,恭喜你,该软件所提供的文件没有被更动过。
# 如果有出现任何讯息,才是有出现状况啊!
范例二:查询一下,你的 /etc/crontab 是否有被更动过?
[root@study ~]$ rpm -Vf /etc/crontab
.......T. c /etc/crontab
# 瞧!因为有被更动过,所以会列出被更动过的信息类型!

There is a c before the changed file name, and then a bunch of strange characters. The c stands for configuration, which means configuration file. As for the first few pieces of information:

  • S: (file Size differs) Whether the file size differs has been changed
  • M: (Mode differs) Has the file type or file attribute (rwx) been changed? The parameters such as executable etc. have been changed
  • 5: (MD5 sum differs) The content of the MD5 fingerprint code is already different
  • D: (Device major/minor number mis-match) The major/minor number of the device has changed
  • L: (readLink(2) path mis-match) Link path has been changed
  • U: (User ownership differs) The owner of the file has been changed
  • G: (Group ownership differs) The group ownership of the file has been changed
  • T: (mTime differs) The creation time of the file has been changed
  • P: (caPabilities differ) The function has been changed

So, if all the information in a configuration file has been changed, then his display will be:

SM5DLUGTP c filename

As for that c represents the meaning of "Config file", that is, the type of file, the file types are as follows:

  • c: configuration file (config file)
  • d: file data file (documentation)
  • g: Ghost file~ Usually the file is not included by a certain software, and it rarely happens! (Ghost file)
  • l: License file
  • r: read me

5 RPM uninstall and rebuild the database (erase/rebuilddb)

Uninstall is to uninstall the software, use the -e parameter

[root@study ~]$ rpm -e 已安装的软件名称

Since RPM files are often installed/removed/upgraded, some actions may cause
damage to the files in the RPM database /var/lib/rpm/ . You can use --rebuilddb to rebuild the database.

[root@study ~]$ rpm --rebuilddb 			<==重建数据库

Guess you like

Origin blog.csdn.net/happyjacob/article/details/113486970