May 13, 2024 5 min read

yum command in Linux with Examples

In this tutorial, we will explain how to use the yum command, which is a package management tool to install, update and manage software packages.

yum command in Linux
yum command in Linux
Table of Contents

Introduction

Before we discuss yum command in Linux, let's briefly understand - What is yum command ?

The yum command is a package management tool frequently used in Linux operating systems to install, update, and manage software packages. It simplifies software installation by automatically resolving dependencies.

With yum, users can effortlessly search for, install, update, and remove software packages on their system. This command streamlines the process of maintaining software on a Linux system, making it a vital tool for system administrators and everyday users alike.

yum can also be used to manage system updates, including security updates and bug fixes. By regularly running yum update, you can ensure that your system is up-to-date and secure.

In this tutorial, you will understand yum command in Linux. We will also address a few FAQs on yum command in Linux.

yum command: Useful flags

Assuming yes for all prompts

--y

Assuming no for all prompts

--assumeno

Disabling GPG verification

--nogpgcheck

Skipping broken packages

Packages with unresolved dependencies are skipped.

--skip-broken

Quiet mode

Suppresses all output save warnings and errors.

-q

Changelog

Show the package's changelog.

--changelog

Enabling/Disabling repository for single execution

A repository can be dynamically enabled or disabled for a single execution.

--enable-repo=[path]
--disable-repo=[path]    

Package Management

Installing an RPM package from remote repositories

sudo yum install [package-name]

Installing a local RPM package

sudo yum install /path/to/vim-1.2.rpm

Installing a specific version of a package

sudo yum install gcc-4.0

Checking for Updates Without Installing

sudo yum check-update

Removing an RPM package and dependencies

Removes a package along with any dependencies it may have (assuming no other dependencies exist).

sudo yum remove [package-name]
💡
Note: Any configuration files will remain intact; only the binaries and libraries will be deleted.

Removing Unused Dependencies

sudo yum autoremove

Downgrading a package

This will install the older version of the package.

sudo yum downgrade [package-name]

Viewing a package’s dependencies

sudo yum deplist [package-name]

Listing packages

The yum list command accepts the following types of arguments:

  • Listing all available packages from repositories
sudo yum list available
  • Listing installed packages
sudo yum list installed
  • Listing installed and available packages
sudo yum list all
  • Listing all packages (installed or available) that match a given [package-name], can be a glob
sudo yum list [package-name]    
sudo yum list mysql*
  • Listing installed and available kernel packages
sudo yum list kernel 

Searching for package

This looks through all repositories for [package-name], including the package descriptions.

sudo yum search [package-name]

Upgrading all system packages

sudo yum upgrade

Running this command on production systems is generally not advised, as it installs all the most recent versions of all installed packages on the system.

Reinstalling a single package

It is occasionally required to force a package to be reinstalled.

sudo yum reinstall [package-name]

Viewing info for a package

sudo yum info [package-name]

Finding which RPM package installs a given file

When using a command, and it's unclear which package needs to be installed, this one comes in quite handy.

sudo yum provides [file]

The yum provides command is also capable of accepting a glob pattern for package names.

sudo yum provides "*/bin/vim"

Listing all dependencies for a given package

sudo yum provides [package-name]

Package groups

For RPM-based Linux systems, the package manager yum can be used to manage package groups through the use of the command-line tool yum-groups-manager. With yum-groups-manager, you can alter the packages and dependencies that are a part of each group in addition to creating, editing, and deleting package groups. In order to create custom repositories, you can also use it to generate a new yum repository configuration file that only contains the package groups you specify.

Package groups are sets of related packages that can be installed collectively, usually for a particular use case, like a web server or desktop environment.

Listing all groups

sudo yum group list

Installing all packages for a group

sudo yum group install "Basic Web Server"

Removing all packages for a group

sudo yum group remove "Basic Web Server"

Repository Management

Listing all repositories

sudo yum repolist

Listing all packages for a given [repository]

sudo yum repo-pkgs [repository] list

Installing all packages from given [repository]

sudo yum repo-pkgs [repository] install

Removing all packages from a given [repository]

sudo yum repo-pkgs [repository] remove

Cleaning YUM Cache

sudo yum clean all

Updating local metadata cache

Yum runs this automatically when it needs to, but you can manually refresh it with yum makecache.

sudo yum makecache

All packages that are available are retrieved and reindexed from the repositories that yum is aware of when this command is executed.

yum-utils and yumdownloader

A set of plugins and utilities for yum, an RPM-based Linux package manager, is called yum-utils. These tools and plugins are intended to improve yum's functionality and offer more resources for package and repository management.

In Linux systems that use RPM, the yum-utils package contains the command-line tool yumdownloader. It can be helpful for setting up local repositories or installing packages on machines without internet access because it lets you download packages from yum repositories without having to install them first.

Downloading RPMs

  • Downloading RPM from remote repositories
sudo yumdownloader [package-name]
  • Downloading Source RPMs
sudo yumdownloader --source [package-name]
  • Downloading all dependencies for an RPM
sudo yumdownloader --resolve [package-name]

Filtering by architecture

sudo yumdownloader --archlist=[arch-list]  [package-name]

FAQs on yum command in Linux

Can yum update all installed packages at once?

Yes, with the yum update command, you can update all installed packages in one go.

How does yum help in managing software dependencies in Linux?

yum assists in managing software dependencies by automatically resolving and installing required dependencies when adding new software.

Can you list all installed packages using the yum command?

Yes, you can view all installed packages on your system with the yum list installed command.

Can yum be used to clean up old or unused packages in a Linux system?

Yes, yum provides commands like yum clean packages to remove old or unused packages from the system, freeing up disk space.

What is the importance of GPG keys in relation to the yum command in Linux?

GPG keys are used to verify the authenticity of software packages obtained from repositories. yum uses these keys to ensure the integrity and security of packages.

Does yum provide a way to check for broken dependencies in installed packages in Linux?

Yes, yum offers tools like yum check that can identify and report broken dependencies in installed packages on Linux.

Can yum be used to downgrade multiple packages to specific versions in Linux?

Yes, yum allows users to downgrade multiple packages to specified versions by providing the package names and version numbers.

Conclusion

We hope this tutorial helped you understand how to use yum command in Linux.

If you have any queries, please leave a comment below, and we’ll be happy to respond to them for sure.

Great! You’ve successfully signed up.
Welcome back! You've successfully signed in.
You've successfully subscribed to DevOps Tutorials - VegaStack.
Your link has expired.
Success! Check your email for magic link to sign-in.
Success! Your billing info has been updated.
Your billing was not updated.