Understanding package manager and systemctl

Understanding package manager and systemctl

Day 7 of 90daysofdevops

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 lines tool like apt-get or Pacman.

To understand a package manager, you must understand what a package is.

What is a package?

A package is usually referred to as 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 the packaging system but the 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 using the package manager

Check if the system is up-to-date.

sudo apt-get update

Install Docker

sudo apt install docker.io -y

Install all the dependency packages

sudo snap install docker

Check the installed version of the docker

docker --version

Install Jenkins using the package manager

Jenkins requires the Java Runtime Environment (JRE).

Install Java

It is recommended to install Jenkins using the project-maintained repository, rather than from the default Ubuntu repository. The reason for that is the Jenkins version in the default Ubuntu repository might not be the latest available version, which means it could lack the latest features and bug fixes.

Add the Jenkins repository key: To ensure that the Jenkins package comes from a trusted source, add the Jenkins repository key to your system with the following command.

wget -q -O - https://pkg.jenkins.io/debian-stable/jenkins.io.key |sudo gpg --dearmor -o /usr/share/keyrings/jenkins.gpg

Add the Jenkins repository to your system:

sudo sh -c 'echo deb [signed-by=/usr/share/keyrings/jenkins.gpg] http://pkg.jenkins.io/debian-stable binary/ > /etc/apt/sources.list.d/jenkins.list'

Update your package manager's cache:

sudo apt update

Finally, install Jenkins:

sudo apt install jenkins

After installation, start the Jenkins service and check the status:

sudo systemctl start jenkins
sudo systemctl status jenkins

Opening the Firewall

sudo ufw allow 8080
sudo ufw allow OpenSSH
sudo ufw enable
sudo ufw status

systemctl and systemd

systemctl is used to examine and control the state of “systemd” system and service manager. systemd is a system and service manager for Unix-like operating systems(most of the distributions, not all).

Check the status of the docker service in your system

systemctl status docker

Stop the service Jenkins and post before and after screenshots

sudo systemctl status jenkins

sudo systemctl stop jenkins

Read about the commands systemctl vs service

systemctl and service are both command-line tools used for managing services in Linux systems.
The systemctl command manages both system and service configurations, enabling administrators to manage the OS and control the status of services. systemctl is useful for troubleshooting and basic performance tuning.
The service command starts, stops, and restarts a daemon or service by calling the script. Usually, all scripts are stored in /etc/init. d directory. It runs a script in as predictable an environment as possible.

systemctl provides a more efficient and powerful way to manage services, as well as other system resources such as timers and sockets.

systemctl status jenkins
service jenkins status

Thank you for reading!!