1.rpm command
rpm can be used to install, upgrade, query, verify, and uninstall rpm packages.
2. How to use the rpm package
rpm -ivh package file //install
rpm -Uvh package file //upgrade
rpm -e package name //uninstall
rpm -qa //Query all installed packages
rpm -q package name //Query whether a package is installed
rpm -qi package name //Query the detailed information of a package
rpm -ql package name //Query which files are installed by this rpm package
rpm -qf file // Which rpm package the query file comes from
Option Description:
Install:
i: install means install.
v: Query more detailed information screen.
h: Displays the installation progress.
upgrade:
U: The following software is not installed, the system will install it; if the software is installed, update the latest version
F: The following software is not installed, and the system will not install it; if the software is installed, it will be upgraded to the latest version
Inquire:
qa: Query all installed software on the machine.
qf: Find out which software belongs to through a file.
q: Only query whether the software is installed.
qi: List the software's detailed information (information), developer, version and description.
ql: List the complete file names (list) where all files and directories of the software are located.
qc: List all setting files of the software.
qd: List all help files of the software.
qR: List the files contained in the dependent software related to the software (Required).
qp[licdR]: Consistent with the above, qp queries the file information in the non-installed RPM package.
verify:
V: followed by the name of the software, the files contained in the software have been changed before they are listed. For a software query.
Va: List all files on the system that may have been changed. for a real system.
Vp: followed by the file name, for RPM packages.
Vf: List whether a file has been changed.
Uninstall:
e: uninstall
Arguments available for RPM installation (not commonly used)
3. Examples
3.1 Install rpm package
Check the rpm package that comes with the image.
In the lower right corner of the virtual machine, connect the image and the CD-ROM logo.
Confirm that the mnt directory is not mounted, and then mount it
mount /dev/cdrom /mnt
cd /mnt/Packages/
ls
Install
# rpm -ivh tree-1.6.0-10.el7.x86_64.rpm
Preparing... ################################# [100%]
Upgrading/installing...
1:tree-1.6.0-10.el7 #################################### [100%]
3.2 Querying which files are installed by rpm
# rpm -ql tree
/usr/bin/tree
/usr/share/doc/tree-1.6.0
/usr/share/doc/tree-1.6.0/LICENSE
/usr/share/doc/tree-1.6.0/README
/usr/share/man/man1/tree.1.gz
3.3 Check which rpm package a file comes from
# rpm -qf `which tree`
tree-1.6.0-10.el7.x86_64
3.4 Querying the installed rpm information
# rpm -qi tree
Name : tree
Version : 1.6.0
Release : 10.el7
Architecture: x86_64
Install Date: Wed, April 18, 2018 11:26:04
Group : Applications/File
Size : 89505
....
3.5 Uninstall rpm package
# rpm -e tree
no reminder
4. Validation (not commonly used)
For software, check whether the tree software has been changed.
# rpm -V tree
For system files, check whether the system files have been modified for the default situation (there is no prompt message if there is no modification, the following prompt message is to delete a blank line for testing, that is, if)
# rpm -Vf /etc/crontab
S.5....T. c /etc/crontab
The meaning of the first 8 bits
第9个字符的含义
5. 重建数据库
某些操作可能导致RPM数据库/var/lib/rpm内的文件损坏。重建数据库恢复。
rpm --rebuilddb