Jannah Theme License is not validated, Go to the theme options page to validate the license, You need a single license for each domain name.
DevOps

rpm Command: Syntax, Options, Examples

Introduction

The RPM command is a vital tool for administering software packages on Linux systems. This tool is central to package management on Linux, especially for enterprise and server environments. This blog will explore the rpm command in Linux, providing a detailed look at its syntax, various options, and real-world examples. You will get to understand how to use the rpm command to manage RPM files, ensuring efficient rpm package management on your system. Whether you are new to Linux or looking to refine your skills, you’ll find practical guidance and examples here.

What is RPM?

What is RPM?

RPM, short for Red Hat Package Manager, is a powerful package management tool used to install, upgrade, and discard software packages on Linux. An RPM file consists all the significant files, libraries, and metadata needed to install a particular program or application. These RPM packages simplify software distribution and maintenance, making it easy to manage software on Linux systems. When you run the rpm command, it reads the RPM file to install or manage software. If you’re using Linux, especially Red Hat or its derivatives, understanding what RPM is and how it works is crucial for handling system software.

rpm Command Syntax

The basic syntax for the rpm command in Linux is straightforward. It follows this structure:

rpm [options] [package_name]

Here, [options] represent the specific actions you want to perform, such as installing or querying a RPM package. The [package_name] is the RPM file you are managing. By using various options, you can control what you do with the rpm package. For example, you can install, update, or delete an RPM package in Linux. The command is highly flexible, making it a core part of RPM package management.

rpm Command Options

rpm Command Options

The rpm command offers a range of powerful options to manage RPM packages in Linux. These options allow you to install, upgrade, query, and even delete packages efficiently. Here’s a detailed breakdown:

  • -i – Installs a new RPM package. This is the most basic option for adding software rpm files to your Linux system.
  • -U – Upgrades an existing RPM package or installs it in the situation it is not already installed. This is useful for keeping software updated.
  • -e – Deletes (removes) an installed RPM package. Use this option when you want to completely remove a program or service from Linux.
  • -v – Shows verbose output. When you use this with other rpm commands, it provides detailed information about what’s happening during the process.
  • -q – Queries the system for information about RPM packages. You can see details like the package version, release number, and description.
  • -l – Lists all files that are installed by a specific rpm file in Linux. This is helpful when you need to know exactly what files are part of a package.
  • –test – Tests a command without actually making changes. It’s a dry run to check if the action will succeed without affecting the system.
  • -V – Verifies an installed RPM package to ensure its files haven’t been altered. This is efficient for verifying the integrity of packages after installation.
  • -f – Finds out which RPM package a particular file belongs to. This option is effective when you possess a file but are unsure which package it came from.
  • –force – Forces the installation or upgrade of an RPM package, even if it conflicts with another package or is already installed. Employ this with caution, as it can overwrite important files.
  • –nodeps – Ignores dependency checks during installation or removal of an RPM package. This can be risky, as it may leave your system with destructed dependencies.
  • –rebuilddb – Rebuilds the RPM database. If your RPM database is corrupted, this command can help restore it.

rpm Command Examples

Here are some practical instances of the rpm command in Linux. These commands help manage rpm packages efficiently, whether you’re installing, upgrading, or removing software on your system.

Install an RPM Package:

rpm -i package_name.rpm

This installs the specified RPM file on your system. It’s the most basic way to add new software using RPM on Linux.

Upgrade an RPM Package:

rpm -U package_name.rpm

This upgrades an existing rpm package or installs it if it’s not yet installed. It’s useful for keeping software rpm up-to-date.

Delete an RPM Package:

rpm -e package_name

This removes the specified RPM package from your system. Use this to clean up unused rpm packages or troubleshoot issues.

Query Installed Packages:

rpm -qa

This lists all installed rpm packages on your system. It’s a quick way to see what RPM packages are already installed.

Check for Package Info:

rpm -qi package_name

This queries detailed information about a specific RPM package. It provides data like version, description, and release details.

List Files in an RPM Package:

rpm -ql package_name

This lists all the files installed by a specific rpm package. It’s helpful when you need to know where files from a RPM file are located.

Check if a File Belongs to an RPM Package:

rpm -qf /path/to/file

This command tells you which rpm package a specific file belongs to. Use it when you’re unsure which software rpm installed a certain file.

Verify Installed RPM Packages:

rpm -V package_name

This verifies the integrity of an installed rpm package. It checks if any files have been altered since installation.

Test RPM Installation Without Making Changes:

rpm --test -i package_name.rpm

This tests the installation of an RPM file without actually installing it. Useful to see if there will be conflicts or issues.

Rebuild the RPM Database:

rpm --rebuilddb

This rebuilds the RPM package database. It’s essential when the RPM database gets corrupted and needs fixing.

Where to Find and Download .rpm Packages?

Where to Find and Download .rpm Packages?

Finding and downloading .rpm packages is straightforward. Several trusted sources provide a wide range of software rpm files for Linux distributions that use RPM package management. Here are the primary places to find them:

  1. Official Linux Distribution Repositories
    The safest way to get RPM packages is from the official repositories of rpm-based Linux distributions like Fedora, CentOS, RHEL, and openSUSE. These repositories host RPM packages that are verified, tested, and optimized for your specific Linux version. You can use the package manager (e.g., dnf, yum, or zypper) to download and install packages directly from the repository. This ensures security and compatibility.
  2. RPM Fusion
    RPM Fusion is a popular third-party repository that provides additional rpm packages for Fedora and RHEL-based distributions. It offers free and non-free RPM software that is not accessible in the official repositories. You can add RPM Fusion to your system and easily download RPM packages.
  3. Software Vendor Websites
    Many software vendors provide .rpm packages directly on their websites. Popular applications like Google Chrome, Visual Studio Code, and Oracle Java offer RPM files for Linux users. Always make sure that you’re downloading from the official website to avoid malicious software.
  4. rpmfind.net
    This site is a searchable index for finding RPM packages. You can search by package name, version, or distribution to find the right rpm file for your needs. It’s widely used to find specific versions of rpm packages not available in repositories.
  5. Koji Build System
    Koji is Fedora’s build system and is an excellent source for Fedora RPM packages. You can download both stable releases and build versions of software rpm files. It is generally employed by developers and advanced users for accessing the latest builds.
  6. Open Build Service (OBS)
    Hosted by openSUSE, OBS provides an easy way to find RPM packages for multiple Linux distributions, including Fedora and CentOS. It’s a collaborative platform where developers can build and distribute RPM files for different distributions.
  7. Community Forums and Developer Sites
    Some niche or less mainstream software may provide .rpm packages on community forums or project-specific websites. Examples include GitHub or GitLab repositories where developers upload RPM files for public use. Always check the integrity of such files.

Also Read: RPM Installation on Linux: Troubleshooting and Solutions

Conclusion

The rpm command provides a robust way to manage software RPM packages on Linux systems. From simple installation and upgrades to querying package details and removing unnecessary files, this tool is essential for maintaining your Linux rpm environment. With its several choices & flexibility, it offers full control over rpm package management. By learning the syntax and key commands, you can easily handle all aspects of RPM packages in Linux—ensuring your system stays up-to-date, clean, and functional.

Arpit Saini

He is the Director of Cloud Operations at Serverwala and also follows a passion to break complex tech topics into practical and easy-to-understand articles. He loves to write about Web Hosting, Software, Virtualization, Cloud Computing, and much more.

Related Articles