FUNDAMENTALS A Complete Guide for Beginners
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
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
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
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
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
From 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:
- Adding [repository]
- 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
From 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
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
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
Here, 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
From 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
Here 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 -
From 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’
So, 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’
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 |
|
|
YUM |
|
|
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:
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
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
- reinstall: Reinstall the failed or removed packages.
- firefox: The package which I want to reinstall.
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
- autoremove: Uninstall any dependency that is not required by any installed packages.
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
- 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.
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
- reinstall: Reinstall the failed or removed packages
- vlc: The package which I want to reinstall.
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
- autoremove: Uninstall any dependency that is not required by any installed packages.
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
Related Articles
- Apt Vs Apt-get What’s the Difference?
- Yum Vs Rpm [Which One is Better]
- Dnf Vs Yum [How Both Are Different]
- Dpkg Vs Apt [What’s the Difference Between Package Managers]
- Apt Vs Rpm [Distinction Between Package Managers]
- Deb vs Rpm [Whether One is the Best]
- Apt Vs Pacman [Which One Should Be Utilized]
<< Go Back to Linux Package Manager Comparison | Package Management in Linux | Learn Linux Basics
Apt does indeed allow local file installs by doing the following:
sudo apt install ./mypackage.deb
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.