Day-07 Task: Understanding package manager and systemctl

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.
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.
Tasks
You have to install docker and Jenkins in your system from your terminal using package managers
Docker Installation
Before installation run the update command
#sudo apt update
#sudo apt install docker.io
Check status after installation
#sudo systemctl status docker
Jenkins Installation
Update Your Package Lists Before installing Jenkins, make sure your system has the latest package information.
#sudo apt update
Browse to Jenkin's site and follow the instructions
https://pkg.jenkins.io/debian-stable/
# sudo wget -O /usr/share/keyrings/jenkins-keyring.asc \ https://pkg.jenkins.io/debian-stable/jenkins.io-2023.key
# echo deb [signed-by=/usr/share/keyrings/jenkins-keyring.asc] \ https://pkg.jenkins.io/debian-stable binary/ | sudo tee \ /etc/apt/sources.list.d/jenkins.list > /dev/null
#sudo apt-get update
#sudo apt-get install fontconfig openjdk-11-jre
#sudo apt-get install jenkins
Check Jenkins status.
#sudo systemctl status jenkins
To start Jenkins
#sudo systemctl start jenkins
To stop Jenkins
#sudo systemctl stop jenkins
Enable Jenkins on Boot Ensure Jenkins starts automatically on system boot.
#systemctl enable jenkins
Access Jenkins Web Interface Jenkins runs on port 8080 by default. Open your browser and navigate to http://your_server_ip_or_domain:8080.
http://3.111.169.99:8080
If a website is not reachable check the Ec2 instance security group and add a new rule.
Unlock Jenkins Retrieve the initial password required to unlock Jenkins.
#cat /var/lib/jenkins/secrets/initialAdminPassword
e809562f0a5f4eea889025f986185336
Copy the password and paste it into the Jenkins web interface.
Customize Jenkins Install suggested plugins or select custom plugins based on your requirements.
Write a small blog or article to install these tools using package managers on Ubuntu and CentOS.
Streamlining Your Setup: Installing Essential Tools on Ubuntu and CentOS with Package Managers
Introduction: Setting up a new environment can be a daunting task, but with the right tools and package managers, you can simplify the process and get up and running in no time. In this guide, we'll walk you through the installation of some essential tools using package managers on both Ubuntu and CentOS.
1. Ubuntu:
Update your package lists:
sudo apt update
1.1 Git:
sudo apt install git
Git is a version control system that allows you to track changes in your codebase efficiently.
1.2 Docker:
sudo apt install docker.io
Docker enables you to containerize applications, making them portable and easy to deploy across different environments.
2. CentOS:
Update your package lists:
sudo yum update
2.1 Git:
sudo yum install git
Just like on Ubuntu, Git is essential for version control and collaboration on projects.
2.2 Docker:
sudo yum install docker
Docker on CentOS provides the same containerization benefits, allowing you to isolate applications and their dependencies.
systemctl is used to examine and control the state of the “systemd” system and service manager. system is a system and service manager for Unix-like operating systems(most of the distributions, not all).
Tasks
check the status of the docker service in your system (make sure you completed the above tasks, else docker won't be installed)
#sudo systemctl status docker
stop the service Jenkins and post before and after screenshots
Before
After
read about the commands systemctl vs service
eg. systemctl status docker
vs service docker status
Both systemctl
and service
are commands used in Linux systems to manage services, but they have some differences in usage and functionality.
systemctl
:
Systemd Integration:
systemctl
is part of the systemd system and service manager, which has become the standard init system for many Linux distributions. It is responsible for managing system processes and services during the system boot process.Extensive Feature Set:
systemctl
provides a more extensive set of features compared toservice
. It allows you to control and query the state of services, manage dependencies, view logs, enable or disable services at boot, and more.Unified Interface:
systemctl
offers a unified interface for interacting with various types of units, not just services. This includes targets, devices, mounts, and sockets.Enhanced Logging: Systemd provides enhanced logging capabilities, and
systemctl
allows you to view and analyze these logs easily.
service
:
Traditional SysV Init System:
service
is associated with the traditional SysV init system, which was the default init system for many older Linux distributions.Simplified Interface:
service
provides a simplified interface for starting, stopping, restarting, and checking the status of services. It is often used with simple service management tasks.Limited Functionality: While
service
is straightforward and easy to use, it has limited functionality compared tosystemctl
. It lacks some of the advanced features provided by systemd.
Common Commands:
Start a Service:
systemctl start <service-name> service <service-name> start
Stop a Service:
systemctl stop <service-name> service <service-name> stop
Restart a Service:
systemctl restart <service-name> service <service-name> restart
Check Service Status:
systemctl status <service-name> service <service-name> status
Summary, systemctl
is the more powerful and feature-rich command, especially in systems using systemd, while service
is a simpler tool associated with the older SysV init system.
Subscribe to my newsletter
Read articles from Irfan S Momin directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by

Irfan S Momin
Irfan S Momin
A Foodie Software Engineer's Journey to Eating Healthy and Learning Something New Every Day