#Day7 #90DaysofDevOps Understanding Package Manager and Systemctl:

Rohit KadolkarRohit Kadolkar
4 min read

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.

What is a package?

A package is usually referred to an application but it could be a GUI application, command line tool or a software library (required by other software programs). A package is essentially an archive file containing the binary executable, configuration file and sometimes information about the dependencies.

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.

How to install Docker

  1. Remove docker if already installed

    sudo apt-get remove docker docker-engine docker.io

  2. Update package list

sudo apt-get update

  1. Install Docker package

sudo apt install docker.io

  1. Install dependency packages

sudo snap install docker

  1. Check version of docker

docker -- version

  1. Pull an image from docker hub using following command

sudo docker run hello-world

  1. Check if docker image has been pulled and is present in the system

sudo docker images

  1. To display all the containers pulled, use following

sudo docker ps -a

  1. To check containers in running state, use following

sudo docker ps

How to install Jenkins

  1. Install Java

    sudo apt-cache search openjdk

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

  1. Check Java version

    java --version

  1. Update package list

sudo apt update

  1. Add the repository key to the system:

wget -q -O - https://pkg.jenkins.io/debian-stable/jenkins.io.key | sudo apt-key add -

  1. Next, let’s append the Debian package repository address to the server’s sources.list:

sudo sh -c 'echo deb http://pkg.jenkins.io/debian-stable binary/ > /etc/apt/sources.list.d/jenkins.list'

  1. After both commands have been entered, we’ll run update so that apt will use the new repository

sudo apt update

  1. Finally, we’ll install Jenkins and its dependencies.

sudo apt install jenkins

  1. Starting jenkins

sudo systemctl start jenkins

  1. Since systemctl doesn’t display status output, we’ll use the status command to verify that Jenkins started successfully:

sudo systemctl status jenkins

  1. Opening the Firewall port 8080

sudo ufw allow 8080

  1. Check status

sudo ufw status

  1. If status is inactive

sudo ufw allow OpenSSH

sudo ufw enable

  1. Check status again

sudo ufw status

  1. Setting up Jenkins

To set up your installation, visit Jenkins on its default port, 8080, using your server domain name or IP address: http://your_server_ip_or_domain:8080

  1. Here It will ask for a password to log in as path of the password is highlighted in red colour just copy it and paste into your browser:

systemctl and system:

  • Systemd is a system and service manager, while systemctl is a command-line utility for managing system services.

  • Systemd provides a suite of daemons, libraries, and utilities to manage system components, while systemctl is a specific tool within that suite.

check the status of the docker service in your system:

Check the status of the Docker service on your Linux system using the following command in the terminal:

sudo systemctl status docker

To Stop the Service:

To stop the Docker service, you can use the following command in the terminal:

sudo systemctl stop docker

This will stop the Docker service immediately. If you want to prevent the service from starting automatically at boot, you can also disable it using the following command:

sudo systemctl disable docker

check the status of Jenkins service in your system:

sudo systemctl status jenkins

To Stop the Service:

To stop the Jenkins service, you can use the following command in the terminal:

sudo systemctl stop jenkins

systemctl

The systemctl command manages both system and service configurations, enabling administrators to manage the OS and control the status of services. Further, systemctl is useful for troubleshooting and basic performance tuning.

service

The service command starts, stop and restart a daemon or services by calling the script. Usually all scripts are stored in /etc/init. d directory. It runs a script in as predictable environment as possible.

systemctl vs service

systemctl is basically a more powerful version of service. With service you can only do commands related to the service (i.e. status, reload, restart) whereas with systemctl you can use more advanced commands such as: systemctl is-failed name.service # check if service failed to load

0
Subscribe to my newsletter

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

Written by

Rohit Kadolkar
Rohit Kadolkar

DevOps Enthusiast