Day 7 of #90DaysOfDevOps

Basavaraj TeliBasavaraj Teli
4 min read

Package manager in Linux

Introduction to Linux package management

Package management is the process of installing, updating, and removing software packages on a Linux system. Linux distributions come with their own package managers, which allow users to install, remove, and update software packages easily. Package managers keep track of dependencies, so users don’t need to worry about installing packages that rely on other packages.

What is package?

Archives that contain the pre-compiled binary software files, installation scripts, configuration files, dependency requirements, and other details about the software.

Package Managers

There are several package managers available for different Linux distributions. The most common ones are APT, YUM, Pacman, DNF, and zypper. These package managers have similar functionalities, but their commands may differ slightly.

APT Package Manager

APT (Advanced Packaging Tool) is a package manager used by Debian, Ubuntu, and other Debian-based Linux distributions. APT can be used to install, update, and remove packages. The APT package manager uses a centralized package repository, which can be accessed through the command line or through a graphical user interface.

YUM Package Manager

YUM (Yellowdog Updater Modified) is a package manager used by Red Hat, Fedora, CentOS, and other Red Hat-based Linux distributions. YUM can be used to install, update, and remove packages. YUM uses a centralized package repository, which can be accessed through the command line or through a graphical user interface.

Basic commands for package management

Updating the package list

For APT, the command is:

sudo apt update

For YUM:

sudo yum check-update

Updating packages/system

To update all installed packages (a system update), use the following command:

For APT:

sudo apt upgrade

For YUM:

sudo yum update

Installing packages :

To install a package, use the following command:

For APT:

sudo apt install [package name]

Installing Jenkins on Ubuntu

sudo wget -O /usr/share/keyrings/jenkins-keyring.asc https://pkg.jenkins.io/debian-stable/jenkins.io-2023.key

echo 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

sudo apt-get update

sudo apt-get install jenkins

For YUM:

sudo yum install [package name]

Removing packages :

To remove a package, use the following command:

For APT:

sudo apt remove [package name]

For YUM:

sudo yum remove [package name]

Searching for packages :

To search for a package, use the following command:

For APT:

apt search [package name]

For YUM:

yum search [package name]

Getting more information about a package :

To get more information about a package, such as its description and version, use the following command:

For APT:

apt show [package name]

For YUM:

yum info [package name]

What is systemd in linux?

systemd is an init system and system manager for Linux operating systems. It is a collection of programs and libraries, not a single binary. systemd is responsible for starting and managing processes on the system, including system services, user programs, and daemons.

Managing services with systemd:

Below is the list of some useful systemd utilities along with a brief description of what they do:

  • systemctl: It Controls the systemd system and services.

  • journalctl: Used To manage journal, systemd’s own logging system

  • hostnamectl: Can Control hostname.

  • localectl: Helps Configure system local and keyboard layout.

  • timedatectl: Used to Set time and date.

  • systemd-cgls : It Shows cgroup contents.

  • systemadm: It is a Front-end for systemctl command.

What is systemctl?

Systemctl is a command-line tool that allows for the management and monitoring of the systemd system and service manager.

Check Service Status - systemctl status service_name.service

Starting a Service - systemctl start service_name.service

Stopping a Service - systemctl stop service_name.service

Restarting a Service - systemctl restart service_name.service

To avoid manually stopping and starting a running service, you can use the restart command to initiate a service restart.

Reloading a Service - systemctl reload service_name.service

In some cases, it may not be necessary to perform a complete service restart to apply any configuration changes made. Instead, you can use the reload command to initiate a service reload, which allows the service to re-read its configuration files and implement any changes without the need to restart.

0
Subscribe to my newsletter

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

Written by

Basavaraj Teli
Basavaraj Teli

Aspiring DevOps engineer, working on DevOps projects to gain practical knowledge. I write technical blog post on DevOps to share my knowledge with fellow tech enthusiasts.