sodcalculator

10 Tech How-To

Install RPM Packages on CentOS Linux

Guide 10-24070 · Updated · Step by step

This guide walks you through installing RPM packages on CentOS Linux, covering both graphical and command-line methods. RPM (Red Hat Package Manager) is the core package format for CentOS, and you’ll learn how to use yum, dnf, and the rpm command itself to install software from local files or repositories. You’ll also see how to handle dependencies and avoid common pitfalls.

What You’ll Need

  • A CentOS system (7, 8, or 9) with an active internet connection if you plan to download packages or use repositories.
  • Root or sudo access to install system-wide packages.
  • An RPM file (ends with .rpm) if you’re installing locally. You can download these from official project sites or trusted mirrors.
  • Basic comfort with the terminal, though a graphical option is also covered.

Step-by-Step

  1. Check your CentOS version – Run cat /etc/centos-release or hostnamectl to know whether you’re on CentOS 7 (uses yum), CentOS 8/9 (uses dnf, but yum is aliased). This determines which commands you’ll use.
  2. Update your system (recommended) – Before installing anything, run sudo yum update (or sudo dnf update on 8/9) to refresh the package cache and patch existing software. This reduces dependency conflicts.
  3. Install from a repository (easiest) – If the package is in the default repos, simply run sudo yum install package-name (or sudo dnf install package-name). Replace package-name with the actual name, e.g., sudo yum install httpd for Apache. The tool resolves and installs dependencies automatically.
  4. Install a local RPM file – Navigate to the directory containing the .rpm file, then run sudo yum localinstall ./package.rpm (CentOS 7) or sudo dnf install ./package.rpm (CentOS 8/9). Using yum/dnf is preferred because it pulls dependencies from repositories.
  5. Install with the raw rpm command (if necessary) – If you must use rpm directly, run sudo rpm -ivh package.rpm. The flags: -i install, -v verbose, -h show hash progress. This does not resolve dependencies, so only use it when you’re sure all dependencies are present.
  6. Handle dependencies manually (if needed) – If rpm reports missing dependencies, you can download them from the same source or enable the EPEL (Extra Packages for Enterprise Linux) repository. For example, on CentOS 8: sudo dnf install epel-release, then retry the install.
  7. Verify the installation – After installation, check the package is present with rpm -q package-name or yum list installed | grep package-name. To see files installed, use rpm -ql package-name.
  8. Run the software – Many packages add a systemd service. Start it with sudo systemctl start service-name and enable it to start on boot with sudo systemctl enable service-name. For command-line tools, just type the command name.

Common Mistakes

  • Using rpm -i without dependencies – This often fails with “failed dependencies” errors. Always prefer yum/dnf when possible.
  • Downloading from untrusted sources – RPMs from random websites can be malicious or incompatible. Stick to official project sites, CentOS repos, or well-known third-party repos like EPEL.
  • Ignoring architecture – A 64-bit (x86_64) RPM won’t install on a 32-bit (i686) system, and vice versa. Check with uname -m.
  • Forgetting to use sudo – Installing system-wide requires root. Without sudo, you’ll get permission denied errors.
  • Mixing package managers – Don’t use rpm to install packages that were meant for dnf, as it can bypass the dependency database and leave your system inconsistent.

Tips

  • Use yum provides or dnf provides – If you’re not sure which package contains a file, run sudo yum provides /path/to/file to find it.
  • Enable EPEL for extra software – Many useful packages are not in the default repos. Install epel-release first, then you can install those packages normally.
  • Check for updates regularly – Run sudo yum update periodically to get security patches and bug fixes for your installed RPMs.
  • Remove packages cleanly – Use sudo yum remove package-name (or dnf remove) to uninstall, which also cleans up dependencies that are no longer needed.
  • Query before installing – Use rpm -qpi package.rpm to view information about a local RPM without installing it.

Troubleshooting

  • “Failed dependencies” error – This means the package needs other packages. If you used rpm, switch to yum localinstall or dnf install ./file.rpm. If that still fails, install the missing dependencies manually or enable the appropriate repository.
  • “Package already installed” – You might be trying to install an older or identical version. Use rpm -Uvh to upgrade, or rpm -e to remove the old one first.
  • “No package available” – The package isn’t in your enabled repositories. Search with yum search keyword or dnf search keyword. If it’s not there, you may need to add a third-party repo or download the RPM manually.
  • “Permission denied” – You forgot sudo. Prefix your command with sudo.
  • “Error: Nothing to do” – The package is already installed and up to date. Use rpm -q to confirm.
  • System becomes unstable after install – This can happen if you force-installed with --nodeps. Check for missing dependencies with rpm -Va and consider removing the package with yum remove.

Frequently Asked Questions

Can I install an RPM without root?

No, system-wide installation requires root privileges. You can use rpm --prefix to install into a user directory, but many packages assume standard paths and may not work correctly.

What’s the difference between yum and dnf?

Yum was the default package manager in CentOS 7 and earlier. DNF is the next-generation version, default in CentOS 8 and 9. DNF is faster and has better dependency resolution, but the commands are nearly identical.

How do I uninstall an RPM?

Use sudo yum remove package-name or sudo dnf remove package-name. This removes the package and any orphaned dependencies.

Is it safe to use rpm -i –nodeps?

Generally no. It bypasses dependency checks and can break your system. Only use it in rare cases where you know all dependencies are satisfied, and even then, prefer a proper package manager.

What is EPEL and why should I enable it?

EPEL (Extra Packages for Enterprise Linux) is a repository maintained by the Fedora project that provides many additional packages not in the base CentOS repos. It’s safe and widely used.

Can I install a .rpm file from a GUI?

Yes, you can double-click an RPM file in the file manager, and the Software Center or GNOME Software will open with an install prompt. However, this method is less reliable for dependency resolution, so the command line is recommended.

Related

General steps for current mainstream versions; menus can differ by device and version. See the disclaimer or report an error.

More in this bed

The whole Tech How-To bed →