Day-7 :- Understanding Package Manager and systemctl

Day-7 :- Understanding Package Manager and systemctl

·

5 min read

### What is a package manager in Linux?

In simpler words, a package manager is a tool that allows users to install, remove, upgrade, configure, and manage software packages on an operating system. The package manager can be a graphical application like a software center or a command line tool like apt-get or pacman.

### What is a package?

A package is usually referred to an application but it could be a GUI application, command line tool or a software library (required by other software programs). A package is essentially an archive file containing the binary executable, configuration file, and sometimes information about the dependencies.

### Different kinds of package managers

Package Managers differ based on the packaging system but the same packaging system may have more than one package manager.

For example, RPM has Yum and DNF package managers. For DEB, you have apt-get, aptitude command line based package managers.

## Tasks

1 . You have to install docker and Jenkins in your system from your terminal using package managers.

Ans :- Docker Installation

I have followed this link for docker installation on centos, it's the official documentation from docker. Docker Installation in Centos

I have followed this link for docker installation on ubuntu, its official documentation from docker - Docker Installation on Ubuntu

*here are some screenshots (centos)**

*For Ubuntu - Install Docker :-** 1. Open the terminal on Ubuntu.

2. Remove any docker file that is running in the system, using the following command: sudo apt-get remove docker docker-engine docker.io

3. Check if the system is up-to-date using the following command :- sudo apt-get update

4. Install Docker using the following command :- sudo apt install docker.io

5. Install all the dependency packages using the following command :- sudo snap install docker

6. Before testing Docker, check the version installed using the following command :- docker --version

*here are some screeshots (ubuntu) -**

For Ubuntu: Install Jenkins

Step 1: Install Java

Jenkins requires the Java Runtime Environment (JRE).

  1. Check if you already have java installed on your Ubuntu system: java --version

2. Depending on which Java version you want to install, Java 8 or 11, run one of the following commands:

To install OpenJDK 8, run: sudo apt install openjdk-8-jdk -y To install OpenJDK 11, run: sudo apt install openjdk-11-jdk -y

While installation I received this error - No Presto metadata available for base Error downloading packages which got resolved after running this command - sudo yum clean all

Step 2: Add Jenkins Repository

It is recommended to install Jenkins using the project-maintained repository, rather than from the default Ubuntu repository. The reason for that is because the Jenkins version in the default Ubuntu repository might not be the latest available version, which means it could lack the latest features and bug fixes.

1. Start by importing the GPG key. The GPG key verifies package integrity but there is no output. Run:

curl -fsSL https://pkg.jenkins.io/debian-stable/jenkins.io.key | sudo tee /usr/share/keyrings/jenkins-keyring.asc > /dev/null

2. Add the Jenkins software repository to the source list and provide the authentication key:

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

Step 3: Install Jenkins

1. Update the system repository

sudo apt update

2. Install Jenkins by running:

sudo apt install jenkins -y

3. To check if Jenkins is installed and running, run the following command:

sudo systemctl status jenkins A bright green entry labeled active (running) should appear in the output, indicating that the service is running.

Write a small blog or article to install these tools using package managers on Ubuntu and CentOS

Ubuntu:

  1. apt (Advanced Package Tool): It is a package manager used to install, upgrade, remove, and configure software packages on Ubuntu systems.

  2. dpkg (Debian Package): It is a low-level package manager used to build and install Debian packages.

  3. apt-get: It is a command-line tool used to install, upgrade, and remove packages on Ubuntu systems.

  4. aptitude: It is a menu-based package manager that provides a more advanced way to manage packages on Ubuntu systems.

CentOS:

  1. yum (Yellowdog Updater Modified): It is a command-line package manager used to manage packages on CentOS systems.

  2. rpm (Red Hat Package Manager): It is a command-line package manager used to install, upgrade, and remove software packages on CentOS systems.

  3. dnf (Dandified Yum): It is a package manager used to manage packages on CentOS systems.

  4. yumex (Yum Extender): It is a graphical user interface used to manage packages on CentOS systems.

Now, what is systemctl ?

Systemctl is the controller that is a part of systemed service (it is an init system). It is used to start/stop/restart the systemed services. It is always executed by the root user which means you have to execute the command with sudo.

Now, let's see the status of Jenkins service by systemctl command.

sudo systemctl status jenkins

You can see in this picture the Jenkins status is active(running) means you can access Jenkins on your web browser. (localhost:8080)

Now, let's stop the Jenkins service by systemctl command.

sudo systemctl stop jenkins.service

See after executing this command Jenkins status has been stopped i.e inactive (failed). Now, your Jenkins server is not running.

Now, let's see one more example of stopping the Docker service. First, let's see the status of running docker.

Let's stop the docker service by

sudo systemctl stop docker.socket

Now, what is the difference between systemctl and service ?

Sytemctl is a more powerful command than service. By service command, you can stop, status, and restart the services but with systemctl you can use more advanced commands like you can see list units of services, and mask/unmask the service, and it provides much more than service command.

Follow for more such amazing Linux and DevOps Blogs and share it with your friends.

******************THANK YOU !!*******************