Understanding package manager and systemctl

Understanding package manager and systemctl

#90 Days of DevOps Challenge - Day 7

What is a package manager in Linux?

In simpler words, a package manager is a tool that allows users to install, remove, upgrade, configure and manage software packages on an operating system. The package manager can be a graphical application like a software center or a command line tool like apt-get or pacman.

You’ll often find me using the term ‘package’ in tutorials and articles, To understand package manager, you must understand what a package is.

What is a package?

In Linux a package is a compressed software archive file that contains all the files that comes with a software application delivers any kind of functionality, this can be any kind of command line utility,GUI application or a software library.

A package may consist of a binary executable, configuration file and other software dependencies. Common types of Linux packages include .deb, .rpm, and .tgz. Linux packages don't usually contain the dependencies necessary to install them, therefore Linux distributions use package managers to automatically read dependencies files and download the packages needed before proceeding with the installation.

The package usually includes a manifest of dependencies that must be satisfied for a software application to execute as expected on any give Linux computer.

Common Package Managers in Linux include:

  • dpkg (Debian Package Manager)

  • APT (Advanced Package Tool)

  • rpm (RedHat Package Manager)

  • yum (Yellowdog Update Modified)

  • dnf (Dandified Yum)

Different kinds of package managers

Package Managers differ based on packaging system but same packaging system may have more than one package manager.

For example, RPM has Yum and DNF package managers. For DEB, you have apt-get, aptitude command line based package managers.

  • Install docker in your system from your terminal using package managers

Step 1:- Update your system packages by running the following command

sudo apt-get update
sudo apt-get upgrade -y

Step 2:- Need to Install Docker


sudo apt-get install docker.io -y

Step3:- To check the version ned to tun below command

docker --version
or 
docker -v

Step 4:- To check the Docker service status

systemctl status docker

Step 5:- If the docker service not yet started then need to run below command to start docker service

systemctl start docker

Step 6:- Verify that Docker is running correctly by running the below command

sudo docker run hello-world

  • Install jenkins in your system from your terminal using package managers

Step 1:- Update your system packages by running the following command

sudo apt-get update
sudo apt-get upgrade -y

Step 2:- Need to install java by following command

sudo apt-get install openjdk-11-jdk -y

Step 3:- To check the java version

java --version

Step 4:- Then run the below command to install jenkins

curl -fsSL https://pkg.jenkins.io/debian/jenkins.io-2023.key | sudo tee \
  /usr/share/keyrings/jenkins-keyring.asc > /dev/null

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

sudo apt-get update
sudo apt-get install jenkins -y

Step 5:- You can enable the Jenkins service to start by following command

 sudo systemctl enable jenkins

Step 6:- You can start and stop the Jenkins service with the command:

sudo systemctl start jenkins

sudo systemctl stop jenkins

Step 7:- Check the status of the Jenkins service using the command:

sudo systemctl status jenkins

Step 8:- To unlock the unlock Jenkins need to run below commands

sudo cat /var/lib/jenkins/secrets/initialAdminPassword

Systemctl and Systemd

Systemd is a system and service manager for Linux operating systems, which provides a range of features such as service management, process tracking, and logging.
One of the key components of systemd is the systemctl command-line tool, which is used to control and manage system services. systemctl allows users to start, stop, restart, enable, disable, and check the status of services.

Check the status of docker service in your system

systemctl status docker

  • Stop the service jenkins and post before and after screenshots

Before stopping service :-

After stopping service:-

  • Systemctl vs Service

systemctlservice
The systemctl command is a utility which is responsible for examining and controlling the systemd system and service manager. It is a collection of system management libraries, utilities and daemons which function as a successor to the System V init daemon. The new systemctl commands have proven quite useful in managing a servers services. It provides detailed information about specific systemd services, and others that have server-wide utilization.A variety of services run continuously on a Linux background, such as network and system services. Services running on Linux are also known as daemons, which refers to a group of processes working on the back-end. Services can be managed and listed through different methods and tools. The Systemd is a software suite of tools with the ability to manage Linux systems adopted by Linux distribution as a drop-in replacement of the init process. All system tasks can be controlled through Systemd. The process can be started or ended using this tool, and all enabled and disabled services information can also be listed with Systemd.
Command:- sudo systemctl start apache2Command:- sudo service apache2 start

Devops#devops,#90daysofDevOps

Thank you for reading!! I hope you find this article helpful!!

if any query or if any correction to be done in this blog please let me know.

Happy Learning!!

Saikat Mukherjee

Did you find this article valuable?

Support Saikat Mukherjee's blog by becoming a sponsor. Any amount is appreciated!