Introduction
A package manager is a centralized mechanism for finding, installing, and managing software. APT and YUM are popular package management systems created for Debian-based and Red Hat-based Linux distributions, respectively.The two package managers are among the most popular and easiest-to-learn package managing utilities.In this article, you will learn the difference between APT and YUM and their basics.
YUM vs. APT: What Are the Differences?
YUM and APT offer the same core functionalities when it comes to installing packages. Both tools keep the information in a database and provide the same basic command-line features. However, some key differences set the two package managers apart.The following table shows an overview of the crucial differences between YUM and APT:Package Manager | YUM | APT |
---|---|---|
Used in | Red-Hat-based distros, such as RHEL, Fedora, CentOS, Rocky Linux, OpenSUSE, etc. | Debian and Ubuntu-based distros, such as Debian, Ubuntu, Lubuntu, Kubuntu, etc. |
Supported Installation Package Format | .rpm files. | .deb files. |
Configuration Files | /etc/yum.conf file with two sections. allows users to set YUM options with global and repository-specific effects. | /etc/apt/apt.conf file organized in a tree with options organized into functional groups. |
Command Options | The most used yum options are:
install
remove
search
info
update | The most used apt options are:
update
upgrade
install
remove
purge
list
search |
Upgrades | The yum update command is used to upgrade the installed packages to the latest version. | The sudo apt upgrade command is used to upgrade all packages to the latest stable version. |
Change Rollbacks | YUM allows any changes to be rolled back. | Allows changes to be rolled back by specifying the version you want to downgrade to. |
GUI Front-End Support | Yumex and PackageKit. | Nala and Synaptic. |
What Is YUM?
YUM (Yellowdog Updater, Modified) is an open-source package management system designed for RPM-based distributions (systems such as RHEL, CentOS, or its successor Rocky Linux). The tool installs, updates, manages and removes software packages.YUM manages packages either from software repositories (local or remote) or from .rpm packages and automatically resolves any dependencies during installation.Note: There is a newer improved version of the YUM package manager called DNF (Dandified YUM). The tool offers better performance and more features when installing, updating, or removing software in a RedHat-based Linux system.
Installing Packages with YUM
To find and install a package using YUM, follow the instructions below:Important: Some commands in the article require
sudo
or root privileges to make changes to the system.search
option. The option allows you to search through all the available packages and match the name of the specified package. The syntax is:yum search [package_name]
For example, to find the Firefox package, run:yum search firefox

list
option is another way to search for a specific package. The syntax is:yum list [package_name]
For example:yum list firefox

Note: Although the
search
and list
options are used to find a package, yum search
is more comprehensive. Running yum search
outputs results with the keyword in the package name, summary, or description. Running yum list
only looks for the search term in the package name.sudo yum install [package_name]
For example, to install the Firefox package, run:sudo yum install firefox

-y
flag to the command to answer yes to all prompts.Package Management with YUM
YUM allows users to manage the installed packages, get details, and update or remove them. Follow the instructions below to learn how to complete those actions.Note: Learn the difference between RPM and YUM, two RedHat-based package managers.
list
option followed by the --installed
flag allows you to see the information about all installed packages:yum list --installed

info
option shows details about a specified package. The syntax is:yum info [package_name]
For example, to get details about the Firefox package, enter:yum info firefox

update
option to keep all the packages up to date and to ensure you have the latest software on the machine. Run the following command:sudo yum update

python3
package, run:yum update python3

remove
option and passing the package name. The syntax is:yum remove [package_name]
For example, to remove Firefox, run:yum remove firefox

Repository Management with YUM
A software repository contains software packages, files, databases, or information accessible over a network. YUM allows users to configure which repositories the tool uses by adding new repos or removing existing ones.Display Existing RepositoriesTo see a list of software repositories enabled on your machine, run:yum repolist

- By adding a
[repository]
section to the /etc/yum.conf file. - By adding a .repo file in the /etc/yum.repos.d/ directory, which is the recommended way.
yum-utils
package installed first. If it's not installed on your system, install it by running:sudo yum install -y yum-utils
2. Add the repository using the following syntax:sudo yum-config-manager
--add-repo
[repository_URL]
For [repository_url]
, specify the repo URL. For example, to add the Docker repository, run:sudo yum-config-manager
--add-repo
https://download.docker.com/linux/centos/docker-ce.repo

yum-config-manager --disable [repository_ID]
For [repository_ID]
, specify the unique repo ID obtained by listing all repositories:yum repolist all

docker-ce-stable
. Enter this command to disable the Docker repository:yum-config-manager --disable docker-ce-stable

What Is APT?
APT (Advanced Packaging Tool) is an open-source package management tool used for installing, updating, upgrading, uninstalling, and configuring software packages on Debian-based Linux distributions. The tool works with repositories and installs any package dependencies automatically.Note: Learn the difference between apt and apt-get or the difference between Snap and APT.
Installing Packages with APT
Install packages using APT by searching for a package in a repository and installing it via the CLI or a GUI app if you are using one.Follow the instructions below to search for a package and install it.Search for PackagesSearch for a package with a specific keyword in its name or description using thesearch
option. The syntax is:apt search [package_name]
For [package_name]
, specify a keyword to search for. For example, to search for openssh packages, run:apt search openssh

sudo apt install [package_name]
For example, to install the openssh-server
package, run:sudo apt install openssh-server

-y
flag to the command to automatically answer yes to all prompts.Install Specific Package VersionInstall a particular package version by specifying the version you want to install. Follow the steps below:1. See which package versions are available using the following syntax:apt-cache showpkg [package_name]
For example:
apt install [package_name]=[version_number]
For example:
sudo apt install package1 package2 package3
Provide the package names separated by spaces. For example:
docker
and nginx
packages. Add as many package names as needed.Reinstall a PackageReinstalling a package is sometimes necessary if the installation fails, the package is corrupted, or some files are missing. Reinstall a package using the syntax below:sudo apt reinstall [package_name]
In the following example, we reinstall the docker
package:
Package Management with APT
Package management with APT involves listing installed packages, obtaining package details, and upgrading or removing installed packages.List PackagesAPT allows users to list packages in a repository or the packages installed on the system. To do so, use this command:apt list
Since the list is very long, containing thousands of packages, pipe the output into a pager such as less for easier navigation. For example:apt list | less
Alternatively, to list only the installed packages, run:apt list --installed

apt show [package_name]
For example:
sudo apt update

sudo apt upgrade -y
Enter the password and wait for the process to finish.To update every package and their dependencies, run:sudo apt full-upgrade
Note: Upgrading the packages and their dependencies involves uninstalling existing software and installing new software if the upgrade process requires it.
sudo apt install --only-upgrade [package_name]
For example:
remove
option. The syntax is:sudo apt remove [package_name]
For example, to remove the MySQL package we previously installed, run:sudo apt remove mysql-server

purge
option. For example:sudo apt purge mysql-server

Repository Management with APT
The APT software repositories are defined in the /etc/apt/sources.list file, or as individual files under the /etc/apt/sources.list.d/ directory.Although the default APT repository contains thousands of applications, sometimes the software you need must be installed through a third-party repository.This section shows how to add a third-party repository or remove one.Add a RepoAdding a repository to APT sources has two steps:- Adding the repository GPG key.
- Installing the repo using the
add-apt-repository
command.
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -

add-apt-repository
command:sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu focal stable"

add-apt-repository
command with the --remove
option. The syntax is:sudo add-apt-repository --remove [ppa]
For [ppa]
, specify the repository name/URL. For example, to remove the Docker repo we previously added, run:sudo add-apt-repository --remove 'deb [arch=amd64] https://download.docker.com/linux/ubuntu focal stable'
