Day 7 : Unlocking the Power of Package Managers and Systemctl!

Naushad KhanNaushad Khan
5 min read

🚀 "In the world of Linux, managing software is like cooking with the right ingredients. The package manager is your chef!" 🍲

Hello, fellow DevOps adventurers! Today was all about discovering package managers and how they make software management a breeze. We also explored systemctl, the magic tool that lets us control services running on our system. Let’s dive into the fascinating journey of Day 7!

📦 What is a Package Manager?

Imagine trying to install software manually—finding the files, figuring out dependencies, and making sure everything works together. Sounds exhausting, right? Well, this is where the package manager steps in like a superhero!

A package manager is a tool that helps you install, update, configure, and remove software effortlessly. It takes care of dependencies (other software needed to run the main one) and ensures everything is in perfect harmony. In Linux, we use commands like apt-get, yum, and dnf to manage packages.

Think of it as your personal grocery delivery service for software—it brings you exactly what you need with just a few commands!

🍔 What is a Package?

A package in Linux is like a neatly wrapped meal that contains everything you need to run a software application. It could be a GUI tool, a command-line utility, or even a library that other applications depend on.

In short: a package = software + dependencies + instructions.

🛠️ Installing Docker and Jenkins with Package Managers

Now that I understood what a package manager does, I jumped right into the task: installing Docker and Jenkins on my Linux system! 💻

Step 1: Installing Docker

Using Ubuntu as my base, I used the apt-get command to install Docker:

sudo apt-get update

sudo apt-get install docker.io

Boom! Docker was installed within minutes. 🐳

Step 2: Installing Jenkins

Next up was Jenkins, the automation server that every DevOps engineer loves:

sudo apt-get update

sudo apt install fontconfig openjdk-17-jre

java -version

sudo apt-get update

sudo apt-get install Jenkins

sudo systemctl enable Jenkins

systemctl status jenkins

sudo apt update

After this, you can access Jenkins by visiting http://localhost:8080 in your web browser. The initial password can be found using this command:
sudo cat /var/lib/jenkins/secrets/initialAdminPassword

Jenkins was up and running in no time!

📘 Pro Tip: If you're on CentOS or RedHat, you can install Docker and Jenkins using yum or dnf package managers. Just like ordering food from a different app, but the results are the same!


🔥Systemctl and Systemd: Controlling Services with Style!

Once Docker and Jenkins were installed, it was time to control their services with a super tool called systemctl.

What is Systemctl?

Systemctl is like the command center of a spaceship, giving you control over which services are running, which should start at boot, and even when to stop or restart them.

Let’s break it down with some tasks I did today:

Task 1: Checking Docker Service Status

First, I checked whether Docker was running or not:

Docker was up and running! The systemctl command gave me detailed information, like whether the service was active, running, and if there were any errors.

Task 2: Managing Jenkins Service

Next, I stopped the Jenkins service:

sudo systemctl stop Jenkins

And voila! Jenkins stopped. I then started it again with

sudo systemctl start Jenkins

Being able to stop, start, and restart services with just a command is powerful, especially in production environments where uptime is everything.

⚙️ Systemctl vs. Service: What’s the Difference?

While both systemctl and the older service command are used to manage services, systemctl is part of the modern systemd system, offering more features and flexibility. It’s like comparing a smartphone to an old-school mobile—both can make calls, but the smartphone does so much more!

Example :

Systemctl allows more complex operations, including automating services, controlling logs, and managing dependencies between services.

📜 Automating Service Management

I took things a step further by automating the start and stop processes for Docker and Jenkins with a script! 💡 This is useful when you want to automate the deployment process or simply ensure critical services are always running.

Here’s the script I created to automatically start and stop these services:

#!/bin/bash

echo "Starting Docker and Jenkins..."

sudo systemctl start docker

sudo systemctl start jenkins

echo "Services started successfully!"

This script made service management as simple as running one command. Talk about efficiency! 🔥

🌟 Enable and Disable Services on Boot

I also learned how to make sure Docker starts automatically whenever my system boots, and prevent Jenkins from starting automatically. Here’s how I did it:

  • Enable Docker on boot:

sudo systemctl enable docker

Disable Jenkins from starting on boot:

sudo systemctl disable Jenkins

This level of control ensures that my services behave exactly how I want them to, even if my system restarts.

🧐 Analyzing Logs with Journalctl

Finally, I used journalctl to dig into the logs of both Docker and Jenkins. Logs are like the footprints services leave behind, showing everything they’ve been doing (or trying to do).

To see the logs for Docker:

For Jenkins:

This helped me analyze what went right or wrong during service operations. Logs are incredibly useful when troubleshooting issues in real-time.

✨ Final Thoughts: The Power of Package Managers and Systemctl

Today was a huge leap in understanding how to manage software and services on Linux. From installing Docker and Jenkins with ease using package managers to controlling services with systemctl, I realized how important these tools are in the daily life of a DevOps engineer.

Managing services isn’t just about turning things on or off—it’s about having control, automation, and foresight. This knowledge will help me as I continue my #90DaysOfDevOps journey!

🔧 Takeaway: If you want to make your DevOps life easier, mastering package managers and systemctl is a must!

Looking forward to Day 8! 🚀

1
Subscribe to my newsletter

Read articles from Naushad Khan directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Naushad Khan
Naushad Khan

DevOps engineer with a passion for automation, CI/CD, and cloud platforms like AWS. I bridge dev and ops, optimizing workflows and sharing insights through technical blogs. Let’s automate the future! 🌐⚙️