Home » Linux Package Management
Packages in Linux are distributed as
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.
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.
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.
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
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
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
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
[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
[root@localhost ~]# yum remove firefox
or
[root@localhost ~]# yum -y remove firefox
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
[root@localhost ~]# yum list all | less
Here | less is required as the list of packages would be large
[root@localhost ~]# yum list firefox
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
[root@localhost ~]# yum history
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
Run the following command to ensure there are no missing repositories.
[root@localhost ~]# yum repolist all
[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.