rpm command

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)

executable parameters

representative meaning

--nodeps

When to use: When the software cannot be installed due to dependency problems, you insist on installing it. Problem:  May not work properly.

--replacefiles

When to use: When showing that a file is already installed on the system, it can be overridden with a parameter. Problem: To figure out if it can be overridden.

--replacepkgs

When to use: Reinstall the software installed by a certain mood.

--force

Timing of use: mandatory installation, a combination of the above two parameters.

--test

When to use it: Test whether the software can be installed into the current environment and find out the dependency problems. rpm -ivh re-pppoe.i386.rpm --test

--justdb

When to use: Update the relevant information of the database

--nosignature

When to use: When bypassing certificate detection.

--prefix new path

When to use: Install the software to another path. --prefix /usr/local

--noscripts

When to use: You don't want to let some system commands execute by yourself during the software installation process.


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

character

meaning

S(file Size differs)

file size

M(Mode differs)

file type or file attribute (rwx)

5(MD5 sum differs)

The content of the fingerprint code such as MD5

D(Device major/minor number mis-match)

设备的主次代码

L(readLink (2) path mis-patch)

Link路径

U(User ownership differs)

文件的所有者

G(Group ownership differs)

文件的所属组

T(mTime differs)

文件的创建时间


第9个字符的含义

字符

含义

c

设置文件(config file)

d

文档(documentation)

g

鬼文件(ghost file)文件不被软件包含

l

授权文件(license file)

r

自述文件(read me)


5. 重建数据库

某些操作可能导致RPM数据库/var/lib/rpm内的文件损坏。重建数据库恢复。 

rpm --rebuilddb


Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324538283&siteId=291194637