Day 7 Task: Understanding package manager and systemctl
Mastering Software Management and Service Control in Linux
Table of contents
- 🔶 What is a package manager in Linux?
- 🔶 What is a package?
- 🔶 Different kinds of package managers
- 🔶 Task 1: Install docker and Jenkins in your system from your terminal using package managers.
- 🔶 Task 2: Write a small blog or article to install these tools using package managers on Ubuntu and CentOS
- 🔶 systemctl and systemd
- 🔶 Task 3: Check the status of the docker service in your system (make sure you completed the above tasks, else docker won't be installed)
- 🔶 Task 4: Stop the service Jenkins and post before and after screenshots
- 🔶 Task 5: Read about the commands systemctl vs service
🔶 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 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.
APT package manager
APT (Advanced Package Tool) is a package management system used in Debian-based Linux distributions, such as Debian itself, Ubuntu, and Linux Mint. It is designed to simplify the installation, upgrading, and removal of software packages on a Linux system.
DNF package manager
DNF (Dandified Yum) is a package manager used in Fedora, RHEL (Red Hat Enterprise Linux), CentOS, and other RPM-based Linux distributions. It is the successor to the Yum package manager and offers enhanced performance, improved dependency resolution, and better version-locking capabilities.
YUM package manager
YUM (Yellowdog Updater Modified) is a package manager used in RPM-based Linux distributions, such as CentOS, Fedora, and Red Hat Enterprise Linux (RHEL). It provides an easy way to manage software packages by handling installation, updating, and removal of packages, as well as resolving dependencies between packages.
ZYpp package manager
ZYpp (Zypper Package Manager) is a package management tool used in openSUSE and SUSE Linux Enterprise distributions. It is designed to handle the installation, updating, and removal of software packages, as well as dependency resolution and repository management.
🔶 Task 1: Install docker and Jenkins in your system from your terminal using package managers.
🔶 Task 2: Write a small blog or article to install these tools using package managers on Ubuntu and CentOS
Installing Docker
Before you install Docker Engine for the first time on a new host machine, you need to set up the Docker repository. Afterward, you can install and update Docker from the repository.
Set up the repository
1. Update the apt
package index and install packages to allow apt
to use a repository over HTTPS:
sudo apt-get update sudo apt-get install ca-certificates curl gnupg
- Add Docker’s official GPG key:
sudo install -m 0755 -d /etc/apt/keyrings
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg
sudo chmod a+r /etc/apt/keyrings/docker.gpg
- Use the following command to set up the repository:
echo \
"deb [arch="$(dpkg --print-architecture)" signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu \
"$(. /etc/os-release && echo "$VERSION_CODENAME")" stable" | \
sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
Steps to Install Docker Engine
Update the
apt
package index:sudo apt-get update
Install Docker Engine, containers, and Docker Compose.
sudo apt-get install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
Verify that the Docker Engine installation is successful by running the hello-world image.
sudo docker run hello-world
Installing Jenkins
First of all, install Java:
#Update your system
sudo apt update
#Install java
sudo apt install openjdk-11-jre
#Validate Installation
java -version
#It should look somethStep - 1 Install Javaing like this
#openjdk version "11.0.12" 2021-07-20 OpenJDK Runtime Environment (build 11.0.12+7-post-Debian-2) OpenJDK 64-Bit Server VM (build 11.0.12+7-post-Debian-2, mixed mode, sharing)
To install Jenkins:
curl -fsSL https://pkg.jenkins.io/debian-stable/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-stable binary/ | sudo tee \
/etc/apt/sources.list.d/jenkins.list > /dev/null
sudo apt-get update
sudo apt-get install jenkins
To Start Jenkins:
#Enable the Jenkins service to start
sudo systemctl enable jenkins
#To start jenkins
sudo systemctl start jenkins
#To check the status of jenkins
sudo systemctl status jenkins
Browse to http://<server-ip>:8080 (or whichever port you configured for Jenkins when installing it) and wait until the Unlock Jenkins page appears.
#Use to generate passward to unlock
sudo cat /var/lib/jenkins/secrets/initialAdminPassword
Getting Started
Create First Admin User
Instance Configuration
Jenkins is ready
Jenkins Dashboard
🔶 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).
🔶 Task 3: Check the status of the docker service in your system (make sure you completed the above tasks, else docker won't be installed)
sudo service docker status
🔶 Task 4: Stop the service Jenkins and post before and after screenshots
#To check the status of jenkins
sudo systemctl status jenkins
#To Stop the jenkins
sudo systemctl stop jenkins
🔶 Task 5: Read about the commands systemctl vs service
eg. systemctl status docker
vs service docker status
systemctl
and service
are two different commands used in Linux to manage and control system services. They serve similar purposes but have some differences in their usage and capabilities.
systemctl
:systemctl
is a command-line tool used to control the systemd system and service manager, which is the default initialization system in most modern Linux distributions.It allows users to start, stop, restart, enable, disable, and manage system services, targets (similar to runlevels), and other units managed by systemd.
The syntax for using
systemctl
is as follows:systemctl [command] [service_name]
Example commands using
systemctl
:Start a service:
systemctl start service_name
Stop a service:
systemctl stop service_name
Restart a service:
systemctl restart service_name
Enable a service to start at boot:
systemctl enable service_name
Disable a service from starting at boot:
systemctl disable service_name
Check the status of a service:
systemctl status service_name
service
:service
is a legacy command used to control system services in older Linux distributions that do not use systemd as their default initialization system. It is also used in some current distributions for compatibility purposes.While it can perform similar actions to
systemctl
, its syntax and capabilities are more limited.The syntax for using
service
is as follows:service [service_name] [command]
Example commands using
service
:Start a service:
service service_name start
Stop a service:
service service_name stop
Restart a service:
service service_name restart
Enable a service to start at boot:
service service_name enable
Disable a service from starting at boot:
service service_name disable
Check the status of a service:
service service_name status
In modern Linux distributions that use systemd, it is recommended to use systemctl
for managing services, as it offers more features and better integration with the initialization system. However, in some cases, you may still encounter service
being used for compatibility reasons or on systems that have not yet adopted systemd.
Stay in the loop with my latest insights and articles on cloud ☁️ and DevOps ♾️ by following me on Hashnode, LinkedIn (https://www.linkedin.com/in/chandreshpatle28/), and GitHub (https://github.com/Chandreshpatle28).
Thank you for reading! Your support means the world to me. Let's keep learning, growing, and making a positive impact in the tech world together.