DEV Community

Cover image for Package Management in Linux System
yash sugandh
yash sugandh

Posted on

Package Management in Linux System

In the last few posts, we explored Permissions in Linux System and Changing Permissions in Linux System.

Today, let's take a step in a different direction and understand Package management in Linux System.

Package management is a method of installing and maintaining(update, remove, manage dependency, etc) software in the system.

Softwares are usually distributed in packages and stored in repositories.

Earlier, one had to download and compile source code to install the software.

Now, most of the modern Unix-like operating systems offer a centralized mechanism for finding and installing software.

But before we jump into how the package management system works, let's look into what are the advantages of using it

  • Ease of installation and removal of software
  • To keep track of updates and upgrades
  • To provide consistent usage throughout the devices.
  • To manage dependencies while installing a new software

Okay, there are different Linux distributions. Do all of them use the same packaging management system?

No, different distributions use different packaging management systems.

So, a package intended for one distribution is generally not compatible with another distribution.

How a Package System Works

Most package management systems are built around collections of package files.

A package file is a collection of files that comprise the software package.

A package may consist of numerous package files and pre- and post-installation scripts that perform configuration tasks before and after the package installation.

Package management systems usually consist of two types of tools.

  • Low-level tools which handle tasks such as installing and removing package files

  • High-level tools that perform metadata searching and dependency resolution

The functionality may be similar in all the distributions but their tools are different

Distribution Format Low Level Tool High Level Tool
Debian .deb dpkg apt,apt-cache,apt-get,aptitude
Ubuntu .deb dpkg apt,apt-cache,apt-get
CentOS .rpm rpm yum
Fedora .rpm rpm dnf
  • dpkg

dpkg is a low-level tool to install, build, remove and manage Debian packages.

  • apt

apt provides a high-level command-line interface for the package management system.

It is intended as an end-user interface and enables some options better suited for interactive usage.

  • aptitude

aptitude is a text-based interface package management system.

It allows the user to view the list of packages and to perform package management tasks such as installing, upgrading, and removing packages.

  • rpm

RPM is a package management system used to build, install, verify, update, and uninstall software.

  • yum

yum is the high level tool for getting, installing, deleting, querying, and managing Red Hat Enterprise Linux RPM software packages.

  • dnf

DNF or Dandified YUM is the next-generation version of the Yellowdog Updater, Modified. It is used for getting, installing, deleting, querying, and managing Red Hat Enterprise Linux RPM software packages.

Let's have a look at how do we use these tools:

Debian and Ubuntu

dkg

Task Command
Install a .deb file dpkg -i package-file-name.deb
Remove a .deb file dpkg -r package-file-name.deb
List installed Packages dpkg --list search-pattern
Check if a package is installed dpkg -s package-name
location of installed file dpkg -L package-name

apt

Task Command
Installs the package(s) with dependency apt-get install package-name(s)
Remove the package(s) but not dependency apt-get remove package-name(s)
Remove unused dependency apt-get autoremove
Update Package List apt-get update
search Packages apt search search_string
get info about a package apt show package

CentOS and Fedora

rpm

Task Command
Install a .rpm file rpm -i package-file-name.rpm
Remove a .npm file rpm --erase package-name(s)
Listing Installed Files rpm -qa
Check if a given package is installed rpm --query package-name(s)

yum

Task Command
Installs the package(s) with dependency yum install package-name(s)
Remove the package(s) but not dependency yum erase package-name(s)
Update Package List yum update
search Packages yum search search-pattern
get info about a package yum info package-name(s)

dnf

Task Command
Installs the package(s) with dependency dnf install package-name(s)
Remove the package(s) but not dependency dnf remove package-name(s)
Update Package List dnf upgrade
search Packages dnf search search-pattern
get info about a package dnf info package-name(s)

These are the most common functionalities that these Package Managers Provide.

Hope this will help you better understand the Package management in Linux.

See you in funny papers 🚀

Top comments (2)

Collapse
 
glabrie profile image
Guillaume

It's a really nice series so far, thank you!
I feel like this one is missing a bit on containerized apps management (flatpak,snap,appimage) and alternative package management systems (like PKGBUILD or Nix). That'd make this otherwise really nice introduction pretty complete.

Collapse
 
yashsugandh profile image
yash sugandh

Thanks a lot for the feedback. I will try and cover the rest of the topics in the next post :)