Linux ‘yum’ Command Installation | Step-by-Step Guide

Linux ‘yum’ Command Installation | Step-by-Step Guide

Linux terminal displaying the setup of yum a command for package management in RPM-based systems

Are you looking to install the yum command on your Linux system but aren’t sure where to start? Many Linux users, particularly beginners, might find the task intimidating. Yet, yum is a powerful tool and a utility worth mastering. Installing yum will make it easy to manage packages via the Linux command line. Yum is also readily available on most package management systems, making it a straightforward process once you know-how.

In this tutorial, we will guide you on how to install the yum command on your Linux system. We will show you methods for both APT and YUM-based distributions, delve into compiling yum from source, installing a specific version, and finally, how to use the yum command and ensure it’s installed correctly.

So, let’s dive in and begin installing yum on your Linux system!

TL;DR: How Do I Install and Use the ‘yum’ Command in Linux?

The 'yum' command is typically pre-installed on most Linux distributions. You can verify this with: yum --version. However, if it’s not available on your system, particularly on CentOS and similar distributions, you can install it using the command sudo yum install yum.

sudo yum install yum

This command will install yum on your Linux system. But remember, this is just the tip of the iceberg. There’s much more to learn about installing and using yum. Continue reading for a more detailed guide, advanced installation options, and usage scenarios.

Understanding and Installing the ‘yum’ Command

The ‘yum’ command, short for Yellowdog Updater Modified, is a powerful, open-source command-line package-management utility for Linux systems using the RPM Package Manager. It automatically computes dependencies and determines the actions necessary to install packages.

Installing ‘yum’ with APT

On Debian-based distributions like Ubuntu, you might need to install the ‘yum’ utility using the Advanced Package Tool (APT). Here’s how you can do it:

sudo apt-get update
sudo apt-get install yum

# Output:
# Reading package lists... Done
# Building dependency tree
# Reading state information... Done
# The following additional packages will be installed:
#   yum-utils
# Suggested packages:
#   rpm-i18n
# The following NEW packages will be installed:
#   yum yum-utils
# 0 upgraded, 2 newly installed, 0 to remove and 0 not upgraded.
# Need to get 458 kB of archives.
# After this operation, 2,048 kB of additional disk space will be used.
# Do you want to continue? [Y/n]

This command first updates your package list and then installs yum. The terminal will display the progress and prompt you to confirm the installation. Press Y to continue.

Installing ‘yum’ with YUM

On Fedora, CentOS, and similar distributions, ‘yum’ is usually pre-installed. If not, you can install it using the yum command itself, like so:

sudo yum install yum

# Output:
# Loaded plugins: fastestmirror
# Loading mirror speeds from cached hostfile
#  * base: mirror.23media.com
#  * extras: mirror.23media.com
#  * updates: mirror.23media.com
# Resolving Dependencies
# --> Running transaction check
# ---> Package yum.noarch 0:3.4.3-167.el7.centos will be installed
# --> Finished Dependency Resolution

This command will install yum on your system. The terminal will display the progress of the installation. The ‘yum’ command is now ready to use on your Linux system.

Installing ‘yum’ from Source Code

Sometimes, you might want to install yum from its source code. This method allows you to get the latest features, bug fixes, or a specific version that might not be available in the package repositories. Here’s how to do it:

wget http://yum.baseurl.org/download/3.4/yum-3.4.3.tar.gz
tar -xvzf yum-3.4.3.tar.gz
cd yum-3.4.3
make
sudo make install

# Output:
# 'yum-3.4.3/'
# ...
# 'yum-3.4.3/yum/'
# ...
# 'make[1]: Leaving directory '/home/user/yum-3.4.3'
# make[1]: Entering directory '/home/user/yum-3.4.3'
# make[1]: Nothing to be done for 'install-exec-am'.
# ...

This series of commands first downloads the yum source code tarball, extracts it, changes the directory to the extracted folder, compiles the code, and finally installs it on your system.

Installing Specific Versions of ‘yum’

At times, you might need to install a specific version of yum. This could be due to compatibility issues, specific features, or stability considerations. Here’s how to do it with both apt and yum package managers.

Installing Specific Versions with APT

sudo apt-get install yum=3.4.3-4

# Output:
# Reading package lists... Done
# Building dependency tree
# Reading state information... Done
# The following additional packages will be installed:
#   yum-utils
# Suggested packages:
#   rpm-i18n
# The following NEW packages will be installed:
#   yum yum-utils
# 0 upgraded, 2 newly installed, 0 to remove and 0 not upgraded.
# Need to get 458 kB of archives.
# After this operation, 2,048 kB of additional disk space will be used.
# Do you want to continue? [Y/n]

Installing Specific Versions with YUM

sudo yum install yum-3.4.3-4.el7

# Output:
# Loaded plugins: fastestmirror
# Loading mirror speeds from cached hostfile
#  * base: mirror.23media.com
#  * extras: mirror.23media.com
#  * updates: mirror.23media.com
# Resolving Dependencies
# --> Running transaction check
# ---> Package yum.noarch 0:3.4.3-167.el7.centos will be installed
# --> Finished Dependency Resolution
VersionKey FeaturesCompatibility
3.4.3-4Latest bug fixesCentOS 7, Fedora 22
3.2.29-81Stable releaseCentOS 6, Fedora 19

Basic Usage of ‘yum’ and Verification

Now that you have installed yum, you can use it to manage packages on your Linux system. Here’s a basic example of how to use yum to install a package:

sudo yum install nano

# Output:
# Loaded plugins: fastestmirror
# Loading mirror speeds from cached hostfile
#  * base: mirror.23media.com
#  * extras: mirror.23media.com
#  * updates: mirror.23media.com
# Resolving Dependencies
# --> Running transaction check
# ---> Package nano.x86_64 0:2.3.1-10.el7 will be installed
# --> Finished Dependency Resolution

To verify that yum is installed correctly, you can use the yum command to check its version:

yum --version

# Output:
# 3.4.3

This command will display the version of yum installed on your system, confirming that the installation was successful.

Exploring Alternative Package Installation Methods

While ‘yum’ is a widely used command for package management in Linux, it’s not the only tool available. In this section, we’ll explore some alternative methods for installing packages, including the ‘dnf’ command and manual installation.

Using ‘dnf’ for Package Management

The ‘dnf’ command, short for Dandified YUM, is the next-generation version of ‘yum’. It’s the default package manager in Fedora and its derivatives. Here’s how you can use ‘dnf’ to install a package:

sudo dnf install nano

# Output:
# Last metadata expiration check: 0:15:12 ago on Sat 05 Jun 2021 08:30:34 AM EDT.
# Dependencies resolved.
# ================================================================================
#  Package       Architecture  Version               Repository              Size
# ================================================================================
# Installing:
#  nano          x86_64        2.9.8-1.el8           @anaconda               582 k

# Transaction Summary
# ================================================================================
# Install  1 Package

# Total download size: 582 k
# Installed size: 1.8 M
# Is this ok [y/N]: y
# Downloading Packages:
# Running transaction check
# Transaction check succeeded.
# Running transaction test
# Transaction test succeeded.
# Running transaction
#   Preparing        :                                                        1/1 
#   Installing       : nano-2.9.8-1.el8.x86_64                               1/1 
#   Running scriptlet: nano-2.9.8-1.el8.x86_64                               1/1 
#   Verifying        : nano-2.9.8-1.el8.x86_64                               1/1 

# Installed:
#   nano-2.9.8-1.el8.x86_64                                                       

# Complete!

This command installs the ‘nano’ package using ‘dnf’. The terminal will display the progress and ask for your confirmation before proceeding with the installation.

Manual Installation of Packages

Another method is manual installation, where you download the package files and install them manually using the ‘rpm’ command. This method gives you the most control but requires more effort. Here’s how to do it:

wget http://mirror.centos.org/centos/7/os/x86_64/Packages/nano-2.3.1-10.el7.x86_64.rpm
sudo rpm -i nano-2.3.1-10.el7.x86_64.rpm

# Output:
# Retrieving http://mirror.centos.org/centos/7/os/x86_64/Packages/nano-2.3.1-10.el7.x86_64.rpm
# Preparing...                          ################################# [100%]
# Updating / installing...
# 1:nano-2.3.1-10.el7                  ################################# [100%]

This command first downloads the ‘nano’ package from a CentOS mirror and then installs it using the ‘rpm’ command.

MethodAdvantageDisadvantage
‘yum’Easy to use, resolves dependenciesMight not have the latest version
‘dnf’Next-gen ‘yum’, better performanceNot available on all distros
ManualFull control, install any versionMore effort, must handle dependencies

Remember, the best method depends on your specific needs and the Linux distribution you’re using. While ‘yum’ is straightforward and reliable, ‘dnf’ offers better performance and manual installation gives you more control.

Resolving Common ‘yum’ Command Issues

While ‘yum’ is a reliable package manager, you might occasionally encounter issues. This section will discuss some common problems and their solutions.

‘yum’ Command Not Found

If you get a ‘yum: command not found’ error, it means ‘yum’ is not installed on your system or not in your PATH. Here’s how you can check if ‘yum’ is installed:

which yum

# Output:
# /usr/bin/yum

This command will display the path to the ‘yum’ executable if it’s installed. If it returns nothing, you’ll need to install ‘yum’ using the methods discussed earlier.

Dependency Resolution Errors

Sometimes, ‘yum’ might fail to install a package due to dependency issues. Here’s an example:

sudo yum install some-package

# Output:
# Error: Package: 1:some-package-1.2.3-4.el7.x86_64 (epel)
#            Requires: libexample.so.0()(64bit)

This error means ‘some-package’ requires the ‘libexample.so.0’ library, but it’s not installed or available. To resolve this, you can search for the required package and install it:

sudo yum whatprovides libexample.so.0
sudo yum install libexample

Repository Errors

If you get errors related to the repository, such as ‘Cannot retrieve repository metadata’, it might be due to network issues or problems with the repository itself. You can try cleaning the ‘yum’ cache to solve this:

sudo yum clean all

This command cleans the ‘yum’ cache, which can help resolve repository-related errors.

Remember, troubleshooting involves understanding the error message, identifying the problem, and then applying the appropriate solution. The ‘yum’ command provides verbose error messages that can guide you in troubleshooting.

Understanding Package Management in Linux

Before diving into the specifics of the ‘yum’ command, let’s take a step back and understand the concept of package management in Linux. This understanding will provide a solid foundation for using ‘yum’ and other similar tools.

What is a Package?

In Linux, a package is a compressed file archive that contains all of the files that come with a particular application. The files are usually compiled code, but they can also include scripts and documentation. The package also contains metadata, such as the software’s name, description of its purpose, version number, vendor, checksum, and a list of dependencies necessary for the software to run.

rpm -qi nano

# Output:
# Name        : nano
# Version     : 2.3.1
# Release     : 10.el7
# Architecture: x86_64
# Install Date: Tue 05 Jun 2021 08:30:34 AM EDT
# Group       : Applications/Editors
# Size        : 1818912
# License     : GPLv3+
# Signature   : RSA/SHA256, Sat 04 Jul 2020 12:09:48 AM EDT, Key ID 24c6a8a7f4a80eb5
# Source RPM  : nano-2.3.1-10.el7.src.rpm
# Build Date  : Wed 27 May 2020 02:02:26 PM EDT
# Build Host  : x86-01.bsys.centos.org
# Relocations : (not relocatable)
# Packager    : CentOS BuildSystem <http://bugs.centos.org>
# Vendor      : CentOS
# URL         : http://www.nano-editor.org/
# Summary     : A small text editor
# Description :
# Nano is a small, free and friendly editor which aims to replace Pico, the
# default editor included in the non-free Pine package. On top of copying
# Pico's look and feel, nano also implements some missing (or disabled by
# default) features in Pico, such as "search and replace" and "go to line
# and column number".

This command displays the metadata of the ‘nano’ package, showing information such as the name, version, size, license, and a brief description.

Importance of Package Management

Package management is crucial in Linux for several reasons. It ensures that software is installed correctly, with all its dependencies. It also makes software easier to remove or update, prevents file conflicts, and maintains system stability and security.

Imagine having to manually download, compile, and install every software you need, along with its dependencies. Not only would this be time-consuming, but it could also lead to file conflicts, broken dependencies, and system instability. Package managers like ‘yum’ automate this process, making it easier, safer, and more efficient.

By understanding the concept of package management in Linux, you can better appreciate the functionality and convenience that ‘yum’ brings to your Linux system.

The Relevance of Package Management in System Administration and Security

Package management is not just about installing or removing software; it’s a crucial part of system administration and security. Using package managers like ‘yum’, administrators can ensure that software is up-to-date, secure, and running optimally.

Package Management and System Administration

In system administration, package management helps maintain system stability and performance. It allows administrators to manage software efficiently, keep track of installed software, and resolve dependencies. This is especially important in large-scale environments, where manual software management would be impractical.

Package Management and Security

From a security perspective, package managers offer several benefits. They provide a trusted source of software, reducing the risk of installing malicious or compromised software. They also facilitate timely updates, which often include security patches. By using ‘yum’, you can ensure your system is secure and up-to-date.

sudo yum update

# Output:
# Loaded plugins: fastestmirror
# Loading mirror speeds from cached hostfile
#  * base: mirror.23media.com
#  * extras: mirror.23media.com
#  * updates: mirror.23media.com
# Resolving Dependencies
# --> Running transaction check
# ---> Package openssl-libs.x86_64 1:1.0.2k-19.el7 will be updated
# --> Processing Dependency: openssl-libs(x86-64) = 1:1.0.2k-19.el7 for package: 1:openssl-1.0.2k-19.el7.x86_64
# --> Finished Dependency Resolution

This command updates all installed packages on your system, ensuring they have the latest features and security patches.

Exploring Related Concepts

While ‘yum’ is a powerful tool, package management in Linux involves many other concepts worth exploring. For example, repositories are online storage locations for software packages. Dependencies are other packages that a software needs to run correctly. Understanding these concepts can enhance your proficiency with ‘yum’ and Linux package management.

Further Resources for Mastering Linux Package Management

To deepen your understanding of Linux package management, here are some additional resources you can explore:

  1. This TLDP document illustrates how to build and install software packages for Linux.

  2. Linux Package Management with Yum, RPM, Apt, Dpkg, Aptitude and Zypper – Part 9: A comprehensive guide on Linux package management using different tools, including ‘yum’.

  3. The Fedora Project Wiki: The official Fedora Project Wiki, with detailed information on the ‘dnf’ package manager, the successor to ‘yum’.

Wrapping Up: Installing the ‘yum’ Command in Linux

In this comprehensive guide, we’ve delved into the world of the ‘yum’ command, a powerful tool for package management in Linux.

We began with the basics, walking through the process of installing the ‘yum’ command in Linux. We then delved into more advanced territory, discussing methods such as installing from source and installing specific versions. We also provided practical examples to reinforce the concepts discussed.

Along the way, we addressed common issues that you might encounter when using the ‘yum’ command, such as command not found errors, dependency resolution errors, and repository errors. We provided solutions and tips to help you overcome these challenges.

We also explored alternative methods for installing packages in Linux, such as the ‘dnf’ command and manual installation. Here’s a quick comparison of these methods:

MethodAdvantageDisadvantage
‘yum’Easy to use, resolves dependenciesMight not have the latest version
‘dnf’Next-gen ‘yum’, better performanceNot available on all distros
ManualFull control, install any versionMore effort, must handle dependencies

Whether you’re a beginner just starting out with Linux or an experienced user looking to level up your skills, we hope this guide has given you a deeper understanding of the ‘yum’ command and its capabilities.

With its ease of use and robust functionality, the ‘yum’ command is a powerful tool for package management in Linux. Happy coding!