• 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. Determining disk usage in Linux using “du” command
  2. How to Install Mokutil package on CentOS/RHEL 7 and 8
  3. How to check failed or bad login attempts in Linux
  4. Auditd Messages Are Filling Up /var/log/messages
  5. How To Force User/Group Ownership Of Files On A Samba Share
  6. CentOS / RHEL 7 : How to recover from deleted root entry in /etc/shadow and/or /etc/passwd files
  7. dumpe2fs Command Examples in Linux
  8. lynis: command not found
  9. How to Disable or set SELinux to Permissive mode
  10. aspell Command Examples in Linux

You May Also Like

Primary Sidebar

Recent Posts

  • ncat Command Examples in Linux
  • ncat: command not found
  • nautilus Command Examples in Linux
  • namei: command not found

© 2023 · The Geek Diary

  • Archives
  • Contact Us
  • Copyright