Installing packages via Yum, RPM & DNF in CentOS
Working in a CentOS development environment can be a fun experience. When it comes to installing software in a Linux environment, it will not be as easy as the software installation process in Windows. It takes a while to understand and get used to it. In this blog, we will be learning how to install packages in CentOS.
CentOS distribution is an open-source Red Hat-based Linux distribution. The common way to install software on CentOS is to use a package manager. Red Hat Package Management (RPM) system is the packaging system used by CentOS. We use RPM to install, uninstall, upgrade, list, and check .rpm-based packages. The .rpm Linux files are used to install software applications in any RedHat-based Linux OS, similar to .exe files in Windows.
There are a few ways to install RPM package on CentOS.
- Install via YUM
YUM (Yellow Dog Updater, Modified) is a front-end tool that uses the RPM package manager to install software in your CentOS operating systems with root permissions. We can use Yum to search, fetch packages from official or third-party repositories, also update installed packages to the latest available version. Some things I like about Yum are its ease of use, automatic installation of all available dependent libraries, and package updates.
When you install a package via Yum, e.g. sudo yum install wireshark
, it will check for the existing yum repository files (ended with .repo
format) in /etc/yum.repos.d/
directory to retrieve the required information to download and install new software.
During the software installation on CentOS 7.x.x, I encountered a problem where the specific software package version available is too old… So, I have to build & install the software from source. Anyways, let’s move on to the second method to install a package in CentOS.
2. Install via rpm
I have been using yum to install software packages in CentOS, but only install via rpm occasionally when the packages are not available in the yum repository or sometimes I can’t access the yum repository due to network or working in an air-gapped environment.
rpm is a low-level tool for RPM pacakges’ installation, removal, upgrade, query, and verification. You can install an RPM package using the following command(e.g. sudo rpm -i wireshark-3.4.10-1.el9.x86_64.rpm
, which can be downloaded from here. Check your Linux kernel version & CentOS version to select the right .rpm file). If you want to show the verbose output and hash marked progress bar, change the -i
to -ivh
( v
means verbose, h
means hash).
You can also install straightly from the binary package mirror link found in pkgs.org: sudo rpm -ivh http://mirror.centos.org/centos/7/os/x86_64/Packages/xxxxx.x86_64.rpm
rpm will only display a list of missing dependencies, instead of automatically resolving them for you. Therefore, you will have to download and install all the required dependencies manually… If you want to make rpm auto-install dependencies, this link might be able to help you.
3. Install via DNF
DNF (Dandified Yum) is a software package manager for RPM-based Linux distributions, and it is the next major version of YUM. For the newer CentOS versions (e.g., CentOS 8), their default package manager will become DNF instead of YUM, since DNF comes along with improvement and more robust features. Some of the DNF commands are pretty similar to YUM, for example sudo dnf install wireshark
To get yourself familiarized with Linux OS, the best way is to switch your working environment from Windows to Linux and use it daily. You will definitely get more comfortable with Linux!