How To Configure Yum In Linux

Yum is a package manager to retrieve the package information, update the package, install the package and also to delete the package.it also perform automatic dependency resolution when update, installing or removing package, thus it’s able to automatically determine, fetch and install all the dependent package.

           How yum is different from rpm

 Yum always install a new kernel regardless of whether we’re using “yum update” or “yum install”, however on the contrary while using rpm command we’ve to use “-u” to update the kernel.

               What is the role of GPG

 Yum provide secure package management by enabling GPG and each and every package must be gpg signed in order to install it. If any of the package is gpg signed then it means that the package is safe to download and install into the server.

        How to create yum repository

STEP 1: Mount the ISO, create a directory and mount that ISO into that directory.

[root@ORATEST yum.repos.d]# mkdir /mnt/disc

[root@ORATEST yum.repos.d]#

[root@ORATEST yum.repos.d]# mount /dev/sr0 /mnt/disc

mount: /dev/sr0 is write-protected, mounting read-only

[root@ORATEST yum.repos.d]# df -kh | grep -i /mnt/disc

/dev/sr0                     4.6G  4.6G     0 100% /mnt/disc

NOTE: if you’re using the RHEL iso instead of DVD media then please use below command   

mkdir /mnt/disc

mount -o loop RHEL7.9.iso /mnt/disc

NOTE (A):  -o loop option is required to mount the file as a block device

 STEP 2: Go into the yum.repos directory and create a file with any name but with .repo extension

[root@ORATEST yum.repos.d]# pwd;ls -ltr

/etc/yum.repos.d

total 4

-rw-r--r--. 1 root root 174 Aug 26 14:37 rhel7.repo

 STEP 3: Put below line in repo file to start yum repository

 [root@ORATEST ~]# cd /etc/yum.repos.d/

[root@ORATEST yum.repos.d]# ls -ltr

total 4

-rw-r--r--. 1 root root 174 Aug 26 14:37 rhel7.repo

[root@ORATEST yum.repos.d]#

[root@ORATEST yum.repos.d]# cat rhel7.repo

[ol7_latest]

name=yum_repository

gpgcheck=1

enabled=1

baseurl=https://yum.oracle.com/repo/OracleLinux/OL7/latest/$basearch/

gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-oracle

STEP 4: Run “yum repolist” to validate  the repository

root@ORATEST ~]# yum repolist

Loaded plugins: langpacks, ulninfo

repo id                                                                                  repo name                                                                             status

ol7_latest/x86_64                                                                        yum_repository                                                                        27,095

repolist: 27,095

 [root@ORATEST yum.repos.d]# yum install httpd

Loaded plugins: langpacks, ulninfo

Resolving Dependencies

--> Running transaction check

---> Package httpd.x86_64 0:2.4.6-99.0.1.el7_9.1 will be installed

--> Finished Dependency Resolution

 Dependencies Resolved

=====================================================================================================================================================================================

 Package                               Arch                                   Version                                               Repository                                  Size

=====================================================================================================================================================================================

Installing:

 httpd                                 x86_64                                 2.4.6-99.0.1.el7_9.1                                  ol7_latest                                 1.2 M

 Transaction Summary

=====================================================================================================================================================================================

Install  1 Package

Total download size: 1.2 M

Installed size: 3.7 M

STEP 5: validate whether any package is installed or not

 [root@ORATEST yum.repos.d]# yum list openssh

Loaded plugins: langpacks, ulninfo

Installed Packages

openssh.x86_64                                                                     7.4p1-23.0.3.el7_9                                                                     @ol7_latest

[root@ORATEST yum.repos.d]#

  Validate Repository and its related info verbosely

[root@ORATEST ~]# yum repolist -v

Not loading "rhnplugin" plugin, as it is disabled

Loading "ulninfo" plugin

Loading "langpacks" plugin

Adding en_US.UTF-8 to language list

Config time: 0.036

Yum version: 3.4.3

Setting up Package Sacks

pkgsack time: 0.006

Repo-id      : ol7_latest/x86_64

Repo-name    : yum_repository

Repo-revision: 1723729321

Repo-updated : Thu Aug 15 19:12:06 2024

Repo-pkgs    : 21,777

Repo-size    : 49 G

Repo-baseurl : https://yum.oracle.com/repo/OracleLinux/OL7/latest/x86_64/

Repo-expire  : 21,600 second(s) (last: Mon Aug 26 14:38:52 2024)

  Filter     : read-only:present

Repo-excluded: 5,318

Repo-filename: /etc/yum.repos.d/rhel7.repo

        Remove Package using Yum

[root@ORATEST ~]# yum remove httpd

Loaded plugins: langpacks, ulninfo

Resolving Dependencies

--> Running transaction check

---> Package httpd.x86_64 0:2.4.6-99.0.1.el7_9.1 will be erased

--> Finished Dependency Resolution

Dependencies Resolved

 =====================================================================================================================================================================================

 Package                               Arch                                   Version                                              Repository                                   Size

=====================================================================================================================================================================================

Removing:

 httpd                                 x86_64                                 2.4.6-99.0.1.el7_9.1                                 @ol7_latest                                 3.7 M

Transaction Summary

=====================================================================================================================================================================================

Remove  1 Package

Installed size: 3.7 M

Is this ok [y/N]: y

Downloading packages:

Running transaction check

Running transaction test

Transaction test succeeded

Running transaction

  Erasing    : httpd-2.4.6-99.0.1.el7_9.1.x86_64                                                                                                                                 1/1

  Verifying  : httpd-2.4.6-99.0.1.el7_9.1.x86_64                                                                                                                                 1/1


Removed:

  httpd.x86_64 0:2.4.6-99.0.1.el7_9.1

Complete!




Post a Comment

Previous Post Next Post