1. YUM Introduction
YUM – Is Yellow Dog Update / Modifier, is a command line tool used as package manager. using yum we to install / update /remove the package.
Dependencies are installed automatically from the yum repository. In this section we are going to see general commands that are used for daily activities. YUM is free and open source.
2. Listing Repos
The default directory is /etc/yum.repos.d, inside we could see files with *.repo. By default OS Installation repos files are created automatically. yum repolist command will display the available repos that are configured in the repo file
root@control ~]# yum repolist Last metadata expiration check: 0:02:41 ago on Saturday 09 May 2020 10:36:02 AM IST. repo id repo name status AppStream CentOS-8 - AppStream 5,318 BaseOS CentOS-8 - Base 1,661 centos-ansible-29 CentOS Configmanagement SIG - ansible-29 5 *epel Extra Packages for Enterprise Linux 8 - x86_64 5,458 *epel-modular Extra Packages for Enterprise Linux Modular 8 - x86_64 0 extras CentOS-8 - Extras 16 root@control ~]#
3. Listing the packages
To display list of all packages that are available in the repository, execute the below command.
[root@control ~]# yum list available
For example if we need to display the list of samba packages available, execute the below command, if you enabled multiple repos we could see multiple packages for the same package.
[root@control ~]# yum list samba Last metadata expiration check: 0:03:11 ago on Saturday 09 May 2020 10:36:02 AM IST. Available Packages samba.x86_64 4.10.4-101.el8_1 BaseOS
We can also use search option, but it will display with all matching pattern.
root@control ~]# yum search samba Last metadata expiration check: 0:12:30 ago on Saturday 09 May 2020 10:44:23 AM IST. ===================================== Name Exactly Matched: samba ====================================== samba.x86_64 : Server and Client software to interoperate with Windows machines samba.x86_64 : Server and Client software to interoperate with Windows machines ==================================== Name & Summary Matched: samba ===================================== samba-libs.x86_64 : Samba libraries samba-libs.i686 : Samba libraries samba-libs.x86_64 : Samba libraries samba-winbind.x86_64 : Samba winbind samba-client.x86_64 : Samba client programs python3-samba.i686 : Samba Python3 libraries python3-samba.x86_64 : Samba Python3 libraries samba-client-libs.x86_64 : Samba client libraries samba-client-libs.i686 : Samba client libraries samba-client-libs.x86_64 : Samba client libraries python3-samba-test.x86_64 : Samba Python libraries samba-winbind-clients.x86_64 : Samba winbind clients samba-winbind-modules.i686 : Samba winbind modules
4. Install the package
Install option is used to install the package, in the section we are going to install samba package.
[root@control ~]# yum install samba -y Last metadata expiration check: 0:00:19 ago on Saturday 09 May 2020 10:44:23 AM IST. Dependencies resolved. Package Architecture Version Repository Size Installing: samba x86_64 4.10.4-101.el8_1 BaseOS 739 k Installing dependencies: libwbclient x86_64 4.10.4-101.el8_1 BaseOS 115 k samba-client-libs x86_64 4.10.4-101.el8_1 BaseOS 5.1 M samba-common noarch 4.10.4-101.el8_1 BaseOS 209 k samba-common-libs x86_64 4.10.4-101.el8_1 BaseOS 177 k samba-common-tools x86_64 4.10.4-101.el8_1 BaseOS 469 k samba-libs x86_64 4.10.4-101.el8_1 BaseOS 185 k Transaction Summary Install 7 Packages Total download size: 6.9 M Installed size: 28 M Downloading Packages: (1/7): libwbclient-4.10.4-101.el8_1.x86_64.rpm 83 kB/s | 115 kB 00:01 (2/7): samba-common-4.10.4-101.el8_1.noarch.rpm 72 kB/s | 209 kB 00:02 (3/7): samba-common-libs-4.10.4-101.el8_1.x86_64.rpm 100 kB/s | 177 kB 00:01 (4/7): samba-4.10.4-101.el8_1.x86_64.rpm 111 kB/s | 739 kB 00:06 (5/7): samba-libs-4.10.4-101.el8_1.x86_64.rpm 73 kB/s | 185 kB 00:02 (6/7): samba-common-tools-4.10.4-101.el8_1.x86_64.rpm 55 kB/s | 469 kB 00:08 (7/7): samba-client-libs-4.10.4-101.el8_1.x86_64.rpm 86 kB/s | 5.1 MB 01:00 Total 115 kB/s | 6.9 MB 01:01 Running transaction check Transaction check succeeded. Running transaction test Transaction test succeeded. Running transaction Preparing : 1/1 Running scriptlet: samba-common-4.10.4-101.el8_1.noarch 1/7 Installing : samba-common-4.10.4-101.el8_1.noarch 1/7 Running scriptlet: samba-common-4.10.4-101.el8_1.noarch 1/7 Verifying : samba-common-tools-4.10.4-101.el8_1.x86_64 6/7 Verifying : samba-libs-4.10.4-101.el8_1.x86_64 7/7 Installed: samba-4.10.4-101.el8_1.x86_64 libwbclient-4.10.4-101.el8_1.x86_64 samba-client-libs-4.10.4-101.el8_1.x86_64 samba-common-4.10.4-101.el8_1.noarch samba-common-libs-4.10.4-101.el8_1.x86_64 samba-common-tools-4.10.4-101.el8_1.x86_64 samba-libs-4.10.4-101.el8_1.x86_64 Complete! [root@control ~]#
We can 6 dependency packages has been installed, along with samba package. -y option is used to installing without asking confirmation.
5. Verify the installation
To verify the installation we can use rpm command or yum history command.
Query the package using rpm command, execute the below command.
[root@control ~]# rpm -qa samba samba-4.10.4-101.el8_1.x86_64
Also you can grep for the samba package, this also show other packages with matching pattern
[root@control ~]# rpm -qa |grep samba samba-4.10.4-101.el8_1.x86_64 samba-common-libs-4.10.4-101.el8_1.x86_64 samba-common-4.10.4-101.el8_1.noarch samba-libs-4.10.4-101.el8_1.x86_64 samba-client-libs-4.10.4-101.el8_1.x86_64 samba-common-tools-4.10.4-101.el8_1.x86_64
In certain situation we need to know when was the successful installation of the package has been installed, use the –last option
It will show package name and version, and the install date.
[root@control ~]# rpm -qa samba --last samba-4.10.4-101.el8_1.x86_64 Sat May 9 10:45:48 2020
6. Detailed information of a package
Suppose if we want to know the package information like Release, License, Build information, Packager, we can use -i option,
[root@control ~]# rpm -qi samba Name : samba Epoch : 0 Version : 4.10.4 Release : 101.el8_1 Architecture: x86_64 Install Date: Sat May 9 10:45:48 2020 Group : Unspecified Size : 2524153 License : GPLv3+ and LGPLv3+ Signature : RSA/SHA256, Tue Dec 24 01:04:27 2019, Key ID 05b555b38483c65d Source RPM : samba-4.10.4-101.el8_1.src.rpm Build Date : Thu Dec 12 02:12:36 2019 Build Host : x86-01.mbox.centos.org Relocations : (not relocatable) Packager : CentOS Buildsys bugs@centos.org Vendor : CentOS URL : http://www.samba.org/ Summary : Server and Client software to interoperate with Windows machines Description : Samba is the standard Windows interoperability suite of programs for Linux and Unix. [root@control ~]#
In few scenarios if we check the configuration file from which package the file exists. -qif is query information file
[root@control ~]# rpm -qif /etc/samba/smb.conf Name : samba-common Epoch : 0 Version : 4.10.4 Release : 101.el8_1 Architecture: noarch Install Date: Sat May 9 10:45:47 2020 Group : Unspecified Size : 132320 License : GPLv3+ and LGPLv3+ Signature : RSA/SHA256, Tue Dec 24 01:04:51 2019, Key ID 05b555b38483c65d Source RPM : samba-4.10.4-101.el8_1.src.rpm Build Date : Thu Dec 12 02:15:51 2019 Build Host : aarch64-06.mbox.centos.org Relocations : (not relocatable) Packager : CentOS Buildsys bugs@centos.org Vendor : CentOS URL : http://www.samba.org/ Summary : Files used by both Samba servers and clients Description : samba-common provides files necessary for both the server and client packages of Samba. [root@control ~]#
7. YUM history
yum history is used to display all the yum transactions with the history ID
[root@control ~]# yum history
ID | Command line | Date and time | Action(s) | Altered
-------------------------------------------------------------------------------
29 | install samba -y | 2020-05-09 10:45 | Install | 7
28 | update --exclude=java-1. | 2020-05-06 01:36 | I, U | 48 EE
27 | remove httpd | 2020-05-06 01:25 | Removed | 6
26 | history undo 24 | 2020-05-06 01:25 | Removed | 5
25 | install httpd | 2020-05-06 01:20 | Install | 6
24 | install bind-utils | 2020-05-06 00:36 | Install | 5
23 | remove bind-utils | 2020-05-06 00:35 | Removed | 5
22 | install bind-utils | 2020-05-06 00:35 | Install | 5
For example if we want to see what is happened in the ID no 29, execute the below command
This will show the executed command, in this case we have used yum install samba -y, we could see the same in the Command Line row. Which user has executed the command
[root@control ~]# yum history info 29
Transaction ID : 29
Begin time : Saturday 09 May 2020 10:45:46 AM IST
Begin rpmdb : 885:2bdffe9b697913d3794f07400b6b4c7d4c0e486c
End time : Saturday 09 May 2020 10:45:49 AM IST (3 seconds)
End rpmdb : 892:cd685d218565ccd09e4f52b86391a4a0ab749e47
User : root
Return-Code : Success
Releasever : 8
Command Line : install samba -y
Packages Altered:
Install libwbclient-4.10.4-101.el8_1.x86_64 @BaseOS
Install samba-4.10.4-101.el8_1.x86_64 @BaseOS
Install samba-client-libs-4.10.4-101.el8_1.x86_64 @BaseOS
Install samba-common-4.10.4-101.el8_1.noarch @BaseOS
Install samba-common-libs-4.10.4-101.el8_1.x86_64 @BaseOS
Install samba-common-tools-4.10.4-101.el8_1.x86_64 @BaseOS
Install samba-libs-4.10.4-101.el8_1.x86_64 @BaseOS
[root@control ~]#
8. Revert back the changes with YUM
The undo option we can revert back the changes, make sure changes can be reverted only you have installed or removed using yum only, rpm commands cannot be revoked.
[root@control ~]# yum history undo 29 Last metadata expiration check: 0:13:45 ago on Saturday 09 May 2020 10:44:23 AM IST. Undoing transaction 29, from Saturday 09 May 2020 10:45:46 AM IST Install libwbclient-4.10.4-101.el8_1.x86_64 @BaseOS Install samba-4.10.4-101.el8_1.x86_64 @BaseOS Install samba-client-libs-4.10.4-101.el8_1.x86_64 @BaseOS Install samba-common-4.10.4-101.el8_1.noarch @BaseOS Install samba-common-libs-4.10.4-101.el8_1.x86_64 @BaseOS Install samba-common-tools-4.10.4-101.el8_1.x86_64 @BaseOS Install samba-libs-4.10.4-101.el8_1.x86_64 @BaseOS Dependencies resolved. Package Architecture Version Repository Size Removing: libwbclient x86_64 4.10.4-101.el8_1 @BaseOS 102 k samba x86_64 4.10.4-101.el8_1 @BaseOS 2.4 M samba-client-libs x86_64 4.10.4-101.el8_1 @BaseOS 23 M samba-common noarch 4.10.4-101.el8_1 @BaseOS 129 k samba-common-libs x86_64 4.10.4-101.el8_1 @BaseOS 321 k samba-common-tools x86_64 4.10.4-101.el8_1 @BaseOS 1.3 M samba-libs x86_64 4.10.4-101.el8_1 @BaseOS 437 k Transaction Summary Remove 7 Packages Freed space: 28 M Is this ok [y/N]: y Running transaction check Transaction check succeeded. Removed: libwbclient-4.10.4-101.el8_1.x86_64 samba-4.10.4-101.el8_1.x86_64 samba-client-libs-4.10.4-101.el8_1.x86_64 samba-common-4.10.4-101.el8_1.noarch samba-common-libs-4.10.4-101.el8_1.x86_64 samba-common-tools-4.10.4-101.el8_1.x86_64 samba-libs-4.10.4-101.el8_1.x86_64 Complete! [root@control ~]#
9. Removing a package
IF we need to remove a package, in few scenarios the dependency packages will also be removed, we are going to remove samba package, we can see total 7 packages are removed.
[root@control ~]# yum remove samba Dependencies resolved. Package Architecture Version Repository Size Removing: samba x86_64 4.10.4-101.el8_1 @BaseOS 2.4 M Removing unused dependencies: libwbclient x86_64 4.10.4-101.el8_1 @BaseOS 102 k samba-client-libs x86_64 4.10.4-101.el8_1 @BaseOS 23 M samba-common noarch 4.10.4-101.el8_1 @BaseOS 129 k samba-common-libs x86_64 4.10.4-101.el8_1 @BaseOS 321 k samba-common-tools x86_64 4.10.4-101.el8_1 @BaseOS 1.3 M samba-libs x86_64 4.10.4-101.el8_1 @BaseOS 437 k Transaction Summary Remove 7 Packages Freed space: 28 M Is this ok [y/N]: y Removed: samba-4.10.4-101.el8_1.x86_64 libwbclient-4.10.4-101.el8_1.x86_64 samba-client-libs-4.10.4-101.el8_1.x86_64 samba-common-4.10.4-101.el8_1.noarch samba-common-libs-4.10.4-101.el8_1.x86_64 samba-common-tools-4.10.4-101.el8_1.x86_64 samba-libs-4.10.4-101.el8_1.x86_64 Complete! [root@control ~]#
10. Conclusion
YUM is user friend tool for the package management, we can verify all the activities with history command.
[root@control ~]# yum history
ID | Command line | Date and time | Action(s) | Altered
-------------------------------------------------------------------------------
32 | remove samba | 2020-05-09 11:01 | Removed | 7
31 | install samba | 2020-05-09 11:00 | Install | 7
30 | history undo 29 | 2020-05-09 10:58 | Removed | 7
29 | install samba -y | 2020-05-09 10:45 | Install | 7
28 | update --exclude=java-1. | 2020-05-06 01:36 | I, U | 48 EE
27 | remove httpd | 2020-05-06 01:25 | Removed | 6
26 | history undo 24 | 2020-05-06 01:25 | Removed | 5
25 | install httpd | 2020-05-06 01:20 | Install | 6
24 | install bind-utils | 2020-05-06 00:36 | Install | 5
23 | remove bind-utils | 2020-05-06 00:35 | Removed | 5
22 | install bind-utils | 2020-05-06 00:35 | Install | 5
Easy use of yum package manager, Hope you have easy understanding how to use , let us know your views and suggestions.
Also refer Storage Migration using LVM https://computercarriage.com/2020/05/25/storage-migration-using-lvm/
Refer the yum cheat sheet from Redhat https://access.redhat.com/sites/default/files/attachments/rh_yum_cheatsheet_1214_jcs_print-1.pdf
let us know between “yum remove” and “yum erase” difference
remove is a alias for erase. both does the same job,