#Day 7 - Understanding Package Manager and Systemctl

#Day 7 - Understanding Package Manager and Systemctl

What is a Package Manager in Linux?

When you dive into the world of Linux, you'll often come across the term "package manager." But what exactly is a package manager, and why is it such an integral part of the Linux ecosystem? In this article, we'll demystify the concept of package managers, explain what packages are, and provide practical examples of using package managers on Ubuntu and CentOS to install Docker and Jenkins.

Understanding Packages

Before we explore package managers, let's clarify what a "package" is. In the context of Linux, a package typically refers to a software application, whether it's a graphical user interface (GUI) program, a command-line tool, or a software library that other programs rely on. A package is essentially an archive file containing the binary executable code, configuration files, and sometimes information about any dependencies it may have.

Types of Package Managers

Package managers come in various flavors, and their usage can differ based on the packaging system used by a specific Linux distribution. To further complicate matters, the same packaging system might have multiple package managers. Here are a few examples:

1. RPM-based Package Managers:

  • Yum: Yum is a popular package manager used in RPM-based distributions like CentOS and Red Hat Enterprise Linux.

  • DNF: DNF is the next-generation package manager that succeeded Yum and is commonly used in modern RPM-based distributions.

2. DEB-based Package Managers:

  • apt-get: Apt-get is a command-line package manager for DEB-based distributions, such as Ubuntu and Debian.

  • aptitude: Aptitude is another command-line package manager that offers enhanced functionality over apt-get.

Now, let's get our hands dirty and use package managers to install Docker and Jenkins on Ubuntu and CentOS.

Installing Docker and Jenkins Using Package Managers

On Ubuntu:

1. Install Docker: Open your terminal and run the following commands-

sudo apt-get update 
sudo apt-get install docker.io

2. Install Jenkins: To install Jenkins on Ubuntu, use the following commands:

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

On CentOS:

  1. Install Docker: On CentOS, Docker can be installed using the following commands:
sudo yum install docker
sudo systemctl start docker
sudo systemctl enable docker

2. Install Jenkins: To install Jenkins on CentOS, run the following commands:

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
sudo systemctl start jenkins
sudo systemctl enable jenkins

Exploring systemctl and systemd

As you delve into Linux system management, you might encounter terms like systemctl and systemd. These are essential tools and concepts for controlling and monitoring system services. Here's a brief overview:

  • systemctl: This command is used to examine and control the state of the "systemd" system and service manager. It allows you to start, stop, restart, enable, and disable services on your Linux system.

  • systemd: systemd is a system and service manager that has become the standard for Unix-like operating systems, with widespread adoption across various Linux distributions. It provides a robust and efficient way to manage services, logging, and system initialization.

System Service Management

To check the status of the Docker service in your system, use the following command:

sudo systemctl status docker

To stop the Jenkins service and capture before and after screenshots, use the following commands:

sudo systemctl stop jenkins 
# Capture screenshots here 
sudo systemctl start jenkins 
# Capture screenshots again

In summary, package managers are the lifeblood of the Linux ecosystem, simplifying the installation, configuration, and management of software packages. They ensure that your Linux system remains organized, efficient, and up to date. Moreover, understanding the basics of systemctl and systemd is essential for managing system services effectively. With these tools at your disposal, you're well-equipped to navigate the Linux landscape with confidence.