Linux Tutorial

Linux File/Directory Management

Linux Packaging And Compression

Vim Text Editor

Linux Text Processing

Linux Software Installation

Linux User/User Group Management

Linux Permission Management

Linux Filesystem Management

Linux Advanced Filesystem Management

Linux System Management

Linux Backup and Recovery

Linux System Service Management

Linux System Log Management

Linux Boot Management

LAMP/LNMP Environment

SELinux Management

Linux rpm Command To Query Packages (-q, -qa, -i, -p, -l, -f, -R)

The rpm command in Linux provides several options for querying packages, which allows you to access information about installed and uninstalled packages. In this tutorial, we will discuss the -q (query) option, along with various flags that can be used in conjunction with it.

  • -q, --query: Query an installed package

The -q option is used to query information about an installed package. The basic syntax for querying an installed package is:

rpm -q PACKAGE_NAME

For example, to query information about the 'wget' package, run:

rpm -q wget
  • -qa, --query --all: List all installed packages

The -qa option lists all installed packages on your system:

rpm -qa
  • -qi, --query --info: Display package information

To show detailed information about an installed package, use the -qi option:

rpm -qi PACKAGE_NAME

For example, to display information about the 'wget' package, run:

rpm -qi wget
  • -qp, --query --package: Query an uninstalled package file

To query an uninstalled package file, use the -qp option:

rpm -qp PACKAGE_FILE.rpm

For example, to query an uninstalled package file 'example-package.rpm', run:

rpm -qp example-package.rpm
  • -ql, --query --list: List files in a package

To list all files included in an installed package, use the -ql option:

rpm -ql PACKAGE_NAME

To list files included in an uninstalled package file, use the -qlp option:

rpm -qlp PACKAGE_FILE.rpm
  • -qf, --query --file: Identify the package that owns a specific file

To find out which installed package a specific file belongs to, use the -qf option:

rpm -qf /path/to/file

For example, to find the package that owns the file '/bin/ls', run:

rpm -qf /bin/ls
  • -qR, --query --requires: List package dependencies

To list the dependencies of an installed package, use the -qR option:

rpm -qR PACKAGE_NAME

To list the dependencies of an uninstalled package file, use the -qRp option:

rpm -qRp PACKAGE_FILE.rpm

In summary, the rpm command provides numerous options for querying packages. By using these options, you can effectively manage and understand the packages installed on your system or the package files you want to install. For additional information on the rpm command, consult the manual with man rpm or visit the online documentation.

  1. How to use rpm -q to query installed packages in Linux: Use rpm -q to query information about installed packages. For example, to query the version of a package:

    rpm -q package_name
    
  2. Querying all installed packages with rpm -qa in Unix-like systems: List all installed packages with the -qa option. Example:

    rpm -qa
    
  3. rpm -i command for querying package information in Linux: Use rpm -i to get detailed information about an installed package. Example:

    rpm -qi package_name
    
  4. Querying package files using rpm -l in Linux: List files installed by a package with rpm -l. For example:

    rpm -ql package_name
    
  5. rpm -f command for file-based package queries in Linux: Identify the package that owns a specific file using rpm -f. Example:

    rpm -qf /path/to/file
    
  6. Using rpm -R to query package dependencies in Linux: Check the dependencies of a package with rpm -R. For example:

    rpm -qR package_name
    
  7. Querying package information from an RPM file with rpm -p: Examine information about an RPM file before installing. For example:

    rpm -qpil package.rpm
    
  8. rpm command examples for various package queries in Linux: Explore additional queries, such as querying packages by release, architecture, or license. Example:

    rpm -qa --last
    rpm -qa --queryformat "%{NAME} %{VERSION} %{RELEASE}\n"