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

The Geek Diary

CONCEPTS | BASICS | HOWTO

  • OS
    • Linux
    • CentOS/RHEL
    • Solaris
    • Oracle Linux
    • Linux Services
    • VCS
  • Database
    • oracle
    • oracle 12c
    • ASM
    • mysql
    • MariaDB
    • Data Guard
  • DevOps
    • Docker
    • Shell Scripting
  • Interview Questions
  • 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. YUM command examples to install, remove and upgrade packages
  2. Unable to Start RDMA Services on CentOS/RHEL 7
  3. How To Send Mails To an External User With Mailx on Linux
  4. Extend the size of /boot partition on virtualized environment (CentOS/RHEL 6)
  5. How to create LXC container using lxcbr0 and virbr0 in CentOS/RHEL
  6. CentOS / RHEL 7 : Enable NTP to start at boot after fresh install (disable chrony)
  7. CentOS / RHEL 7 : How to enable or disable automatic updates (via packagekit)
  8. How to configure VNC Server on Oracle Linux 6
  9. How to Disable “alt+ctrl+Del” Key Combination causing reboot in CentOS/RHEL 4,5
  10. View files using – cat, more, tail, head and wc commands

You May Also Like

Primary Sidebar

Recent Posts

  • Failed to start LSB: Bring up/down networking – On restarting network service CentOS/RHEL (DHCP client)
  • How To Add Timestamps To dmesg Kernel Boot Log in CentOS/RHEL
  • How to disable ICMP redirects on CentOS/RHEL
  • What are Oracle Key Vault Roles
  • Archives
  • Contact Us
  • Copyright

© 2021 · The Geek Diary