Swiftorial Logo
Home
Swift Lessons
Matchups
CodeSnaps
Tutorials
Career
Resources

Using yum - Package Management in Linux

Introduction

Yum (Yellowdog Updater, Modified) is an open-source command-line package-management utility for RPM-compatible Linux operating systems. It allows users to manage packages such as installing, updating, and removing packages from their system. This tutorial will guide you through the basics of using yum.

Installing a Package

To install a package using yum, you can use the yum install command followed by the package name.

Example:

sudo yum install httpd

Sample Output:

Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * base: mirrors.vcea.wsu.edu
 * extras: mirrors.sonic.net
 * updates: mirrors.usc.edu
Resolving Dependencies
--> Running transaction check
---> Package httpd.x86_64 0:2.4.6-90.el7.centos will be installed
--> Finished Dependency Resolution

Dependencies Resolved

================================================================================
 Package        Arch          Version                      Repository      Size
================================================================================
Installing:
 httpd          x86_64        2.4.6-90.el7.centos          base           2.7 M

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

Total download size: 2.7 M
Installed size: 9.5 M
Is this ok [y/d/N]: y
                

Updating a Package

To update an existing package, you can use the yum update command followed by the package name. If no package name is specified, yum will update all packages.

Example:

sudo yum update httpd

Sample Output:

Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * base: mirrors.vcea.wsu.edu
 * extras: mirrors.sonic.net
 * updates: mirrors.usc.edu
Resolving Dependencies
--> Running transaction check
---> Package httpd.x86_64 0:2.4.6-90.el7.centos will be updated
---> Package httpd.x86_64 0:2.4.6-91.el7.centos will be an update
--> Finished Dependency Resolution

Dependencies Resolved

================================================================================
 Package        Arch          Version                      Repository      Size
================================================================================
Updating:
 httpd          x86_64        2.4.6-91.el7.centos          base           2.7 M

Transaction Summary
================================================================================
Upgrade  1 Package

Total download size: 2.7 M
Is this ok [y/d/N]: y
                

Removing a Package

If you need to remove a package from your system, you can use the yum remove command followed by the package name.

Example:

sudo yum remove httpd

Sample Output:

Loaded plugins: fastestmirror
Resolving Dependencies
--> Running transaction check
---> Package httpd.x86_64 0:2.4.6-91.el7.centos will be erased
--> Finished Dependency Resolution

Dependencies Resolved

================================================================================
 Package        Arch          Version                      Repository      Size
================================================================================
Removing:
 httpd          x86_64        2.4.6-91.el7.centos          @base           9.5 M

Transaction Summary
================================================================================
Remove  1 Package

Installed size: 9.5 M
Is this ok [y/N]: y
                

Searching for a Package

To search for a package, you can use the yum search command followed by a keyword related to the package name or description.

Example:

yum search httpd

Sample Output:

Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * base: mirrors.vcea.wsu.edu
 * extras: mirrors.sonic.net
 * updates: mirrors.usc.edu
============================================================ N/S matched: httpd ============================================================
httpd.x86_64 : Apache HTTP Server
mod_auth_mellon.x86_64 : SAML 2.0 authentication module for Apache Httpd

  Name and summary matches only, use "search all" for everything.
                

Listing Installed Packages

To list all the packages currently installed on your system, you can use the yum list installed command.

Example:

yum list installed

Sample Output:

Loaded plugins: fastestmirror
Installed Packages
NetworkManager.x86_64          1:1.10.2-16.el7_5             @base
abrt.x86_64                    2.1.11-48.el7.centos          @base
acl.x86_64                     2.2.51-14.el7                 @anaconda
                

Cleaning Up

Yum keeps a cache of headers and packages that have been downloaded. To clean up this cache, you can use the yum clean command.

Example:

sudo yum clean all

Sample Output:

Loaded plugins: fastestmirror
Cleaning repos: base extras updates
Cleaning up everything