Day-7 of DevOps Challenge: Demystifying Package Managers and systemctl

Akash RastogiAkash Rastogi
4 min read

What is a package manager in Linux?

A package manager in Linux is a tool that automates the process of installing, upgrading, configuring, and removing software packages from a computer's operating system. These packages typically contain binaries, libraries, configuration files, and metadata like the package's name, description, and dependencies.

Key Functions of a Package Manager:

Installation: Easily install software packages from repositories.

Upgrades: Keep software up to date with minimal effort.

Dependency Resolution: Automatically handle the dependencies required by software packages.

Uninstallation: Remove software packages cleanly from the system.

Repositories Management: Add, remove, and update software repositories.

Examples of Package Managers:

APT (Advanced Package Tool): Used primarily in Debian-based distributions like Ubuntu.

Commands: apt-get, apt, apt-cache

Yum (Yellowdog Updater, Modified) and DNF (Dandified Yum): Used in Red Hat-based distributions like Fedora and CentOS.

Commands: yum, dnf

Pacman: Used in Arch Linux and its derivatives.

Commands: pacman

Zypper: Used in openSUSE.

Commands: zypper

RPM (Red Hat Package Manager): Used in various RPM-based distributions.

Commands: rpm

Snap: A universal package manager developed by Canonical.

Commands: snap

Flatpak: Another universal package manager that aims to provide a consistent environment across different Linux distributions.

Commands: flatpak

What is a package?

In the context of Linux and software management, a package is a collection of files and metadata that together form a piece of software. This package can be easily distributed, installed, and managed by a package manager.

Components of a Package:

Binaries: The executable files that perform the software's functions.

Libraries: Shared code that the software needs to run.

Configuration Files: Settings and preferences for the software.

Documentation: Manuals or help files.

Metadata: Information about the package, including its name, version, description, dependencies, and maintainer.

Different kinds of package managers

APT

Where: Ubuntu and Debian.

What It Does: Helps you find, install, and remove software.

Example Command: sudo apt install firefox (to install Firefox).

YUM and DNF

Where: Fedora, CentOS, Red Hat.

What It Does: Manages software for you, including updates and removals.

Example Command: sudo dnf install firefox (to install Firefox).

Pacman

Where: Arch Linux.

What It Does: Quickly installs and removes software.

Example Command: sudo pacman -S firefox (to install Firefox).

Zypper

Where: openSUSE.

What It Does: Handles software management, including dependencies.

Example Command: sudo zypper install firefox (to install Firefox).

RPM

Where: Various RPM-based systems.

What It Does: Installs and removes individual software packages.

Example Command: sudo rpm -i firefox.rpm (to install Firefox).

Snap

Where: Many different Linux systems.

What It Does: Provides universal, containerized software.

Example Command: sudo snap install firefox (to install Firefox).

Flatpak

Where: Many different Linux systems.

What It Does: Offers sandboxed applications.

Example Command: sudo flatpak install flathub org.mozilla.firefox (to install Firefox).

Conda

Where: Data science and scientific computing.

What It Does: Manages packages and environments for Python and other languages.

Example Command: conda install numpy (to install NumPy).

Homebrew (Linuxbrew)

Where: macOS and Linux.

What It Does: Simplifies installing software, especially development tools.

Example Command: brew install wget (to install wget).

I have performed some tasks that might help everyone understand Package Managers and systemctl

You have to install docker and Jenkins in your system from your terminal using package managers

Installing Docker and Jenkins on CentOS

Step 1: Update Your System

Start by updating your system to ensure all existing packages are up to date.

bashCopy codesudo apt update

sudo apt upgrade -y

Step 2: Install Docker

Install Required Packages:

bashCopy codesudo apt install apt-transport-https ca-certificates curl software-properties-common -y

Add Docker’s GPG Key:

bashCopy codecurl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg

Add Docker Repository:

bashCopy codeecho "deb [arch=amd64 signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null

Install Docker:

bashCopy codesudo apt update

sudo apt install docker-ce -y

Start and Enable Docker:

bashCopy codesudo systemctl start docker

sudo systemctl enable docker

Verify Docker Installation:

bashCopy codesudo docker --version

Step 3: Install Jenkins

Add Jenkins’ GPG Key:

bashCopy codecurl -fsSL https://pkg.jenkins.io/debian-stable/jenkins.io.key | sudo tee /usr/share/keyrings/jenkins-keyring.asc > /dev/null

Add Jenkins Repository:

bashCopy codeecho "deb [signed-by=/usr/share/keyrings/jenkins-keyring.asc] https://pkg.jenkins.io/debian-stable binary/" | sudo tee /etc/apt/sources.list.d/jenkins.list > /dev/null

Install Jenkins:

bashCopy codesudo apt update sudo apt install jenkins -y

Start and Enable Jenkins:

bashCopy codesudo systemctl start jenkins

sudo systemctl enable jenkins

Verify Jenkins Installation:

bashCopy codesudo systemctl status jenkins

Understanding systemctl and systemd

systemd

systemd is a system and service manager for Linux operating systems. It is designed to provide a central management and configuration point for the system, handling everything from booting the machine to managing system services and user sessions. Key features of systemd include parallel service startup, on-demand starting of daemons, and tracking of processes using control groups.

systemctl

systemctl is the command-line utility used to interact with systemd. It provides a range of commands to control and manage system services, check the status of services, enable or disable services at startup, and more.

Let's check the status of the Docker service

Steps to Start/Stop Jenkins Service and Check Status

0
Subscribe to my newsletter

Read articles from Akash Rastogi directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Akash Rastogi
Akash Rastogi