fbpx

Background

 

About ISO

  • .iso is an archive image format that allows you to bundle whole file systems within one file. 
  • The .iso files are used for easier transfer and distribution.
  • ISO is also short for International Organization for Standardization.
  • Why ISO – Well accepted,  norm of distribution of operating system files.
 

About Subscription-manager – RHEL

  • Red Hat Subscription Management (RHSM) is a solution that integrates with Red Hat’s system management tools.  Registered systems are entitled to support services, as well as errata, patches, and upgrades.
  • RHSM tracks if your system is registered to the subscription. 
  • We have to take the subscription
  • It is paid service and has its advantages
  • subscription-manager is a client program that registers a system with the Certificate-Based Red Hat Network.

Installing packages on linux

Packages in Linux are distributed as 

  • Redhat RPM – from Redhat, applicable to redhat flavours *.rpm
  • Debian packages – similar to rpms, but with *.deb extension
  • Tarballs archives are distributed with the following extensions “.tar.gz”, “.tar.bz2”, or “.zip” 

Tarballs are presented as source code and we have to compile them on our system.

RPM’s and DEB’s simplify the package installation, but still, they assume availablity of other packages/libraries which is listed as dependencies for that particular RPM, which need to be resolved (dependency rpm’s have to be installed first ) before the package, else the installation will fail with the message missing dependencies.

Introduction to Package Manager

Package managers allow easier installation of RPM’s and DEB’s 

rpm : The RPM package manager allows users to query, verify, install, upgrade, and remove packages. The main downside is that it doesn’t resolve package dependencies or automatic package updates.

yum : YUM (Yellow Dog Updater, Modified) is an open-source Linux package management application that uses the RPM package manager, for debian apt is used for same purpose

dnf : DNF which stands for Dandified yum is an updated version of yum. it is work the same as yum. 

RPM

Redhat Package Manager (RPM) allows you to install, query, verify, update, and remove/erase software packages

Common Commands used to manage packages using RPM.

rpm -ivh {rpm-file} :  To Install the package, as mentioned above it will ask you to install the dependencies if they are not already installed

rpm -Uvh {package.rpm} : Upgrade an installed package.

rpm -ev {package.rpm} :  Remove an installed package

rpm –qa :  Displays the list of all installed packages, as the list is long it is normally used with | grep {package.rpm}, so you can actually view the package you are searching.

rpm -qi {package.rpm} : Displays the information related to installation along with package version and short description. It is used to know when the package was installed.

rpm -qR {package.rpm} : Find out what dependencies a rpm file have.

YUM

YUM (YellowDog Updater Modified) is a package manager used for managing the installation, updating, and removing the software packages in a RedHat-based Linux system.

RPM and YUM are completely two different things, where RPM is the package manager tool that installs the package. YUM is a repository management tool that will fetch the appropriate package for your particular version of Linux(along with all other required packages).

DNF or Dandified YUM is an updated version of yum, it works in a similar manner, with more features in Red Hat flavor Linux distributions. 

Using YUM to manage packages

YUM fetches the appropirate packages along with its dependencies from the repositories defined in its configuration files, while configuring YUM we specify several parameters along with the URL’s to different repositories which provide these packages. 

Repositories are organized collection for packages that YUM can use to fetch the required packages and its dependencies,  Repositories maintain their metadata and other information in such a way that the entire process is efficient, as well as error-free.

If configured correctly you can actually update all the packages in your system using a single yum command.

Important: If you are running RHEL on your system, you have to have an active RHEL subscription to download packages from RHEL’s repositories

Configuring Yum

The main configuration file for YUM is /etc/yum.conf, and  additional configuration files are also read from the directory /etc/yum.repos.d.  Lets take a look at these files and various common parameters 

YUM.CONF

The following is a sample output of yum.conf

[main]gpgcheck=1
logfile=/var/log/yum.log
installonly_limit=3
clean_requirements_on_remove=True
best=True
skip_if_unavailable=False

logfile Full directory and file name for where yum should write its log file.

gpgcheck Either ‘1’ or ‘0’. This tells yum whether or not it should perform a GPG signature check on packages. When this is set in the [main] section it sets the default for all repositories. The default is ‘0’.

installonly_limit Number of packages listed in installonlypkgs to keep installed at the same time. Setting to 0 disables this feature. Default is ‘3’.

clean_requirements_on_remove When removing packages (by removal, update or obsoletion) go through each package’s dependencies. If any of them are no longer required by any other package then also mark them to be removed. Boolean (1, 0, True, False, yes,no) Defaults to False

skip_if_unavailable If set to True yum will continue running if this repository cannot be contacted for any reason. This should be set carefully as all repos are consulted for any given command. Defaults to False.

There are several other parameters that can be defined, you can refer to them seperately.

If you are using publicly hosted repositories it is important that your system/network must allow yum to connect to these repositories and fetch the packages for installation else yum will fail

In some networks such access may be allowed via proxy, in such cases we need to add additional parameters in yum.conf, which will tell yum to connect to the repositories via proxy, these will be covered in a later blog

*.repo

yum automatically searches the /etc/yum.repos.d directory for files with the suffix .repo and appends these to the configuration when it is processing. Use this directory to define repository files for repositories that you want to make available.

[baseos]name=CentOS Stream $releasever - BaseOS
metalink=https://mirrors.centos.org/metalink?repo=centos-baseos-$stream&arch=$basearch&protocol=https,http
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial
gpgcheck=1
repo_gpgcheck=0
metadata_expire=6h
countme=1
enabled=1
  • [baseos] : A unique name for each repository, one word
  • name=A human-readable string describing the repository.
  • baseurl= A URL to the directory where the yum repository’s ‘repodata’ directory lives.
  • metalink= Specifies a URL to a metalink file for the repomd.xml,  a list of mirrors for the entire repository are generated by converting the mirrors for the repomd.xml file to a baseurl
    This can be used instead of or with the baseurl option.
  • mirrorlist= Specifies a URL to a file containing a list of baseurls.
    This can be used instead of or with the baseurl option
  • gpgkey=A URL pointing to the ASCII-armored GPG key file for the repository. This option is used if yum needs a public key to verify a package and the required key hasn’t been imported into the RPM database.
  • gpgcheck=Either ‘1’ or ‘0’. This tells yum whether or not it should perform a GPG signature check on the packages gotten from this repository.
  • repo_gpgcheck=Either ‘1’ or ‘0’. This tells yum whether or not it should perform a GPG signature check on the repodata from this repository.
  • metadata_expire=Time (in seconds) after which the metadata will expire. So that if the current metadata downloaded is less than this many seconds old then yum will not update the metadata against the repository.
  • enabled=Either ‘1’ or ‘0’. This tells yum whether or not use this repository.
 
You can also mount your .iso image file as a yum repository on your system, in such cases yum will download these pacakge from the local repository itself without any need of internet access.

Common Yum Commands

Installing a Package

[root@localhost ~]# yum install firefox

The above command will ask for confirmation before installation adding -y flag to install automatically skipping the confirmation message

[root@localhost ~]# yum -y install firefox

Removing a package

[root@localhost ~]# yum remove firefox
or
[root@localhost ~]# yum -y remove firefox

Updating a package

If you already have a package installed and you want to upgrade the same to the latest version you have to use 

[root@localhost ~]# yum -y update mysql

List all packages

To list all the available packages in the configured repositories
[root@localhost ~]# yum list all | less

Here | less is required as the list of packages would be large

List specific package

[root@localhost ~]# yum list firefox

Search for package

Search will list all the packages that match to the name provided in the command, this is normally used when you dont know the specific package name and want to see what all options are available.

[root@localhost ~]# yum search php

See Yum History

[root@localhost ~]# yum history

Clear yum cache 

The following command ensures that no issues exist relating to corrupted metadata files, missing references, or temporarily free up disk space.

[root@localhost ~]# yum clean all

Check for missing repositories.

Run the following command to ensure there are no missing repositories.

[root@localhost ~]# yum repolist all

List only enabled repositories

[root@localhost ~]# yum repolist 

Update the system

Run the following command to update the package list and install the software:

[root@localhost ~]# yum update
 

..

..

Author
Nikhil Kumar Ahluwalia
Founder Upspir

Nikhil has over 16years of experience in the industry, before starting UPSPIR he was heading the support, services, and delivery function at Ameyo/Exotel as vice-president, and he has vast experience in managing and leading technical support and delivery teams, With Upspir he aims to take his passion of developing and mentoring people to next level by sharing his experiences and learning with those who want to build their career in the tech support domain.

Shopping Basket