Written by 8:04 am How-tos, Show me the code

The yum Package Manager

Yum is a Package Manager or Package Management System for Red Hat Linux and Linux distributions derived from Red Hat Linux such as CentOSFedoraRocky Linux and Alma Linux.

A Package Manager, such as yum is used by a user in order to install, update, upgrade or remove software packages in a Linux installation.

NOTE: Execute the following commands as root user or using sudo.

Basic Usage

# install a package
yum install PACKAGE 

# see which installed packages have updates available
yum check-update 

# update a package
yum update PACKAGE 

# update all packages and their dependencies
yum update 

# remove one or more packages

# display information about a package
yum info PACKAGE

Searching for Packages

# list all available packages
yum list
yum list all 

# list all available packages using a glob expression,
# e.g. yum list java-latest*

# list all installed packages
yum list installed 

# list all available packages in all enabled repositories
yum list available 

# search for packages using one or more terms,
# e.g. 7zip sqlite
yum search TERM0 [TERM1 TERMn]

Package Groups

A package group is a group of related packages under a unique Name and unique GroupID. Installing a group installs all the packages in the group.

# list all available package groups # (displays the name of each package)
yum grouplist 

# list all available package groups # (displays the name of each package and the GroupId in parentheses)
yum grouplist -v 

# install a group by Name or ID
yum groupinstall GROUP_NAME
yum groupinstall GROUP_ID

Package Repositories

A package repository is a package store, a place where packages are stored as files. It can be a service accessible through network or even a local folder.

The term “package repository” is also used to denote a file containing information on how to find those repositories containing the packages.

yum repositories can be found at /etc/yum.repos.d.

A yum repository is plain text file in ini file format with a .repo extension.

The file name of a *.repo file may not contain spaces, e.g. CentOS-Base.repo.

Normally there is more than one *.repo files in the /etc/yum.repos.d folder.

Here is a sample of such a file:

name=CentOS-$releasever - Basebaseurl=http://vault.centos.org/$releasever/os/$basearch/gpgcheck=1gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-5 

#released updates [updates]name=CentOS-$releasever - Updatesbaseurl=http://vault.centos.org/$releasever/updates/$basearch/gpgcheck=1gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-5

NOTE: The keys name and baseurl are mandatory.

# list all available repositories
yum repolist

NOTE: You may create a new repository by adding a *.repo file in the /etc/yum.repos.d folder.

Yum Configuration File

yum uses a configuration file found at /etc/yum.conf. That file contains options that have global effect on how yum behaves.

More information regarding the yum.conf file can be found in Red Hat’s page Configuring Yum and Yum Repositories and in the relevant man page.

Yum Configuration Manager

The yum-config-manager is tool for displaying yum configuration and handling repositories.

# show configuration for all repositories

# show the global configuration,
# i.e. /etc/yum.conf the main section
yum-config-manager main 

# show configuration about a certain repository
# e.g. base
yum-config-manager REPOSITORY_NAME 

# add a repository.
# Repositories provide their own *.repo file
# e.g. yum-config-manager --add-repo http://www.example.com/example.repo
yum-config-manager --add-repo REPOSITORY_URL 

# enable a repository permanently
yum-config-manager --enable REPOSITORY_NAME 

# diable a repository permanently
yum-config-manager --disable REPOSITORY_NAME 

# temporarily enable a specified repository
# and disable all others
# when installing a package
yum --disablerepo="*" --enablerepo="REPOSITORY_NAME" install PACKAGE

More Information

It is easy to find extened information on internet regarding yum. Hera are some links:

Tested on:

  • CentOS 7
(Visited 63 times, 1 visits today)
Share the Post
Last modified: September 20, 2022