If you are a user of RedHat-based Linux distributions such as RHEL and CentOS and want to install a package with dependencies using YUM, you’re in luck! Because YUM is a default package manager for those distributions and it is designed to handle dependencies automatically during the installation of a package. In this tutorial, you’ll learn different methods to install packages with dependencies using yum. Let’s start.
Process flow chart to install YUM packages with dependencies:
[Distro Used Throughout the Tutorial: RHEL 9.2]
2 Methods to Install Package With Dependencies Using YUM
YUM stands for Yellowdog Updater, Modified which is a tool used for package management in RedHat-based Linux distributions such as RHEL, Fedora and CentOS. Actually, it is a high-level package management tool that can handle dependencies automatically during the installation of a package. In this tutorial, I’ll show you two basic methods of installing a package with dependencies using YUM.
Method 01: Using YUM/Yumdownloader in CLI to Install Packages With Dependencies
YUM and Yumdownloader are two related CLI (Command Line Interface) utilities used in Red Hat-based Linux distributions for package management. YUM is primarily used for installing, updating, and removing software packages. On the other hand, Yumdownloader is a utility that focuses on downloading RPM packages from repositories, rather than installing or managing them. It allows you to download individual packages and their dependencies to a specified directory. Let’s dive into different cases regarding package installation using YUM.
Case 01: Installing Packages With Dependencies From Repository Using YUM
YUM maintains a repository of its own which is a centralized location where software packages and related metadata are stored and made available for installation. I’ll demonstrate the method of installing a package from the YUM repository. Let’s say, you want to install httpd, which is an open-source package that provides the Apache HTTP Server in your system:
- Open the RHEL/Fedora terminal.
- Type the below command:
sudo yum install -y httpd
- Enter the user password and PressENTER.The above command will install httpd with all dependencies in your RedHat.
Note: If you want to install multiple packages from YUM repository, just type the package names separated by SPACE as the following syntax:
sudo yum install <package 1> <package 2> …
For example, you can install httpd, gnome-photos, atlas using YUM by the following command:
sudo yum install httpd gnome-photos atlas
This will install all the mentioned packages one by one with their individual dependencies in your system.
Case 02: Installing Local Package With Dependencies
Sometimes, you may need to install a locally downloaded RPM file of a package with its dependencies. In that case, you can use yumdownloader to download the dependencies and yum to install the packages. I’ll demonstrate this by installing httpd locally. Follow the below steps with me:
- Open the RHEL/Fedora terminal.
- Run the below command to create and navigate to a separate directory:
mkdir ~/mypack/ cd ~/mypack/
The above pair of commands will create a directory named mypack in your home directory and then navigate to it.
- Now, type this command and press ENTER:
sudo yumdownloader --resolve httpd
- Type the user password and hit ENTER.
Note: You can use any name instead of mypack, but use the same name you choose in the later steps in this method.
- Run this command to view the downloaded dependency packages:
The red-coloured packages are the dependencies of httpd downloaded by yumdownloader.
- Now, run the below command to install the package with all its dependencies:
sudo rpm -ivh *.rpm
- Type the user password and hit ENTER.The above command will install all the downloaded dependency packages one by one.
Method 02: Using GNOME Software Environment GUI to Install
RedHat-based Linux distributions such as CentOS, Fedora, and Red Hat Enterprise Linux (RHEL) provide Graphical User Interface (GUI) package management tools. The primary GUI package management tool used in these distributions is GNOME Software which is also shortly known as “Software”. Typically, GNOME uses the yum package manager for package installation and management on CentOS and RHEL systems. So, like YUM, you can also use GNOME Software to install a package with dependencies. To learn how to use it, follow the below steps:
- Open the RHEL/Fedora terminal.
- Run this command to launch GNOME Software;
- Click on the search icon and type the package name you want to install.Also, you can explore available packages from Explore section.
- Click on the chosen package.
- Click on the Install button.After some time, GNOME Software will install CopyQ with dependencies using YUM in the backend.
I’ve shown two ways to install packages with dependencies using YUM in RHEL. You might be confused to decide which one suits you the best. Here’s a comparison between the methods provided to give you an overview of the pros and cons.
If you are comfortable with CLI or want to use different versions of software which is not provided by default GNOME Software, you should choose Method 1. On the other hand, if you are a beginner and want to use the basic software provided by the Software Center of your RHEL, no need to go with the command kinds of stuff, rather you should use Method 2.
Common Challenges That May Arise in Installing YUM Packages With Dependencies
YUM is a high-level package management tool that is advanced enough to handle dependency issues automatically. But still, when installing packages with dependencies using YUM, you may encounter some common challenges. Here are these challenges and ways to address them:
Challenge: Sometimes, the required repositories that contain the necessary dependencies may not be configured or enabled on your system.
Solution: You can use yum-config-manager or manually edit the repository configuration files in the
/etc/yum.repos.d/ directory. After configuring, enable the repositories by setting “enabled=1”.
B. Conflicting Package Versions
Challenge: You may encounter conflicts when trying to install packages with different versions or when packages from different repositories have the same name.
Solution: Use the “yum versionlock” plugin to lock a specific version of a package to prevent conflicts. Additionally, prioritize repositories using the “priority” attribute in repository configurations.
C. Corrupted Package Cache
Challenge: A corrupted (outdated) package cache may cause issues during installation.
Solution: Clear the cache using the
yum clean all command. This will remove cached metadata and force yum to fetch updated information from repositories.
D. Disk space constraints
Challenge: Insufficient disk space can prevent package installation, especially when downloading large dependencies.
Solution: Check your disk space using the df command and consider freeing up space system storage if necessary.
YUM and yumdownloader are two package management tool that simplifies the installation, updating and management of software packages with automatic dependency resolution on RedHat-based Linux systems. Moreover, you may encounter its successor, dnf, which is a more recent version package management tool of these distributions. I suggest you always use the latest versions of yum and keep your repository up to date to avoid complex challenges.
People Also Ask
- How To Check Package Dependencies in Linux [3 Easy Ways]
- How to Install Dependencies Using dpkg? [Easiest Solution]
- How to Install Missing Dependencies in Ubuntu? [4 Methods]
- Install Dependencies Automatically in Ubuntu [3 Exclusive Methods]
- 5 Methods to Remove Package and Dependencies in Ubuntu
- How to Install RPM Package With Dependencies? [3 Methods]
- 2 Ways to Install RPM Without Dependencies in Linux
- How to Check RPM Reverse Dependencies in Linux? [4 Methods]
- [Solved] RPM Failed Dependencies Error in RedHat
- Remove Packages without Dependencies Using Yum [2 Methods]
- [Solved] The Following Packages Have Unmet Dependencies Error
- How to Check APT Dependency Tree in Linux? [4 Methods]