Day 7 of the 90-Day DevOps Challenge: Mastering Package Managers and Systemctl in Linux

Tushar PantTushar Pant
4 min read

Welcome to Day 7 of my 90-Day DevOps Challenge, where I focused on two critical aspects of Linux: package managers and systemctl. As a DevOps engineer, understanding how to efficiently manage software packages and services is vital to maintaining robust and reliable systems. Today, I took a deep dive into these tools and explored how they contribute to seamless system management.


Package Managers in Linux: Simplifying Software Management

Linux distributions use package managers to automate the process of installing, updating, configuring, and removing software packages. These tools ensure that software dependencies are met and provide a consistent way to manage applications and libraries on your system.

Types of Package Managers

Different Linux distributions use different package management tools, with the most common being:

  • APT (Advanced Package Tool): Used in Debian-based distributions like Ubuntu. Commands like apt-get and apt are part of this package management system.

  • YUM (Yellowdog Updater Modified) and DNF (Dandified YUM): Used in RPM-based distributions like CentOS and Fedora. YUM is the older tool, while DNF is its modern replacement.


My Tasks: Installing Docker and Jenkins

Today, I put my knowledge to the test by installing Docker and Jenkins on both Ubuntu and CentOS, using their respective package managers. Here’s how it went:

  • Installing Docker on Ubuntu (APT):

      sudo apt-get update 
      sudo apt-get install docker-ce docker-ce-cli containerd.io
    
  • Installing Jenkins on Ubuntu (APT):

      sudo apt-get update 
      sudo apt-get install openjdk-11-jdk wget -q -O - https://pkg.jenkins.io/debian/jenkins.io.key 
      sudo apt-key add - 
      sudo sh -c 'echo deb http://pkg.jenkins.io/debian-stable binary/ > /etc/apt/sources.list.d/jenkins.list' 
      sudo apt-get update 
      sudo apt-get install jenkins
    
  • Installing Docker on CentOS (YUM):

      sudo yum update -y 
      sudo yum install -y yum-utils 
      sudo yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo 
      sudo yum install docker-ce docker-ce-cli containerd.io
    
  • Installing Jenkins on CentOS (YUM):

      sudo yum update -y 
      sudo yum install java-11-openjdk-devel 
      sudo wget -O /etc/yum.repos.d/jenkins.repo https://pkg.jenkins.io/redhat/jenkins.repo 
      sudo rpm --import https://pkg.jenkins.io/redhat/jenkins.io.key 
      sudo yum install jenkins
    

These commands highlight how package managers streamline the installation process by automatically resolving dependencies and configuring the software.


Systemctl and Systemd: Managing Services Like a Pro

systemctl is the command-line utility that interfaces with systemd, the system and service manager for most Linux distributions. systemd manages system processes after the boot process, making systemctl a powerful tool for controlling services.

Why Systemctl Matters

  1. Service Management: Start, stop, restart, and check the status of services running on your system.

  2. Service Enablement: Enable or disable services to start automatically during the boot process.

  3. System Monitoring: View logs and monitor the performance and status of various system services.


Practical Applications: Docker and Jenkins Service Management

With Docker and Jenkins installed, I used systemctl to manage their services:

  • Checking Docker Service Status:

      sudo systemctl status docker
    

    This command shows the current status of the Docker service, including whether it’s active or inactive.

  • Starting Jenkins Service:

      sudo systemctl start jenkins
    

    This command starts the Jenkins service, allowing it to run in the background.

  • Stopping Jenkins Service:

      sudo systemctl stop jenkins
    

    I also experimented with stopping the Jenkins service, taking note of how systemctl handles service dependencies.


Systemctl vs. Service: Understanding the Difference

During my exploration, I compared systemctl with the older service command, which was used in pre-systemd systems:

  • systemctl:

      sudo systemctl status jenkins sudo systemctl restart docker
    

    systemctl provides more detailed output and is integrated with systemd, offering greater control over services.

  • service:

      sudo service jenkins status sudo service docker restart
    

    While service still works in many distributions for backward compatibility, it’s being phased out in favor of systemctl.


Day 7 of the 90-Day DevOps Challenge: Mastering Package Managers and Systemctl in LinuxConclusion: The Power of Package Managers and Systemctl in DevOps

Day 7 was a deep dive into the essential tools that make Linux such a versatile and powerful operating system for DevOps professionals. Understanding how to use package managers simplifies software installation and management, while mastering systemctl ensures that services run smoothly and are easy to control.

These skills are crucial for any DevOps engineer, as they form the foundation for maintaining reliable, secure, and efficient systems. As I continue my journey in the #90DaysOfDevOps challenge, I look forward to applying these tools in more complex scenarios and sharing those experiences with you.

Stay tuned for more insights and practical tips as I progress through this exciting DevOps journey!

22
Subscribe to my newsletter

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

Written by

Tushar Pant
Tushar Pant