Day 7 : Understanding Package Manager and Systemctl

Day 7 : Understanding Package Manager and Systemctl

Β·

3 min read

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 and dnf.

  • DEB: Uses apt-get and aptitude.

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! πŸš€

Β