• 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

12 RPM (Red Hat Package Manager) Command Examples

by admin

RPM is an open-source Package Manager on Linux Like Operating systems (RHEL, CentOS & Fedora).RPM command is used to build, install, query, verify, update and erase individual software packages. RPM utility only works with packages that are built on .rpm format. An RPM file contains not only the software files but also in-depth information about the software, such as what it’s called, when it was released, what changes have been made, and what other packages it depends on to work.

The Local RPM database is maintained in /var/lib/rpm. The database stores information about installed packages such as file attributes and package prerequisites.

RPM file Formart:

name-version-release.architecture.rpm

Where version refers to the open-source version of the project, while the release refers to the Red Hat internals patches to the open-source code. The architecture shows the information about architecture (32 bit or 64 bit). rpm is a backend for other programs such as yum or system-config-packages. These tools provide significant advantages such as automatic dependency resolution.

Syntax:

# rpm [options] [rpmfile]

Primary RPM Options:

  • Install: rpm -i, –install
  • Upgrade: rpm -U, –upgrade
  • Freshen: rpm -F, –freshen
  • Erase: rpm -e, –erase
  • Query: rpm -q, –query
  • output options: -v, -h

Example 1: Installing the RPM Package.

# rpm -ivh  vim-enhanced-7.2.411-1.8.el6.x86_64.rpm
Preparing...                ########################################### [100%]
1:vim-enhanced           ########################################### [100%]

Where:
-i: install a package
-v: verbose output
-h: print hash marks as the package archive is unpacked.

Example 2: Installing rpm packages without dependencies.

# rpm -ivh --nodeps vim-enhanced-7.2.411-1.8.el6.x86_64.rpm

Example 3: Remove / erase rpm package.

# rpm -ev vim-enhanced

Example 4: Upgrade RPM package using -U and -F options.
rpm can be used to upgrade already installed software with -U (–upgrade) command-line option, When upgrading, the original package(with the exception of configuration files ) on the system will be removed and a new package installed. Configuration files from the original installation are saved with a “.rpmsave” extension.

Freshening is almost identical to upgrading, except when the package specified on the command line is not already installed on the system. When upgrading with -U, the package will be installed whether or not it is already installed. But in case of freshening, the package will be ignored if not already installed.

Syntax:

# rpm -Uvh [rpm-file]

Example:

# rpm -Uvh mozilla-mail-1.7.6-12.i586.rpm

Syntax:

# rpm -Fvh [rpm-file]

Example:

# rpm -Fvh mozilla-mail-1.7.6-12.i586.rpm

Example 5: Display all installed packages.

# rpm -qa 
# rpm -qa | less

Example 6: Display list of configuration file(s) for a package.

Syntax:

# rpm -qc [package-name]

rpm -qc command example Linux

Example 7: Find out what package a file belongs to OR find what package owns the file.

# rpm -qf [/path/to/file]

Example 8: Display the information of installed package : version & Description.

# rpm -qi [package name]

rpm -qi display rpm information Linux

Example 9: Display the list of all recently installed RPMs.

# rpm -qa --last 
# rpm -qa --last | less

Example 10: Check the dependencies of an rpm file before installation.

# rpm -qpR  [.rpm-file]

where:
-q: Query a package.
-p: List capabilities this package provides.
-R: List capabilities on which this package depends.

rpm -qrp check rpm dependencies Linux

Example 11: Verify a RPM Package.
Verifying a package means compares the information of installed files of the package against the rpm database. The -Vp (verify package) is used to verify a package.

# rpm -Vp vim-enhanced-7.2.411-1.8.el6.x86_64.rpm

To Verify all rpm packages:

# rpm -Va

Example 12: Import RPM GPG keys.
To verify RHEL/CentOS rpm packages, first, we must import the GPG key, to import the key use the below command. It will import CentOS 6 GPG key.

# rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6

Filed Under: CentOS/RHEL, Linux, Oracle Linux, Ubuntu

Some more articles you might also be interested in …

  1. unzip: command not found
  2. “Read-only locking type set. Write locks are prohibited. Can’t get lock for [volume group]” – error during lvextend
  3. How to Create logical networks to segregate traffic in a data center in RedHat Virtualization (RHV)
  4. How to Restart Network Services in CentOS/RHEL 8
  5. i3lock: command not found
  6. How to Verify if a Disk/Partition is in Use by Oracle ASM, was used by Oracle ASM or is never used by Oracle ASM
  7. understanding “yum history” command output
  8. netcat Command Examples in Linux
  9. as: command not found
  10. How To Disable Or Extend System Logging Rate-limit on CentOS/RHEL 6

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