Day 7 - Understanding package manager and systemctl with Jenkins and Docker

Day 7 - Understanding package manager and systemctl with Jenkins and Docker

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?

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.

Jenkins Installation commands

sudo apt-get update
sudo apt install openjdk-11-jre -y
java -version
$ 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
$ sudo usermod -aG jenkins $USER
$ sudo systemctl status jenkins
$ sudo systemctl enable jenkins

$ sudo passwd ubuntu

$ sudo nano /etc/ssh/sshd_config

$ sudo systemctl restart sshd

Create user/password and click on save and continue

Click on save and Finish

Jenkins runs on port no 8080, so enable the port in security inbound rules and access the publicip:8080

Stop and start the Jenkins service

Docker Installation commands :

$ sudo apt-get update
$ sudo apt install apt-transport-https ca-certificates curl software-properties-common -y
$ curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
$ sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu focal stable"
$ apt-cache policy docker-ce
$ sudo apt install docker-ce -y
$ sudo usermod -aG docker $USER
$ sudo systemctl status docker
$ sudo reboot

$ docker ps

Add the user to the docker group and reboot the VM to fix permission denied issue

Start the VM and use the below commands to check if the docker is working

$ docker ps - Gives the response, so docker is working fine

Stopping a docker service :

systemctl and Service difference

systemctl is used to examine and control the state of “systemd” system and systemctl and service are both commands used in Linux for managing services, but they operate differently and are associated with different service management systems.

systemctl is a central management tool for controlling the systemd system and service manager, which is a replacement for the traditional SysV init system.

systemctl can be used to start, stop, restart, enable, disable, and check the status of services.

service is a command used in systems that use the SysV init system for service management. It's a simpler command compared to systemctl.

It is often used to start, stop, and check the status of services.