YUM also called “Yellowdog Updater” is a package management tool for RPM-based Linux distributions including, RHEL, CentOS and Fedora operating systems. It is used to install, update, remove, find and manage packages on Linux.
Note: If you are using the Debian-based Linux distributions including, Ubuntu, Debina and Linux Mint. You can read my guide on “APT Command in Linux – A Definitive Guide”
You will learn the following:
- Install a Package with YUM
- Remove a Package with YUM
- Update a Package with YUM
- List a Package with YUM
- Search for Packages with YUM
- Get Information of a Package with YUM
- List Yum Repositories
- Install and Remove Group Packages
In this post, we will show you how to use the YUM command to manage packages in Linux with various examples.
Prerequisites
- A server running CentOS/RHEL/Fedora.
- A root password is configured on your server.
1 – Install a Package with YUM
You can install single or multiple packages easily using the YUM command. For example, to install a single HTTP package, run the following command:
yum install httpd
To install multiple packages like, HTTP and Firefox, run the following command:
yum install httpd firefox
To reinstall any packages, run the following command:
yum reinstall httpd
To install a package from the downloaded RPM file, run the following command:
yum localinstall packagename.rpm
2 – Remove a Package with YUM
You can remove a package by just using the option remove by specifying your package name. For example, to remove a package named HTTP, run the following command:
yum remove httpd
To remove multiple packages like, HTTP and Firefox, run the following command:
yum remove httpd firefox
By default, yum stores all package data in /var/cache/yum/ directory. It is recommended to clean all cached files to save disk space. You can clean them with the following command:
yum clean all
To remove all unwanted packages, run the following command:
yum autoremove
3 – Update a Package with YUM
You can also update a single or all packages to the latest version using the option update with the YUM command. For example, to update all installed packages to the latest version, run the following command:
yum update
To update a single package named HTTP, run the following command:
yum update httpd
You can also check all available updates with the following command:
yum check-update
4 – List a Package with YUM
You can use the options list with the YUM command to list all available packages in your system. To list a package named HTTP, run the following command:
yum list httpd
To list all available packages, run the following command:
yum list
To list all installed packages in your system, run the following command:
yum list installed
5 – Search for Packages with YUM
If you don’t know the exact name of the package that you want to install, you can use the option search with the YUM command to find your desired package. For example, search a package named Nginx, run the following command:
yum search nginx
Output:
Last metadata expiration check: 0:01:48 ago on Sunday 28 March 2021 08:23:40 AM EDT. ========================================================= Name Exactly Matched: nginx ========================================================= nginx.x86_64 : A high performance web server and reverse proxy server ======================================================== Name & Summary Matched: nginx ======================================================== nginx-mod-mail.x86_64 : Nginx mail modules nginx-mod-stream.x86_64 : Nginx stream modules nginx-mod-http-perl.x86_64 : Nginx HTTP perl module nginx-mod-http-xslt-filter.x86_64 : Nginx XSLT module nginx-mod-http-image-filter.x86_64 : Nginx HTTP image filter module nginx-filesystem.noarch : The basic directory layout for the Nginx server pcp-pmda-nginx.x86_64 : Performance Co-Pilot (PCP) metrics for the Nginx Webserver nginx-all-modules.noarch : A meta package that installs all available Nginx modules
6 – Get Information of a Package with YUM
If you want to get more information about any package including, package name, version, size and license. You can use the option info with the YUM command.
For example, to get information about a package Nginx, run the following command:
yum info nginx
Output:
Last metadata expiration check: 0:02:18 ago on Sunday 28 March 2021 08:23:40 AM EDT. Available Packages Name : nginx Epoch : 1 Version : 1.14.1 Release : 9.module_el8.0.0+184+e34fea82 Architecture : x86_64 Size : 570 k Source : nginx-1.14.1-9.module_el8.0.0+184+e34fea82.src.rpm Repository : AppStream Summary : A high performance web server and reverse proxy server URL : http://nginx.org/ License : BSD Description : Nginx is a web server and a reverse proxy server for HTTP, SMTP, POP3 and : IMAP protocols, with a strong focus on high concurrency, performance and low : memory usage.
7 – List Yum Repositories
To list all enabled repository in your system, run the following command:
yum repolist
Output:
repo id repo name AppStream CentOS-8 - AppStream BaseOS CentOS-8 - Base extras CentOS-8 - Extras
To list all enabled and disabled repository in your system, run the following command:
yum repolist all
Output:
repo id repo name status AppStream CentOS-8 - AppStream enabled AppStream-source CentOS-8 - AppStream Sources disabled BaseOS CentOS-8 - Base enabled BaseOS-source CentOS-8 - BaseOS Sources disabled Devel CentOS-8 - Devel WARNING! FOR BUILDROOT USE ONLY! disabled HighAvailability CentOS-8 - HA disabled PowerTools CentOS-8 - PowerTools disabled base-debuginfo CentOS-8 - Debuginfo disabled c8-media-AppStream CentOS-AppStream-8 - Media disabled c8-media-BaseOS CentOS-BaseOS-8 - Media disabled centosplus CentOS-8 - Plus disabled centosplus-source CentOS-8 - Plus Sources disabled cr CentOS-8 - cr disabled extras CentOS-8 - Extras enabled extras-source CentOS-8 - Extras Sources disabled fasttrack CentOS-8 - fasttrack disabled
8 – Install and Remove Group Packages
In rpm-based Linux distributions, a number of packages are bundled to a particular group. This will provides an easier way to install all the required packages without installing them individually.
To list all available group packages, run the following command:
yum grouplist
Output:
Last metadata expiration check: 0:03:06 ago on Sunday 28 March 2021 08:23:40 AM EDT. Available Environment Groups: Server with GUI Server Workstation Virtualization Host Custom Operating System Installed Environment Groups: Minimal Install Available Groups: Container Management .NET Core Development RPM Development Tools Development Tools Graphical Administration Tools Headless Management Legacy UNIX Compatibility Network Servers Scientific Support Security Tools Smart Card Support System Tools
To install specific group packages from the above list, run the following command:
yum groupinstall 'Development Tools'
If you want to remove group packages, run the following command:
yum groupremove 'Development Tools'
To update the group packages, run the following command:
yum groupupdate 'Development Tools'