Day 7 of 90DaysOfDevOps : Understanding Package Manager and Systemctl

Pooja NaitamPooja Naitam
2 min read

πŸ”Ή What is a Package Manager?

A package manager is a tool that helps you install, update, and remove software on your system. It can be a graphical app or a command-line tool like apt or yum.

πŸ‘‰ But what’s a package? A package is an archive file containing everything needed to install a piece of software (like Docker or Jenkins) on your system. This includes executable files, configurations, and dependencies.

  • DEB-based (Debian/Ubuntu): apt, apt-get

  • RPM-based (Red Hat/CentOS): yum, dnf


πŸ”Ή Installing Docker and Jenkins on Ubuntu and CentOS

For Ubuntu (Using apt) 🐧

  1. Update the package list:

     sudo apt update
    
  2. Install Docker:

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

     sudo apt install -y jenkins
    

For CentOS (Using yum) 🐧

  1. Install Docker:

     sudo yum install -y docker
    
  2. Install Jenkins:

     sudo yum install -y jenkins
    

πŸ”Ή Managing Services with systemctl πŸ› οΈ

Once Docker and Jenkins are installed, you can use systemctl (part of systemd) to manage these services.

Checking Docker Service Status

sudo systemctl status docker

Stopping and Starting Jenkins

sudo systemctl stop jenkins  # Stop Jenkins
sudo systemctl start jenkins # Start Jenkins

πŸ”Ή Automating Service Management πŸš€

Create a simple script to start or stop Docker and Jenkins as needed:

#!/bin/bash
echo "Choose an action: start or stop"
read action

sudo systemctl $action docker
sudo systemctl $action jenkins

echo "Docker and Jenkins have been $action-ed!"

πŸ”Ή Enabling and Disabling Services on Boot πŸ”„

To automatically start Docker on boot but prevent Jenkins from starting:

# Enable Docker to start on boot
sudo systemctl enable docker

# Disable Jenkins from starting on boot
sudo systemctl disable jenkins

πŸ”Ή Checking Logs with journalctl πŸ“œ

  1. View Docker logs:

     sudo journalctl -u docker
    
  2. View Jenkins logs:

     sudo journalctl -u jenkins
    

Summary πŸ“

With package managers, you can quickly install and update software. Then, with systemctl and systemd, you can manage these services, automate actions, and control their startup behavior. Now you have a solid foundation to manage software and services like a pro in Linux!

0
Subscribe to my newsletter

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

Written by

Pooja Naitam
Pooja Naitam

πŸ‘‹ Hello! I'm Pooja Naitam, a passionate DevOps fresher with a solid foundation in the field. I hold the AWS Certified Cloud Practitioner (CCP) certification, and I'm eager to apply my knowledge to real-world projects while continuously learning cutting-edge technologies. Let's connect and grow together in the exciting world of DevOps!