rpm package management tool (commonly used commands)

RPM Package Manager (RPM) is a powerful command-line driven package management tool for installing, uninstalling, verifying, querying and updating packages on Linux systems.

rpm command

The rpm package is divided into software package and source package. The source package has .src.rpmthe suffix

Common commands

Command reference https://www.cnblogs.com/Daniel-G/archive/2012/11/28/2792630.html

# 1、查看所有rpm包
rpm -qa | grep xxx
# 2、查看文件属于哪个rpm包(遍历所有包看哪个包有这个文件)
rpm -qf /path/filename


# 查看rpm包中的所有文件
# 1、已安装的软件包:
rpm -ql $packet_name
# 2、未安装的软件包:
rpm -qlp $rpm_filename.rpm # -p可以省略

# 查看rpm包所依赖的包
rpm -qR $packet_name
rpm -qRp $rpm_filename.rpm

# 统计安装的包数量
rpm -qa | wc -l
# 查看包信息
rpm -qi $packet_name
rpm -qip $rpm_filename.rpm
# 卸载rpm包
rpm -e $packet_name
# 安装rpm包
rpm -ivh $rpm_filename.rpm
# 源码包操作
rpm --recompile $rpm_filename.rpm # 把源码包解包并编译安装
rpm --rebuild $rpm_filename.rpm # 在安装完成后把编译后的可执行文件重新打包(亲测用不了,可能是版本问题?)

command options

-q query

-l list lists the list of files in the package and the directory where the software is installed

-i info view information

-f file to see which package has this file

-p package Query the package information that is not installed (it seems to be generally omitted)

-R requires Query the dependencies of the rpm package

-s state state includes normal, not installed, replaced

--scripts View installation scripts

-c query configuration file

-d Query the installation location

-ivh install–verbose–hash install and show progress

--test combined with -ivh --test to check dependencies, not real installation

--relocate /=/opt specifies the root directory of the installation

--replacepkg force install whether it is already installed or not

--nodeps ignore dependencies, force install

--force force install regardless of package and file conflicts

-e erase wholesale

- Uvh upgrade

--oldpackage combined with -Uvh --oldpackage downgrade new version to old version

rpmrebuild

# 抽取包文件为cpio格式(类似解压)
rpm2cpio $rpm_filename.rpm | cpio -div

# 提取rpm包的spec文件
rpm -e -p $rpm_filename.rpm

Backup installed rpm packages

There are two options for file changes: 1. The file has been changed, whether to continue 2. Whether to specify a new version number

-bb batch skip option

-ba additional is the self-incrementing version number

-e open spec editor (vim)

-e -p package is generally used to extract the spec file of the rpm package

Guess you like

Origin blog.csdn.net/q863672107/article/details/126473139