In this tutorial we are going to show you the most used 10 YUM commands in Linux. YUM is a command-line package management system that is used on CentOS and AlmaLinux.
YUM (shortcat for “Yellowdog Updater Modified“) package manager is responsible for managing the packages from the YUM repositories located on the server at /etc/yum.repos.d/. In this tutorial we are going to install, remove, update software packages with real example.
The YUM command examples will be explained on the CentOS 7 OS. Let’s get started!
Table of Contents
- Fresh install of CentOS 7
- User privileges: root or non-root user with sudo privileges
1. Update the System
After a fresh installation of the server, it is recommended to update the system packages to the latest versions available.
yum update -y && yum upgrade -y
These two yum commands are very often used, after some changes like adding repositories, and installing or removing packages.
2. Clear the yum Cache
Cleaning the yum cache is to reclaim the disk space. With the yum clean command we can clean the package headers, metadata, and packages. To clean all this stuff execute the following commands:
yum clean headers yum clean metadata yum clean packages
To clean all information above in one command, execute the following line:
yum clean all
3. Search Package
To search some specific package names you can use the following command:
yum search PACKAGE NAME
For example, if we need the MariaDB package, we can simply execute the following line:
yum search mariadb
You will receive the following output, or similar like this:
[root@vps ~]# yum search mariadb Loaded plugins: fastestmirror Loading mirror speeds from cached hostfile * base: mirror.team-cymru.com * epel: ftp-chi.osuosl.org * extras: ftpmirror.your.org * updates: mirror.team-cymru.com ========================================================================= N/S matched: mariadb ========================================================================= mariadb-bench.x86_64 : MariaDB benchmark scripts and data mariadb-devel.i686 : Files for development of MariaDB/MySQL applications mariadb-devel.x86_64 : Files for development of MariaDB/MySQL applications mariadb-embedded.i686 : MariaDB as an embeddable library mariadb-embedded.x86_64 : MariaDB as an embeddable library mariadb-embedded-devel.i686 : Development files for MariaDB as an embeddable library mariadb-embedded-devel.x86_64 : Development files for MariaDB as an embeddable library mariadb-libs.i686 : The shared libraries required for MariaDB/MySQL clients mariadb-libs.x86_64 : The shared libraries required for MariaDB/MySQL clients mariadb-server.x86_64 : The MariaDB server and related files anope-mysql.x86_64 : MariaDB/MySQL modules for Anope IRC services mariadb.x86_64 : A community developed branch of MySQL mariadb-test.x86_64 : The test suite distributed with MariaD percona-xtrabackup.x86_64 : Online backup for InnoDB/XtraDB in MySQL, Percona Server and MariaDB
4. Install Package
Next, we will install the MariaDB package, since we successfully listed with the search command above. To install the mariadb-server package execute the following command:
yum install mariadb-server
5. Reinstall Package
Let’s say that the installation of the previous command was somehow compromised and the package was not installed properly. We can easily reinstall the package with the command below:
yum reinstall mariadb-server
6. Update Specific Package
At the beginning of this tutorial we updated the whole system for the packages to get their latest versions available. We can update only a specific package if we do not want to wait longer for the update process. To update the MariaDB package execute the following command:
yum update mariadb-server
7. Information about a Specific Package
If we want to know more about some package, about its version, size, release or someting else we can execute the following command:
yum info mariadb-server
You should receive output similar to this:
[root@vps ~]# yum info mariadb-server Loaded plugins: fastestmirror Loading mirror speeds from cached hostfile * base: mirror.team-cymru.com * epel: ftp-chi.osuosl.org * extras: ftpmirror.your.org * updates: mirror.team-cymru.com Installed Packages Name : mariadb-server Arch : x86_64 Epoch : 1 Version : 5.5.68 Release : 1.el7 Size : 58 M Repo : installed From repo : base Summary : The MariaDB server and related files URL : http://mariadb.org License : GPLv2 with exceptions and LGPLv2 and BSD Description : MariaDB is a multi-user, multi-threaded SQL database server. It is a : client/server implementation consisting of a server daemon (mysqld) : and many different client programs and libraries. This package contains : the MariaDB server and some accompanying files and directories. : MariaDB is a community developed branch of MySQL.
8. Remove Package
To remove the specific package we do not want anymore we can use the following command:
yum remove mariadb-server
After successful removing the package MariaDB you should receive the following output:
Now just $43 .99
Running transaction Erasing : 1:mariadb-server-5.5.68-1.el7.x86_64 1/1 warning: /var/log/mariadb/mariadb.log saved as /var/log/mariadb/mariadb.log.rpmsave Verifying : 1:mariadb-server-5.5.68-1.el7.x86_64 1/1 Removed: mariadb-server.x86_64 1:5.5.68-1.el7 Complete!
9. Enabled Yum Repositories
To check all enabled YUM repositories execute the following command:
You should receive the following output:
[root@vps ~]# yum repolist Loaded plugins: fastestmirror Loading mirror speeds from cached hostfile * base: mirror.team-cymru.com * epel: ftp-chi.osuosl.org * extras: ftpmirror.your.org * updates: mirror.team-cymru.com repo id repo name status base/7/x86_64 CentOS-7 - Base 10,072 epel/x86_64 Extra Packages for Enterprise Linux 7 - x86_64 13,755 extras/7/x86_64 CentOS-7 - Extras 509 updates/7/x86_64 CentOS-7 - Updates
10. YUM History
To see all the yum commands you executed before you can use the yum history command:
You should receive the output similar to this if you executed all the yum commands from the previous steps:
[root@vps ~]# yum history Loaded plugins: fastestmirror ID | Command line | Date and time | Action(s) | Altered ------------------------------------------------------------------------------- 53 | remove mariadb-server | 2022-05-06 02:16 | Erase | 1 EE 52 | reinstall mariadb-server | 2022-05-06 01:36 | Reinstall | 1 51 | update -y | 2022-05-05 02:38 | I, U | 7 50 | remove kernel-3.10.0-116 | 2022-04-05 04:27 | Erase | 1 49 | update | 2022-04-05 04:14 | I, U | 16
That’s it. In the previous paragraphs were explained the most 10 used YUM commands in Linux. As you can see the commands were explained in the order you should use if you want to install and update the packages on your server. Of course, in the end, you will delete the packages you do not need.
If you need to install, delete or update YUM packages, and you do not know how to do that, you just need to sign up for one of our NVMe VPS plans, submit a support ticket and our admins will do the rest. We are available 24/7.
P.S. If you liked this post about the 10 useful YUM commands in Linux, please share it with your friends on social networks or simply leave a reply below. Thanks.