Apt Vs Yum [Difference Between the Package Managers]

APT and YUM are the two popular package management tools that are mainly used by Debian and RedHat-based Linux distributions respectively. If you understand the differences between the two packages then you will be able to manage the software effectively. In this article, I will show in depth the apt vs yum package managers. This will help you to distinguish between these two and able to use effectively.

What is Apt?

In Debian-based Linux distributions, the installation and removal of software are generally managed through the package management system known as the Advanced package tool (APT). It makes use of tools to manage, update, install, and uninstall operating system packages.

What is Yum?

In RedHat-based Linux distribution, a primary package for managing software packages is YUM which refers to Yellowdog Updater Modifier. It facilitates the installation, updating, removal, and management of dependencies on a system.

Differences Between Apt and Yum

Both of them are package managers that simplify the management of the packages on the distribution system. Besides, having similar functionality, there are some significant differences between them. Some of the differences are shown below in the table:

Package Manager Apt  Yum
Supported Package Format .deb files. .rpm files.
Distributed in Debian and Ubuntu-based distros, such as Debian, Ubuntu, Lubuntu, Kubuntu, etc. Red-Hat-based distros, such as RHEL, Fedora, CentOS, Rocky Linux, OpenSUSE, etc
Package Repository APT repositories to maintain the metadata and package information. RPM repositories to maintain the metadata and package information.
Configuration It is organized into functional groups within the tree. It is organized into two sections with global and repository-specific effects.
Options for searching and managing packages Comparatively fewer commands are available than YUM. More options are available than APT.
Install packages Do not allow from local files without prepend(./).
Allow local files.
Focus on Online Repositories. Package management and automation.
Upgrades For upgrading the installed packages you have to use the upgrade command for APT. For upgrading the installed packages you have to use the update command for YUM.
Dependency To resolve dependency multiple passes are used. To resolve the dependency, a single pass is used.

As you know these two package managers are used for two different distributions. According to your preference and distribution, you can use any of them.

Managing YUM Packages and Repositories

Here I have shown how to search, update and remove a package and handle a repository.

A. Searching for a Package

If you want to search for a package in your repository, you can locate the package with the search command. For that, you can use the command given below. Here I will search for a package named PostgreSQL. For that, I have used the following command. You can copy this command on your Redhat:

sudo yum search postgresql

Searching a package with yum

From the image, you can see using the search command I locate the package. You can use package names according to your liking.

B. Update Packages

When you want to update a package or all the packages you can copy this command in Redhat:

sudo yum update

Updating and Upgrading with yum

Here I update all the available packages with the latest version. From the image, you can see with yum, the upgrade is also done with the update command.

C. Remove Package

If you want to remove a specific package, you can copy this command:

sudo yum remove postgresql

Remove a specific package with yum

Here I have removed the postgresql package, you can remove any package according to your need.

D. Handle Repository With Yum

You can handle repositories with Yum. First I want to see the repository list. To display the repository list you can copy the command:

sudo yum repolist

Showing the directory repolist

From the image, you can see the repository list.

1. Add a Repository

You need the yum-utils package to add the repository. So, if there is no installed yum-utils package, firstly you have to install the package. To install the package you can copy this command:

sudo yum install -y yum-utils

Installation of yum-utilsFrom the above image, you can see I use the -y option which indicates yes to all yum-utils packages. You can skip the option.

You can add a new repository by two methods:

  1. Adding [repository]
  2. Adding repo file

As, you know the yum repositories provide their own repo file so I will add the repository, and yum will add the repo file to the directory. You can copy this syntax to add a repository:

sudo yum-config-manager \

--add-repo \

https://download.docker.com/linux/centos/docker-ce.repo

New repository has been addedFrom the image you can see the new repository is added.

2. Disable a Repository

Firstly to disable a repository, I will see the repository list. For displaying the repository list you can copy this command:

sudo yum repolist all

All repository in the directory has been show

Disable this repository

From the images, you can see I want to disable the repository that I added before.

So, To disable the repository from the directory you can copy the command:

sudo yum-config-manager --disable docker-ce-stable

Command for disabling the repository

The disabled repository has been shown

From the image, you can see to disable a repository you have to use disable option and the repository name.

Managing Apt Packages and Repositories

Like yum, in the following article, I will show how to search, update, remove, and handle a repository with apt.

A. Searching for a Package

If you need to find a package with apt you can locate it by search command. For that, you can use the command given below. Here I will search for a package named zfs. For that, I have used the following command. You can copy this command on your Ubuntu Terminal:

sudo apt search zfs

Search for zfs package with aptHere, I search for the zfs package but you can search according to your liking.

B. Update Packages

You can copy this command on Ubuntu to update the installed packages with apt.

sudo apt update

Updating all the packages in the directoryFrom the image, you can see with “apt update” you can update the installed packages and see the upgradable list. But in Redhat with one command “yum update”, you not only can update the packages but also can upgrade the required ones.

C. Remove Packages

You can copy this command on Ubuntu to remove a package:

sudo apt remove vlc

Remove vlc package with aptHere I remove the vlc package but you can remove a package according to your preference.

D. Handle Repository with Apt

Handling repository with apt means add and remove a repository. Below you can see how to add and remove repository a repository.

1. Add a Repository

If you want to add a repository with apt you have to follow two steps.

Firstly you have to add the repository GPG key. The GPG key verifies the authenticity of the packages. To add the key you can copy this command on Ubuntu:

wget -qO - https://deb.opera.com/archive.key | sudo apt-key add -

GPG key has been addedFrom the image, you can see it displays ‘OK’, which means the key has been added. You can add any repository according to your preference.

Secondly, once the key has been added, then you can install and add the repository. For adding the repository you can copy this command:

sudo add-apt-repository ‘https://deb.opera.com/archive.key’

A new repository has been added with aptSo, by this method, you can add a repository to your directory.

2. Remove a Repository

For removing a repository from the directory you have to use the remove option with the add command. You can copy this command:

sudo add-apt-repository --remove ‘https://deb.opera.com/archive.key’

Removing the recently added repository

Here I remove this repository which I added previously. So you can remove it according to your liking.

Pros and Cons of Apt and Yum

Here the pros and cons of these two package managers are shown in the table:

Package name Pros Cons
APT
  • In management and downloading packages, the apt shows the faster result.
  • As pinning is available, it has options for reverting upgrades.
  • User-friendly.
  • Autonomic resolve dependency and update packages.
  • Provide powerful search and filtering.
  • Not compatible with the RPM operating system.
  • Limited repositories in comparison to yum.
  • Without manual intervention, it can not remove the version of old packages.
YUM
  • Vast repository support.
  • Easy customization of repositories.
  • Resolve dependency and update the installed package automatically.
  • Huge functionality for plugin support.
  • Provide a straightforward way for package management.
  • Incompatible with Debian-based distribution.
  • It did not allow reverting upgrades because of the unavailability of pinning.
  • Slower while downloading and updating.

What Are the Advantages of Yum Over Apt?

Dependency resolution: As it has an advanced dependency-solving algorithm, it resolves dependency better than apt.

Plugin system: It has a plugin system that provides a wide range of functionality.

Flexibility: For handling packages, it shows more flexibility as it can use multiple repositories at once.

What Are the Advantages of Apt Over Yum?

Simple use: Easy use and require less initial configuration than yum.

Advanced features: Supports multiple architectures, from a single repository you can install packages on multiple architectures.

Pinning feature: APT has a pinning feature that can revert the upgrades.

Similarities Between Apt Vs Yum

While APT is only used mainly for Debian-based distribution and YUM is mainly used for Red hat-based distribution, there are some similarities between these two:

  • With a single command, you can install, download, update, and remove packages in both yum and apt.
  • Both of them resolve dependency resolution.
  • Mainly depend on repositories to provide a centralized location.

Examples of Yum Package Manager

Here I will show some examples to install, reinstall, and autoremove with Yum.

Example 1: Installing a Package With Yum

To install a yum package in Redhat copy this command. Here I will install Firefox, you can choose any package according to your liking.

sudo yum install firefox
EXPLANATION
  • sudo: Permits administrative privileges.
  • yum: Primary package management system in Red Hat that provides a high-level front-end command interface.
  • install: command install the following package.
  • firefox: The package which I want to install.

Install firefox with yum

Confirming the installation

Complete the installation

While installing a package with yum there is a confirmation question in which you have to type ‘y’ and press ENTER to install the package.

Example 2: Reinstalling a Package With Yum

Here I will reinstall Firefox, you can choose any package according to your liking. To reinstall a package in Red Hat copy this command:

sudo yum reinstall firefox
EXPLANATION
  • reinstall: Reinstall the failed or removed packages.
  • firefox: The package which I want to reinstall.

Reinstall a package with yum

Complete the reinstallation

Here, from the above images, you can see the newer version of the package installed.

Example 3: Autoremove a Package With Yum

To uninstall any dependency packages that are not required by any installed packages, in Red Hat, you can copy this command:

sudo yum autoremove
EXPLANATION
  • autoremove: Uninstall any dependency that is not required by any installed packages.

Unrequired dependencies are auto removed with yum

From the image, you can see I have removed all the unused or unrequired dependencies with the command.

Examples of Apt Package Manager

Here I will show you how to install, reinstall, and autoremove command work with apt.

Example 1: How to Install a Package With Apt

To install an apt package in Ubuntu copy this command. Here I will install gedit, you can choose any package according to your liking.

sudo apt install gedit
EXPLANATION
  • sudo: Permits administrative privileges.
  • apt: Provides a high-level command line interface for the package management system.
  • install: command install the following package.
  • gedit: The package which I want to install.

Install gedit package with apt

From the above image, you can see by the above-mentioned command I have installed the gedit package. While installing packages, you can use this command.

Example 2: How to Reinstall a Package With Apt

To reinstall an apt package in Ubuntu copy this command. Here I will reinstall vlc, you can choose any package according to your liking.

sudo apt reinstall vlc
EXPLANATION
  • reinstall: Reinstall the failed or removed packages
  • vlc: The package which I want to reinstall.

Reinstall a package with apt

From the above image, you can see by the above-mentioned command I have reinstalled the vlc package. While reinstalling packages, you can use this command.

Example 3: How to Autoremove a Package With Apt

To uninstall any dependency packages that are not required by any installed packages, in Ubuntu you can copy this command:

sudo apt autoremove
EXPLANATION
  • autoremove: Uninstall any dependency that is not required by any installed packages.

Unrequired files are auto removed with apt

From the above image, you can see by the above-mentioned command, I remove the unrequired package dependencies.

Conclusion

If you want to compare these two package managers then you can not be able to that because these two are mainly used for two different distributions. But if you want this really then you have to focus on the benefit of each package. As yum provides a simple and easy way to install from local files as well as online repositories on the other hand apt provides installation files only from online repositories. So, it mainly depends on the preference of the user which one is comparatively better.

People Also Ask

Which Package Manager Should I Use?
As both of the package managers are used for different Linux distributions, you can use any of these according to your distro. It actually depends on your preference.
What is the Difference Between a Yum Update and an Upgrade in Linux?
When you use the “yum update” command it will update all the installed packages to the latest version and if you use “yum upgrade”, it not only updates the installed package but also removes the outdated packages.
Is There Any Alternative to Yum in Linux?
Yes, you can use DNF instead of YUM. Because dnf has the same command and option as YUM and DNF is the successor of YUM.

Related Articles


<< Go Back to Linux Package Manager Comparison | Package Management in Linux | Learn Linux Basics

5/5 - (1 vote)
LINUX
FUNDAMENTALS
A Complete Guide for Beginners Enroll Course Now
Afia Zahin Oishi

Assalamualaikum, I am Afia Zahin, completed my graduation in Biomedical Engineering from Bangladesh University of Engineering and Technology, currently working as a Linux Content Developer Executive at SOFTEKO. A high achieving professional with a strong work ethic and able to work in a team in order to consistently achieve my goal and build my skillset. Able to handle difficult problems with patience and swift decision-making. Read Full Bio

2 thoughts on “Apt Vs Yum [Difference Between the Package Managers]”

    • Sorry for the inconvenience,you are right but you can not install the file only with the .deb file name.With apt,you have to use prepend which you do not need to use with yum.Thank you for your comment.

      Reply

Leave a Comment