Day 7 #90DaysOfDevOpsChallenge: Learning About Package Managers and Systemctl

ASHISH PATILASHISH PATIL
4 min read

Hello DevOps Learners!

Today, I will explain two important topics: Package Managers and Systemctl. These tools help you manage software and services on Linux systems. Let's go step by step to understand them.


What is a Package Manager?

A Package Manager is a tool that helps you:

  • Install new software

  • Remove software you no longer need

  • Update your software

  • Manage software on your computer

Think of it like an app store, but instead of clicking, you type commands in the terminal.

Example:

If you want to install a program, you don’t have to download it from a website. The package manager will do it for you!

Different Linux systems use different package managers. For example:

  • On Ubuntu, we use a package manager called apt-get.

  • On CentOS, we use package managers like yum or dnf.


What is a Package?

A Package is a file that has everything needed to run a program. It could be an app, a tool you use in the terminal, or a part of another software.


Types of Package Managers

There are different package managers depending on the Linux system you are using:

  • For Ubuntu (Debian-based systems): You will use apt-get or apt.

  • For CentOS (Red Hat-based systems): You will use yum or dnf.


Task: Install Docker and Jenkins

Now, let’s install two popular tools: Docker and Jenkins.

On Ubuntu:

  1. Update the package list (this makes sure your system knows about the latest software):

     sudo apt-get update
    
  2. Install Docker:

     sudo apt-get install docker.io
    
  3. Install Jenkins:

     sudo apt-get install jenkins
    

On CentOS:

  1. Update the system:

     sudo yum update
    
  2. Install Docker:

     sudo yum install docker
    
  3. Install Jenkins:

     sudo yum install jenkins
    

What is Systemctl?

After installing software like Docker and Jenkins, you need to manage them. This is where Systemctl helps. Systemctl is a tool that controls and manages services on Linux.

A service is a program that runs in the background (like a web server or a database).

With systemctl, you can:

  • Start or stop services

  • Check if a service is running

  • Make sure a service starts automatically when your computer boots up


Task: Check Docker Service Status

After installing Docker, you can check if the Docker service is running by using this command:

sudo systemctl status docker

If Docker is running, you’ll see a green message that says "active (running)."


Task: Manage Jenkins Service

To stop the Jenkins service, use this command:

sudo systemctl stop jenkins

You can start it again with:

sudo systemctl start jenkins

Systemctl vs. Service

Sometimes you will see another command called service. Both systemctl and service can manage services, but systemctl is newer and has more features.

Here’s how to check the Docker service status with both commands:

  • Using systemctl:

      sudo systemctl status docker
    
  • Using service:

      sudo service docker status
    

Additional Task: Automate Service Management

You can write a simple script to automate the starting and stopping of Docker and Jenkins. Here’s a basic example:

#!/bin/bash
# Script to manage Docker and Jenkins

echo "Stopping Jenkins service..."
sudo systemctl stop jenkins

echo "Starting Docker service..."
sudo systemctl start docker

Save this as a file (for example, manage_services.sh), and you can run it anytime to manage both services!


Final Task: Analyzing Logs

You can check the logs (records of what the services have done) using journalctl. For example, to check Docker’s logs, type this command:

sudo journalctl -u docker

This will show you a detailed history of what Docker has been doing, which is useful for troubleshooting problems.


Conclusion

Understanding package managers and systemctl is important for anyone working in DevOps or system administration. These tools make managing software and services on Linux easier.

I encourage you to try these commands on your own system and share what you learn with others in the DevOps community. Remember, DevOps is all about learning and growing together!


Keep Learning!

Let’s learn together and grow together in the world of DevOps! 🌱🚀 #DevOpsJourney #LearningTogether #GrowthMindset #TechCommunity #TrainWithShubham #90DaysOfDevOps

Follow my #90DaysOfDevOps challenge on LinkedIn, and stay tuned for more updates!

10
Subscribe to my newsletter

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

Written by

ASHISH PATIL
ASHISH PATIL

Hi I am Ashish Patil, a fresher with a keen interest in AWS, DevOps, and Linux. I have been learning about cloud infrastructure and automation, and I am excited to apply my skills in real-world projects. I am committed to continuous improvement and eager to grow in the tech industry.