Hey DevOps enthusiasts! π
Welcome to Day 7 of our 90-day DevOps journey. Today, we're diving into the essentials of package managers and systemctl in Linux. Let's break it down and make it fun! π
What is a Package Manager in Linux? π¦π οΈ
In simpler terms, a package manager is like your app store on Linux. It helps you install, remove, upgrade, configure, and manage software packages on your system. There are graphical tools (like software centers) and command-line tools (like apt-get
or pacman
).
What is a Package? ππ
A package can be a GUI application, a command-line tool, or a software library required by other programs. Essentially, it's an archive file containing the binary executable, configuration files, and sometimes information about dependencies.
Different Kinds of Package Managers π οΈπ
Package managers vary based on the packaging system, but multiple package managers can exist for the same system. For example:
RPM: Uses
yum
anddnf
.DEB: Uses
apt-get
andaptitude
.
Task: Install Docker and Jenkins ππ§
How to install Jenkins on ubuntu
Update your Ubuntu Server,
sudo apt update -y
Install Java on your ubuntu server, because Jenkins uses java in the backend, so java is the pre-requisite for Jenkins installation.
sudo apt install openjdk-11-jre -y
Check java version,
Now, add jenkins key,
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
Now, again update your system,
sudo apt-get update -y
Install Jenkins,
sudo apt-get install jenkins -y
Go to security groups of the server and add inbound rule for port 8080 and If you see the below page on port 8080, then you have successfully installed jenkins on ubuntu.
What is Systemctl and Systemd? π§π₯οΈ
systemctl
is a command-line utility used to examine and control the state of the βsystemdβ system and service manager. systemd
is a system and service manager for Unix-like operating systems (most distributions, but not all).
Tasks: Managing Docker and Jenkins Services
Check Docker Service Status
To check the status of the Docker service, use:
bashCopy codesudo systemctl status docker
Manage Jenkins Service
To stop the Jenkins service:
sudo systemctl stop jenkins
Check the status before and after stopping the service:
sudo systemctl status jenkins
Read About Systemctl vs. Service
To understand the differences between systemctl
and service
, read the following commands:
systemctl status docker
service docker status
Additional Tasks: Automate Service Management π€π
Automate Starting and Stopping Services
Here's a script to automate the starting and stopping of Docker and Jenkins services:
Script: automation.sh
As we run the script you can check the output below :
To stop the services give the input as stop
Enable and Disable Services on Boot
To enable Docker to start on boot:
sudo systemctl enable docker
To disable Jenkins from starting on boot:
sudo systemctl disable jenkins
Analyze Logs with journalctl ππ
To analyze the logs of Docker and Jenkins services:
bashCopy code# Docker logs
sudo journalctl -u docker
# Jenkins logs
sudo journalctl -u jenkins
Post your findings after analyzing the logs to understand any issues or events that have occurred.
Conclusion π
Understanding package managers and systemctl is crucial for managing software and services in Linux. Today, we learned how to install Docker and Jenkins, manage their services, and automate service management. These skills are fundamental for any DevOps engineer, and mastering them will significantly enhance your system administration capabilities.
Keep experimenting and practicing these skills to become proficient in managing software and services in Linux. See you on Day 8 of our DevOps journey! π