• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
  • Skip to footer navigation

The Geek Diary

  • OS
    • Linux
    • CentOS/RHEL
    • Solaris
    • Oracle Linux
    • VCS
  • Interview Questions
  • Database
    • oracle
    • oracle 12c
    • ASM
    • mysql
    • MariaDB
  • DevOps
    • Docker
    • Shell Scripting
  • Big Data
    • Hadoop
    • Cloudera
    • Hortonworks HDP

RPM command examples to query, install, remove and upgrade packages

by admin

All software on a Linux system is divided into packages that can be installed, uninstalled, upgraded, queried, and verified. CentOS/RHEL uses the Red Hat Package Manager (RPM) to facilitate the installation, upgrade and removal of software packages.

The rpm utility provides many useful options for querying and verifying packages, as well as installing, upgrading, and removing packages. The following provides examples of these options.

Query Packages

1. Listing all installed packages

To list all installed packages, use the following command:

# rpm -qa | more
NetworkManager-team-1.8.0-9.el7.x86_64
pyxattr-0.5.1-5.el7.x86_64
HPOvXpl-11.14.014-1.x86_64
bind-utils-9.9.4-51.el7.x86_64
pyOpenSSL-0.13.1-3.el7.x86_64
....

The format of rpm package names is name-version-release.architecture. The example shows packages for version 7 of EnterPrise Linux (el7) with architectures of either:

  • x86_64: Any AMD64 or Intel 64 CPUs
  • noarch: Any CPU architecture
  • i686: 32-bit OS

2. Display Package Information

To display detailed package information (of the bash package, for example), enter:

# rpm -ql bash
/etc/skel/.bash_logout
/etc/skel/.bash_profile
/etc/skel/.bashrc
/usr/bin/alias
/usr/bin/bash
/usr/bin/bashbug
/usr/bin/bashbug-64
/usr/bin/bg

3. Find the package from a file

To perform a reverse search, that is to determine what package a specific file (/etc/hosts, for example) belongs to, enter:

# rpm -qf /etc/hosts
setup-2.8.71-7.el7.noarch

4. Find configuration files of a package

To list configuration files associated with a package (the bash package, for example), enter:

# rpm -qc bash
/etc/skel/.bash_logout
/etc/skel/.bash_profile
/etc/skel/.bashrc

Installing and Updating Packages

1. Installing or Upgrading packages

Using the rpm -U package_name command upgrades installed packages, as well as installs
new packages. For example, to install or upgrade the rsync package:

# rpm –Uvh rsync-3.0.9-18.el7.x86_64.rpm
  • -v (verbose) option displays more information
  • -h (hash) option displays progress.

2. Installing a New Kernel

When installing a new kernel, use the –i option so as not to upgrade the current kernel, for example:

# rpm –ivh kernel-3.10.0-229.el7.x86_64.rpm

Removing Packages

To remove a package (the rsync package, for example), enter:

# rpm –e rsync

Filed Under: Linux

Some more articles you might also be interested in …

  1. acountry Command Examples in Linux
  2. KVM Virsh Command Examples on CentOS and RHEL
  3. flash Command Examples in Linux
  4. How to configure NTP to fall back to local system clock source in CentOS/RHEL
  5. What are makefiles in Linux
  6. pidof Command Examples in Linux
  7. How to Configure YUM to connect to Oracle Public Repository in Oracle Enterprise Linux
  8. fprintd Logs Messages into /var/log/messages Even If USEFPRINTD=no in /etc/sysconfig/authconfig (CentOS/RHEL 7)
  9. How to Configure Multiple MySQL Servers On One System Using mysqld_multi
  10. System Log File /var/log/messages Is Getting Deleted or Trimmed Automatically (CentOS/RHEL)

You May Also Like

Primary Sidebar

Recent Posts

  • “aws s3 mv” Command Examples
  • “aws s3 mb” Command Examples
  • “aws s3 ls” Command Examples
  • “aws s3 cp” Command Examples

© 2023 · The Geek Diary

  • Archives
  • Contact Us
  • Copyright