The Linux Package Manager

Muhammad Qasim Nauman
4 min readJun 26, 2024

--

Hey Folks! hope you are doing well. I am back with insights on the Linux Package Manager.

Photo by Lukas on Unsplash

What is a Package Manager?

Package Manager is a tool to install, update, and manage the software on an OS. Each OS has its package manager and can be a GUI and CLI-based application.

We shall solely discuss the Linux Package Manager today. Linux uses CLI-based package managers and for each distribution of Linux, the package manager is different. Before moving on let’s first understand the package itself.

What is a Package?

The package refers to the actual application, library, or any tool that gets installed through the package manager. Typically a package contains the following components and are type dependent on OS.

Components of a Package

  • Executable files (main program or scripts)
  • Libraries (files on which executable files depend)
  • Configuration Files (Settings and options for the software)
  • Documentation (Readme or help files)
  • Metadata (Information about the package itself, such as its name, version, and dependencies)

Type of Packages

  • Debain Packages (.ded) — Used by Debain-based Linux distributions.
  • Red Hat (.rpm) — Used by Red Hat Linux distributions e.g. Fedora, CentOS.
  • Arch (.pkg.tar.zst) — Used by Arch Linux distributions.
  • macOS (.msg) — Used by MacOS.
  • Windows (.msi, .exe) — Used by Windows.

Types of Linux Package Managers

APT (Advanced Package Tool)

Used by Debain-based distributions e.g. Ubuntu, Debian.

Commands

#to install a package
sudo apt install packagename

#to update the packages
sudo apt update

#to upgrade all packages
sudo apt upgrade

#to remove a package
sudo apt remove packagename

#to search for any package
apt search packagename

YUM/DNF (Yellowdog Updater, Modified / Dandified YUM)

Used by Red-Hat-based distributions e.g. Fedora, CentOS.

Commands

#to install a package
sudo yum install packagename

#to update a package
sudo yum update

#to remove a package
sudo yum remove packagename

#to search for a package
yum search packagename

Pacman

Used by Arch and its derivative distributions.

Commands

#to install a package
sudo pacman -S packagename

#to update a package
sudo pacman -Syu

#to remove a package
sudo pacman -R packagename

#to search a package
pacman -Ss packagename

Zypper

Used by OpenSUSE and SUSE Linux Enterprise

Commands

#to install a package
sudo zypper install packagename

#to update packages
sudo zypper update

#to remove a package
sudo zypper remove packagename

#to search for a package
zypper search packagename

Homebrew

Used by MacOS and some distributions of Linux

Commands

#to install a package
brew install packagename

#to update packages
brew update

#to remove a package
brew uninstall packagaename

#to search for a package
brew search packagename

Bored with theory, let’s move on to hands-on and we will explore some more important and use full commands. We will install two of the most important software required by DevOps namely Docker and Jenkins.

I am using Ubuntu which is a Debian-based distribution and uses the APT package manager.

To install Docker we first need to update the previously available packages. For that we use

sudo apt update

After all the updates are done we will begin with the installation of docker. For that, we will use

sudo apt install docker.io

This will first download and install docker on your machine. Now to check for the status that docker is running or not we use the command systemctl. As docker is a service running on your machine we need to interact with the systemd service manager for Linux OS as it is responsible for managing the services. For that, we systemctl as it helps to interact with the service manager. Today we will learn how to start and check the status of a service.

Now we will check the status of docker. For that, we will use the following command.

sudo systemctl status docker

This will tell in which state the docker service is in. We can use it to check the status of other services like Nginx, apache which are web servers as well. We will learn them later on. The following command gives the following output.

As we install docker it is started by default right after the installation but if it does not we can do it with one simple command.

sudo systemctl start docker

This will start the docker service. Similarly, we can restart and stop the docker service as well. For that, we use the following commands.

#To Restart
sudo systemctl restart docker

#To stop
#first
sudo systemctl stop docker

#and then
sudo systemctl stop docker.socket

Now that we installed docker, we will install another tool, Jenkins. An open-source automation server that helps automate the parts of software deployment related to building, testing, and deploying, facilitating continuous integration, and continuous delivery. It is a server-based system that runs in servlet containers such as Apache Tomcat.

Now to install Jenkins we use the following commands

#First we run this to get the packages
sudo wget -O /usr/share/keyrings/jenkins-keyring.asc \
https://pkg.jenkins.io/debian/jenkins.io-2023.key
echo "deb [signed-by=/usr/share/keyrings/jenkins-keyring.asc]" \
https://pkg.jenkins.io/debian binary/ | sudo tee \
/etc/apt/sources.list.d/jenkins.list > /dev/null

#After we install jenkins
sudo apt update
sudo apt install jenkins

But there arises a problem. We also need Java installed as well. To install Java we use the following command

sudo apt install fontconfig openjdk-17-jre

This installs OpenJDK version 17, we can change that as well according to needs. After all this, we need to start the service of it and we can start using it.

So, this was all from the basics of package manager. Hope you learnt something new.

Thank You for giving it a read. Have a nice day!

--

--