Small knowledge, big challenge! This article is participating in the creation activity of “Essential Tips for Programmers”.

RPM provides powerful query operations, including:

  • Check whether the software package has been installed.
  • Query all installed software packages in the system.
  • View details about software packages.
  • Query the file list of the software package (installation path).
  • Example Query the RPM package to which a system file belongs.

RPM -q: queries whether the software package is installed and the full name of the package

RPM -q Query whether the software package is installed and the full name of the installed package.

– q | — query: the query execution.

The package name is used here, not the full package name. (Installed software, using the full name of the package is not recognized)

$ rpm -q mysql80-community-release
mysql80-community-release-el7-3.noarch
Copy the code
# rpm -q httpdHTTPD - 2.4.6-95. El7. Centos. X86_64. RPMCopy the code

RPM -qa: Queries all installed software packages

RPM -qa: Queries all installed software packages in Linux.

– a | – all: query all of the packages.

# rpm -qaLibgusb 0.2.9-1. El7. X86_64 gnome - disk utility - 3.28.3-1. El7. X86_64 it - 6.18.01-13. El7_3. 1. X86_64 Gnome - bluetooth - libs - 3.28.2-1. El7. X86_64 libappstream - glib - 0.7.8-2. El7. X86_64 libXdmcp - 1.1.2-6. El7. X86_64 Khmeros - base - fonts - 5.0-17. El7. Noarch glibc -static - 2.17-157 el7_3. 2. I686 gstreamer plugins - bad - free - 0.10.23-23. El7. X86_64 Wayland - devel - 1.15.0-1. El7. X86_64 sed - 4.2.2-5. El7. X86_64 python - gobject - 3.22.0-1. El7_4. 1. X86_64 ModemManager 1.6.10-1. El7. X86_64 python - backports - ssl_match_hostname 3.4.0.2-4. El7. Noarch The gnome keyring - PAM - 3.28.2-1. El7. X86_64 cronie 1.4.11-14. El7_2. 1. X86_64 qemu - img - 1.5.3-160. El7_6. 2. X86_64...# omit
Copy the code

RPM -qa finds the specified software by pipe character combined with grep (fuzzy query)

RPM -qa uses the pipe character and grep to find the specified software package.

Mysql > select * from mysql;

# rpm -qa | grep mysqlMysql - community - the client - 8.0.26-1. El7. X86_64 mysql - community - common - 8.0.26-1. El7. X86_64 Mysql80 - community - release - el7-3. Noarch mysql - community - libs - 8.0.26-1. El7. X86_64 Mysql - community - the client - plugins - 8.0.26-1. El7. X86_64 mysql - community - server - 8.0.26-1. El7. X86_64Copy the code

RPM -qpl: Queries the default installation path of the software package

To query the installation path of a specified package:

# RPM - QPL mysql - community - server - 8.0.26-1. El7. X86_64. RPM
Copy the code

The following package name is the full package name.

  • -p|--packageIndicates a query for a specified package, especially one that is not installed. If a package is not installed, it is not specified-pYou will be prompted that it is not installed.

RPM -ql: Command to query the file list of the software package

By default, the RPM software package installs each installation file in an appropriate directory.

RPM -ql : Query all files in the installed software package and their installation paths.

This is the package name, not the full package name.

  • -l|--list: lists all files in the software package and their installation paths.

For example, query all files in apache (HTTPD) package and their installation location:

rpm -ql httpd
Copy the code

RPM -qi: Queries detailed information about the software package

RPM -qi : queries details about the software package.

-i | – info option information query software.

Similarly, you can run the -p, RPM -qip command to query details about a specified package.

# RPM - qip mysql - community - server - 8.0.26-1. El7. X86_64. RPMName: mysql-community-server Version: 8.0.26 Release: 1.el7 Architecture: x86_64 Install Date: (not installed) Group : Applications/Databases Size : 2212303102 License : Copyright (c) 2000, 2021, Oracle and/or its affiliates. Under GPLv2 license as showninthe Description field. Signature : DSA/SHA256, Fri 02 Jul 2021 02:50:54 AM CST, Key ID 8c718d3b5072e1f5 Source RPM : RPM Build Date: Thu 01 Jul 2021 04:54:44 PM CST Build Host: pb2-el7-14.appad3iad.mysql2iad.oraclevcn.com Relocations : (not relocatable) Packager : MySQL Release Engineering <[email protected]> Vendor : Oracle and/or its affiliates URL : http://www.mysql.com/ Summary : A very fast and reliable SQL database server Description : The MySQL(TM) software delivers a very fast, multi-threaded, multi-user, and robust SQL (Structured Query Language) database server. MySQL Server is intendedfor mission-critical, heavy-load production systems as well
as for embedding into mass-deployed software. MySQL is a trademark of
Oracle and/or its affiliates

The MySQL software has Dual Licensing, whichmeans you can use the MySQL software free of charge under the GNU General Public License (http://www.gnu.org/licenses/).  You can also purchase commercial MySQL licenses from Oracle and/or its affiliatesif you do not wish to be bound by the terms of
the GPL. See the chapter "Licensing and Support" in the manual for
further info.

The MySQL web site (http://www.mysql.com/) provides the latest news and
information about the MySQL software.  Also please see the documentation
and the manual for more information.

This package includes the MySQL server binary as well as related utilities
to run and administer a MySQL server.
Copy the code

Run the RPM -qf command to query the RPM package to which the system file belongs

You can run the RPM -qf

command to query the RPM package to which a file belongs.

– f | – file: represents the file.

This command can be used only for files installed using RPM packages.

Query the file corresponding to the ls command and its software package.

# which ls
alias ls='ls --color=auto'
        /usr/bin/ls
# rpm -qf /usr/bin/lsCoreutils - 8.22-18. El7. X86_64Copy the code

RPM -qr: Queries the dependencies of software packages

rpm -qR <package_name>Used to query other packages that an installed software package depends on.

– R | – the requires: query package dependency.

Similarly, add the -p command to find dependencies for a specified package.

Mysql - community - server - # RPM - qpR 8.0.26-1. El7. X86_64. RPM/bin/bash/bin/sh/bin/sh/bin/sh/bin/sh/bin/sh /usr/bin/perl config(mysql-community-server) = 8.0.26-1. El7 coreutils grep Ld - Linux - x86-64. So. 2 (a) (64 - bit) ld - Linux - x86-64. So, 2 (GLIBC_2. 3) (64 - bit) libaio. So. 1 (a) (64 - bit) libaio. So. 1 (LIBAIO_0. 1) (64 - bit) Libaio. So. 1 (LIBAIO_0. 4) (64 - bit) libc. So. 6 () (64 - bit) libc. So. 6 (GLIBC_2. 10) (64 - bit)...# omit
Copy the code

reference

Linux RPM command to query software packages (-q, -qa, -i, -p, -l, -f, -r)