Yum Command on Linux (Installing and Upgrading Packages) [Basic Guide]

Linux distributions based on Red Hat use the package manager called Red Hat Package Manager — RPM to install your software. The most famous distributions include Red Hat’s own Linux Enterprise, Fedora, and CentOS.

RPM is a powerful package manager that allows the administrator to install, remove, and obtain package information. It is a software distribution method widely used in several Linux distributions, in addition to Red Hat.

It also makes it possible to build packages from source files, verify the digital signature, simulate an installation, among others. It’s as powerful as dpkg and apt-get.

Due to the difficulty of dealing with package management using the rpm command, Red Hat-based Linux distributions use the yum utility.

Yum is an acronym for Yellow Dog Updater, Modified. It is a tool used to manage the installation and removal of packages in Linux distributions that use the RPM system.

Yum is a file package manager similar to APT-GET that automatically handles dependencies by computing them and resolving what must be done to treat them.

It has a configuration file that specifies which repositories YUM should use to search for and download RPM packages.

RPM-based Linux won’t always have the YUM package manager installed. If you need to install YUM, it can be obtained at http://yum.baseurl.org.

The installation command is:

# rpm -ivh yum.rpm

Some yum commands:

  • yum list: List all available packages;
  • yum check-update or yum list updates: Check if there are packages available for an update;
  • yum update: Update your system;
  • yum install ;: Installs a specific package and its dependencies;
  • yum remove: Removes a specific package
  • yum info: Presents basic information for a given package.
  • yum whatprovides file: List all packages that have the file indicated in the search

See the examples:

To install a package:

# yum install postgresql

Resolving Dependencies
Install 2 Package (s)
Is this ok [Y/n]: y

Package (s) data still to download: 3.0 M
(1/2): postgresql-9.0.4-5.fc15.x86_64.rpm | 2.8 MB 00:11
(2/2): postgresql-libs-9.0.4-5.fc15.x86_64.rpm | 203 kB 00:00
----------------------------------------------------------
Total 241 Kb/s | 3.0 MB 00:12

Running Transaction
Installing: postgresql-libs-9.0.4-5.fc15.x86_64 1/2
Installing: postgresql-9.0.4-5.fc15.x86_64 2/2

One option in Yum is the “-y” that installs or updates packages without asking. It’s not very suitable for production.

To update installed packages:

# yum update
Plugins loaded: priorities, update-motd, upgrade-helper
amzn-main/latest

Resolving dependencies
---> Performing transaction verification
---> The aws-cli.noarch package 0:1 .7.5-1.2.amzn1 will be updated
---> The aws-cli.noarch package 0:1 .7.12-1.3.amzn1 will be an update
---> Dependency resolution finished

Dependencies resolved
=======================================================================
Package Arq. Repo Tam version.
=======================================================================
Installing:
kernel x86_64 3.14.34-27.48.amzn1 amzn-updates 16 M

Updating:
aws-cli noarch 1.7.12-1.3.amzn1 amzn-updates 604 m
Transaction summary
======================================================================= Install 1 Package (+4 Dependent packages)
Upgrade 1 Package

Total download size: 16 MB
Is this ok [Y/D/n]:

To remove a package:

# yum remove Postgresql

To search for all packages with the word “firefox”:

# yum search Firefox 
Loaded plugins: langpacks, soon, refresh-packagekit ============== N/S Matched: firefox ========================== firefox.x86_64: Mozilla Firefox Web browser gnome-do-plugins-firefox.x86_64: gnome-do-plugins for Firefox mozilla-firetray-firefox.x86_64: System tray extension for firefox mozilla-adblockplus.noarch: Adblocking extension for Mozilla Firefox mozilla-noscript.noarch: JavaScript list extension for Mozilla Firefox Name and summary matches only, use “search all” for everything.

To obtain information about a particular package:

# yum info MySQL
Plugins loaded: priorities, update-motd, upgrade-helper
NewRelic & nbsp; ; 59/59
Installed packages

Name: mysql
Architecture: noarch
Version: 5.5
Release: 1.6.amzn1
Size: 0.0
Repo: installed
From the repository: amzn-main
Summary: MySQL meta package
Webbadress: http://www.mysql.com
License: GPLv2 with exceptions
Description: MySQL is a multi-user, multi-threaded SQL database server. MySQL is a
: client/server implementation consisting of a server daemon (mysqld)
: and many different client programs and libraries. The Base Package
: contains the standard MySQL client programs and generic MySQL files.

To view all the packages available in the yum repository:

# yum list
Installed packages
GeoIP.x86_64 1.4.8-1.5.amzn1 @amzn -main
GeoIP-Devel.x86_64 1.4.8-1.5.amzn1 @amzn -main
Pyyaml.x86_64 3.10-3.6.amzn1 installed
acl.x86_64 2.2.49-6.9.amzn1 installed
acpid.x86_64 1.0.10-2.1.6.amzn1 installed
alsa-lib.x86_64 1.0.22-3.9.amzn1 installed
apr.x86_64 1.5.0-2.11.amzn1 @amzn -updates
(...)

To find out which package a particular file belongs to:

# yum provides /etc/sysconfig/nfs
Plugins loaded: priorities, update-motd, upgrade-helper
1:nfs-utils-1.2.3-39.15.amzn1.x86_64: NFS utilities and supporting clients and daemons for the kernel NFS server

Repo: aman-main
Result starting from:
File name: /etc/sysconfig/nfs

To find out which repositories are active in YUM:

# Yum Repolist
repo id repo status name
amzn-main/latest AMZN-Main-Base 5.019
amzn-updates/latest AMZN-updates-Base 1.085
newrelic/x86_64 New Relic packages 59

Like apt, YUM also caches packages downloaded in the /var/cache/yum directory.

Generally, after the successful installation of the packages, yum automatically cleans the cache directory. This depends on the /etc/yum.conf configuration file, especially the keepcache option.

In any case, you can empty the cache with the command:

# yum clean all

Learn much more about Linux in our online course. You can register here. If you already have an account, or want to create one, just log in or create your user here.

Uirá Endy Ribeiro

Uirá Endy Ribeiro is a Software Developer and Cloud Computing Architect with a 23-year career. He has master's degrees in computer science and fifteen IT certifications and is the author of 11 books recognized in the IT world market. He is also Director at Universidade Salgado de Oliveira and Director of the Linux Professional Institute - LPI Director's Board.

Leave a Reply 0

Your email address will not be published. Required fields are marked *


This site uses Akismet to reduce spam. Learn how your comment data is processed.

Need help?