Mastering Package Managers and systemctl for Linux System Administration

Mastering Package Managers and systemctl for Linux System Administration

Day 7: Understanding package managers and systemctl

Introduction

Managing dependencies and software installations with ease is revolutionary in the field of DevOps. The process is simplified by the invaluable assistance of Linux package managers. They provide a hassle-free experience by automating the processes of installing, configuring, and uninstalling software products.

We'll delve into package managers in this blog, explaining what they are and handling various package kinds. We'll even walk you through installing Docker and Jenkins on Ubuntu and CentOS using package managers. Still, that's not all! Additionally, we'll explain systemctl and systemd—two crucial tools for monitoring Docker's status and managing services. Now let's get going!

What is a Package Manager in Linux?

A package manager is like a helpful wizard for your computer. It makes handling software on Linux super easy. It can install, update, and remove software without any fuss. Plus, it's really good at making sure all the necessary parts are in place.

It also knows where to find all the software, which it gets from special storage places called repositories. When you want to install something, it goes and gets it for you from these repositories.

So, thanks to the package manager, managing software on Linux becomes a walk in the park!

What is a Package?

In the world of Linux, think of a package as a special gift box. Inside, you'll find all the important stuff like files, details, and instructions needed to set up a specific computer program.

These packages have names like .deb for Ubuntu and .rpm for CentOS. They're like secret codes that tell the computer how to handle them.

Now, let's talk about some cool package managers! They're like superheroes for managing software.

  • APT for Debian and Ubuntu: It's super speedy and loved by millions for being easy to use.

  • YUM for CentOS and Red Hat: This one is reliable and makes managing packages a breeze for system experts.

  • DNF for modern Fedora systems: It's like the fancy new version of YUM, offering faster performance and smart problem-solving.

Now that you know this, let's jump into the fun part of our blog! 🛠️💻 Just remember to pick the right package manager for your Linux system, and you'll have a blast exploring all sorts of software!

Installing Docker and Jenkins Using Package Managers

Installing Docker on Ubuntu: To install Docker on Ubuntu

Open your terminal. Execute the following commands:

sudo apt update
sudo apt install docker

Installing Docker on CentOS: To install Docker on CentOS

Open your terminal. Execute the following commands:

sudo yum update
sudo yum install docker

Installing Jenkins on Ubuntu and CentOS

Both Ubuntu and CentOS use Java to run Jenkins, so we need to install the Java Development Kit (JDK) first.

For Ubuntu: To install Jenkins on Ubuntu, execute the following steps:

Install the Java Development Kit (JDK):

sudo apt update
sudo apt install default-jdk

Proceed to install Jenkins:

sudo apt install jenkins

For CentOS: To install Jenkins on CentOS, execute the following steps:

Install the Java Development Kit (JDK):

sudo yum update
sudo yum install java-devel

Proceed to install Jenkins:

sudo yum install jenkins

Difference between systemctl and service

Both systemctl and service are commands used in Linux-based operating systems to manage system services.

However, systemctl is a more modern and advanced command, while service is a legacy command used in older Linux distributions.

Let's take a closer look at the differences between systemctl and service, along with their respective usage examples.

systemctl: It is the primary service management tool in systems that use the systemd init system. systemd is a system and service manager that has replaced the traditional SysV init system in many modern Linux distributions. systemctl allows you to control the system and service state, enable or disable services to start at boot and query the status of services.

To check the status of the Docker service:

systemctl status docker

To start the Docker service:

sudo systemctl start docker

To stop the Docker service:

sudo systemctl stop docker

To enable the Docker service to start at boot:

sudo systemctl enable docker

To disable the Docker service from starting at boot:

sudo systemctl disable docker

service: service is a command used to interact with SysV init scripts, the traditional initialization system used in older Linux distributions. While service can still be found in many systems, it is considered a legacy command, and newer systems that use systemd tend to favor systemctl.

To check the status of the Docker service using the service:

service docker status

To start the Docker service using the service:

sudo service docker start

To stop the Docker service using service:

sudo service docker stop

To restart the Docker service using the service:

sudo service docker restart

Conclusion

We have covered the importance of package managers in Linux in this blog, as well as the different kinds of packages and how to install Docker and Jenkins on Ubuntu and CentOS using package managers.

Additionally, we now have a better understanding of systemctl and systemd, which are effective tools for managing services and keeping track of Docker's state.

Package managers are powerful tools that DevOps professionals may use to automate software installations, freeing them up to focus on building robust and reliable applications.

Happy Learning!