How To Install A Rpm Package In Linux

How To Install A Rpm Package In Linux

Reading time1 min
#Linux#OpenSource#Software#RPM#PackageManagement#Fedora

How to Install an RPM Package in Linux: A Practical Guide

Rationale:
Understanding how to install an RPM package is essential for managing software on RPM-based Linux distributions such as Fedora, CentOS, and Red Hat Enterprise Linux. This guide breaks down the process so you can confidently handle RPM files and troubleshoot common issues.

Suggested Hook:
Ever downloaded an RPM package and wondered how to install it correctly? Whether you’re setting up new software or updating existing tools, mastering RPM installation will make managing your system easier than ever.


What is an RPM Package?

An RPM (Red Hat Package Manager) package is a file format used primarily by distributions like Fedora, CentOS, and RHEL to distribute software. These packages contain the compiled software and metadata needed for installation, upgrade, or removal.


Step-by-Step Guide: Installing an RPM Package

Step 1: Download the RPM Package

You can download an RPM package using a web browser or command-line tools like wget or curl. For instance:

wget https://download.example.com/sample-package.rpm

Make sure you know where the .rpm file is saved on your system.


Step 2: Verify the Package (Optional but Recommended)

Before installing, you might want to check the integrity and details of the package:

rpm -Kv sample-package.rpm

This command verifies the package's signature and checks for corruption.

To view detailed info about the package contents without installing:

rpm -qpi sample-package.rpm

Step 3: Install Using rpm Command

The basic way to install an rpm is using:

sudo rpm -ivh sample-package.rpm

Explanation of flags:

  • -i installs the package
  • -v shows verbose output
  • -h displays a progress bar

If you want to upgrade or replace an existing version:

sudo rpm -Uvh sample-package.rpm

-U means upgrade (install if not already present).


Step 4: Handle Dependencies Smartly

One common challenge when installing with rpm directly is missing dependencies. If dependencies are unmet, you'll see error messages like:

error: Failed dependencies:
    libfoo.so.1()(64bit) is needed by sample-package-1.0.rpm

Using just rpm does not automatically resolve dependencies.


Step 5: Use yum or dnf for Easier Dependency Resolution (Recommended)

To automatically resolve dependencies during installation, use the higher-level package managers:

For RHEL/CentOS 7 and earlier:

sudo yum localinstall sample-package.rpm

For Fedora and RHEL/CentOS 8+ systems that use DNF:

sudo dnf install ./sample-package.rpm

Using yum localinstall or dnf install ./sample-package.rpm tells these managers to treat your local file as a package source and fetch any needed dependencies from configured repos automatically.


Step 6: Verify Installation

After installing, verify that your software is installed properly by querying it:

rpm -q sample-package-name

Replace sample-package-name with the actual package name (often shown during installation).

You can also check if its commands are accessible:

which sample-command
sample-command --version

Bonus Tips

  • Uninstalling: To remove a package installed via RPM:

    sudo rpm -e sample-package-name
    
  • Listing all installed packages: Helps you find exact names:

    rpm -qa | grep sample
    
  • Upgrading all system packages: Keep your OS up-to-date:

    sudo yum update          # CentOS/RHEL7 and earlier   
    sudo dnf upgrade         # Fedora/RHEL8+
    

Conclusion

Installing RPM packages manually via the rpm command gives you fine control but requires managing dependencies yourself. For hassle-free installations, leveraging yum or dnf commands is highly recommended. With this knowledge, managing your Linux software installations becomes straightforward — no more confusion when dealing with those .rpm files!

Got your own tips or questions? Drop them below in the comments!


Happy Installing! 🚀