2 Methods to Install YUM Packages With Dependencies

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:2 methods to install dependencies using yum

[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.

You can read our Comparative Analysis of Methods to distinguish between these two methods and pick the best one for your needs.

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:

  1. Open the RHEL/Fedora terminal.
  2. Type the below command:
    sudo yum install -y httpd
    EXPLANATION
    • sudo: Enables administrative permissions.
    • yum: Calls yum package management tool.
    • install: Command to install a package using yum.
    • -y: Answers YES to all confirmation prompts.
    • httpd: Name of the package.
  3. Enter the user password and PressENTER.installing httpd package with dependencies using yumThe 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

installing multiple package with dependencies using yumThis 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:

  1. Open the RHEL/Fedora terminal.
  2. Run the below command to create and navigate to a separate directory:
    mkdir ~/mypack/
    
    cd ~/mypack/
    EXPLANATION
    • mkdir: Command to create a directory.
    • cd: Command to Change Directory.
    • ~/mypack/: Directory name which I’ve chosen to download the packages.

    created and navigated to mypack directoryThe above pair of commands will create a directory named mypack in your home directory and then navigate to it.

  3. Now, type this command and press ENTER:
    sudo yumdownloader --resolve httpd
    EXPLANATION
    • sudo: Enables administrative permission.
    • yumdownloader: Command-line utility used for downloading RPM packages from YUM repositories.
    • –resolve: This option instructs yumdownloader to resolve and download not only the specified package (“httpd”) but also all its dependencies.
    • httpd: Name of the package.
  4.  Type the user password and hit ENTER.downloading all dependencies using yumdownloader

    Note: You can use any name instead of mypack, but use the same name you choose in the later steps in this method.

  5. Run this command to view the downloaded dependency packages:
    ls ~/mypack/
    EXPLANATION
    • ls: Lists all files and folders in the current directory.
    • ~/mypack/: Absolute path of the folder where all the dependencies were downloaded.

    list of the downloaded dependency packagesThe red-coloured packages are the dependencies of httpd downloaded by yumdownloader.

  6. Now, run the below command to install the package with all its dependencies:
    sudo rpm -ivh *.rpm
    EXPLANATION
    • rpm: Lists all files and folders in the current directory.
    • -ivh: Combined options that indicate the following:
    Option Meaning
    -i Option to install a package using rpm.
    -v This option is used for verbose (detailed information about the installation process) output.
    -h Displays a progress bar as a series of hash (#) symbols during the installation.
    • *.rpm: Indicates every file in the current directory which has .rpm
  7. Type the user password and hit ENTER.installing package with all dependencies using rpmThe 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:

  1. Open the RHEL/Fedora terminal.
  2. Run this command to launch GNOME Software;
    gnome-software
  3. Click on the search icon and type the package name you want to install.searching copyQ package in GNOMEAlso, you can explore available packages from Explore section.
  4. Click on the chosen package.
  5. Click on the Install button.Installing copyQ from GNOMEAfter some time, GNOME Software will install CopyQ with dependencies using YUM in the backend.

Comparative Analysis of Methods to Install YUM Packages With Dependencies

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.

Methods Pros Cons
Method 1
  • Has the option to install some specific dependency packages as you need unlike installing all dependencies.
  • Allows to download packages without installing them.
  • Use online repositories with advanced package management that ensures automatic resolution of dependencies.
  • May look uneasy for beginners unfamiliar with CLI.
  • Repository configuration can be a trouble when you try to install software from third-party repository.
Method 2
  • Provides a GUI-based solution that is suitable for beginners.
  • Hides backend complexity when installing dependencies.
  • Useful in creating a local repository for package distribution or offline installations.
  • Not all package is available for installation.
  • Doesn’t provide an option to install some specific dependency packages.

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:

A. Missing or Unavailable Repositories

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.

Conclusion

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

Does yum install dependencies?
Yes, YUM (Yellodog Updater, Modified) is a high-level package management tool for RedHat-based Linux distributions that can install dependencies automatically. The command for installing a package with all its dependencies using apt is sudo yum install <package name>. Use the actual name of the package instead of <package name> in the mentioned command.
How to install package with dependencies?
In RedHat-based system, using yum or dnf is the best choice to install packages with dependencies, The syntax is sudo yum install <package name> or sudo dnf install <package name>. In case you are in Debian-based system, apt is the package manager for this purpose with the syntax sudo apt install <package name>.
How to install all RPM dependencies?
You can install all RPM dependencies using yum if you know the RPM package name with the command sudo yum install <package name>. Another way is to download all the dependency packages first and then install it. To download, use this command: sudo yumdownloader <package name>. Then use sudo rpm -ivh *.rpm to install all rpm files of dependencies.
Which yum command is used to install a package with all dependencies?
The command for installing a package with all dependencies using yum is sudo yum install <package name>. You have to replace the <package name> with the actual name of the package you want to install.

Related Articles

<< Go Back to Dependencies in Linux | Package Management in Linux | Learn Linux Basics

4.9/5 - (7 votes)
Ashikur Rahman

Hello, I’m Ashikur Rahman, currently working as a Linux Content Developer Executive at SOFTEKO. I have completed my graduation in Computer Science and Engineering from Khulna University of Engineering & Technology (KUET). Also, I’m pursuing my master’s in the same department at Bangladesh University of Engineering & Technology (BUET). I like to learn new technologies, contribute, and share those with others. Here my goal is to provide beneficial and user-friendly articles on Linux distribution for everyone. Read Full Bio

Leave a Comment