Day 7 Task: Understanding package manager and systemctl

Day 7 Task: Understanding package manager and systemctl

·

4 min read

Day 7 of 90daysofdevops

#devops #90daysofdevops #linux

TABLE OF CONTENTS

What is a package manager in Linux?

A package manager is a tool that allows users to install, remove, upgrade, configure and manage software packages. Package managers typically have command-line interfaces, although many also have graphical interfaces.
Some popular Linux package managers include apt, dpkg, yum, pacman, and zypper, each of which is used by different Linux distributions.

What is a package?

A package is a collection of files and information that is bundled together for the purpose of installing or distributing software. Each package contains the files needed to install and run a particular piece of software, as well as information about dependencies and installation instructions.
Linux packages can take various formats depending on the package manager and distribution. For example, Debian-based distributions such as Ubuntu use .deb packages, while Red Hat-based distributions such as Fedora use .rpm packages.

Different kinds of package managers

There are several different package managers used in Linux, each with its own set of features and capabilities.

  • APT: Advanced Package Tool is a command-line tool used on Debian-based distributions, such as Ubuntu and Debian itself.

  • YUM/DNF: Yellowdog Updater, Modified (YUM) and Dandified YUM (DNF) are command-line tools used on Red Hat-based distributions, such as Fedora and CentOS.

  • Pacman: Pacman is a command-line tool used on Arch Linux and its derivatives.

  • Zypper: Zypper is a command-line tool used on openSUSE and SUSE Linux Enterprise.

  • Portage: Portage is a package manager used on Gentoo Linux.

  • Snap: Snap is a package manager used on Ubuntu and other Linux distributions.

  • Flatpak: Flatpak is a package manager used on various Linux distributions.

Install docker

Remove any docker file that are running in the system.

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

Check if the system is up-to-date.

sudo apt-get update

Install Docker

sudo apt install docker.io

Install all the dependency packages

sudo snap install docker

Check the installed version of docker

docker --version

Install Jenkins

Jenkins requires the Java Runtime Environment (JRE).

Install Java

sudo apt install openjdk-11-jdk -y

It is recommended to install Jenkins using the project-maintained repository, rather than from the default Ubuntu repository. The reason for that is because 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 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

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

sudo systemctl status jenkins

ystemctl 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, 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 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