Chapter #7 - Maintaining Software using APT and YUM
In this chapter, youβll learn to use APT and YUM to install, update, and remove software on Debian and Red Hat-based Linux systems.

Now that you've dipped your toes into shell scripting, it's time to level up your system management skills. One of the core responsibilities of any Linux user or admin is keeping software up to date, secure, and running smoothly.
In this chapter, youβll get hands-on with two of the most commonly used package managers in the Linux world: APT (used in Debian-based systems like Ubuntu) and YUM (used in Red Hat-based systems like CentOS).
Youβll learn how to effortlessly install new software, keep it updated, and remove packages you no longer need, all from the command line.
Hereβs what youβll learn in this chapter:
- Use apt or yum to search, install, update, or remove packages
- Understand package dependencies and how they're handled
- Learn how to update your system safely
- Troubleshoot common package management issues
- Explore extra resources for deeper learning
- Practice with real-world exercises to build your confidence
When we speak of package management in Linux, we refer to a method of installing and maintaining (which includes updating and probably removing as well) software on the system.
In the early days of Linux, programs were only distributed as source code, along with the required man pages, the necessary configuration files, and pretty much nothing more.
Nowadays, most Linux distributors use by default pre-built programs or sets of programs called packages, which are presented to users ready for installation on that distribution.
How Package Management Systems Work
If a certain package requires a certain resource, such as a shared library or another package, it is said to have a dependency. All modern package management systems provide some method of dependency resolution to ensure that when a package is installed, all of its dependencies are installed as well.
Almost all the software that is installed on a modern Linux system will be found on the Internet. It can either be provided by the distribution vendor through central repositories (which can contain several thousands of packages, each of which has been specifically built, tested, and maintained for the distribution) or be available in source code that can be downloaded and installed manually.
Because different distribution families use different packaging systems (Debian: *.deb
/ CentOS: *.rpm
), a package intended for one distribution will not be compatible with another distribution.
In order to perform the task of package management effectively, you need to be aware that you will have available two types of utilities: low-level tools (which handle in the backend the actual installation, upgrade, and removal of package files), and high-level tools (which are in charge of ensuring that the tasks of dependency resolution and metadata searching - "data about the data" - are performed).
DISTRIBUTION | LOW-LEVEL TOOL | HIGH-LEVEL TOOL |
---|---|---|
Debian and derivatives | dpkg | apt-get / aptitude |
CentOS | rpm | yum |
The most frequent tasks that you will do with high and low-level package management tools are listed in the following sections.
Installing a Package from a compiled (*.deb or *.rpm) file
The downside of this installation method is that no dependency resolution is provided. You will most likely choose to install a package from a compiled file when such a package is not available in the distributionβs repositories and therefore cannot be downloaded and installed through a high-level tool.
Since low-level tools do not perform dependency resolution, they will exit with an error if we try to install a package with unmet dependencies.
To illustrate, we will use a fictitious file named file.deb
for Debian and derivatives, and file.rpm
for CentOS and similar distributions:
dpkg -i file.deb
rpm -i file.rpm