Day-07: Understanding package manager and systemctl

Kshitij Tripathi
5 min readJun 2, 2023

--

This is the #90DaysofDevops challenge under the guidance of Shubham Londhe sir.

Task:

What is a package manager in Linux?

In Linux, a package manager is a software tool that simplifies the process of installing, updating, and removing software packages on a Linux-based operating system. It provides a convenient and centralized way to manage software packages, dependencies, and system configurations.

The package manager handles the task such as:-

1. Package Installations

2. Package Updates

3. Package Removal

4. Dependency Management

5. Repository Management

Some popular package managers used in various Linux distributions include:

1. APT (Advanced Package Tool): Used in Debian-based distributions like Linux.

2. DNF (Dandified YUM): Used in Fedora and Red Hat Enterprise Linux (RHEL).

3. Pacman: Used in Arch Linux and its derivatives.

4. Zypper: Used in openSUSE

5. YUM (Yellowdog Updater, Modified): Used in older versions of Fedora and RHEL.

These package managers typically provide command-line interfaces (CLI) for advanced users and graphical user interfaces (GUI) for easier management for beginner users.

What is a package?

In Linux, a package refers to a compressed archive file containing software, libraries, configuration files, documentation, and other necessary components required to install and operate a specific piece of software. These packages are designed to simplify the process of software installation and management on a Linux-based operating system.

A package typically contains the following components:

1. Executable files

2. Libraries

3. Configuration files

4. Documentation

5. Dependencies

6. Installation scripts

Linux distributions typically have their own package formats, and each package manager handles those formats. Some common package formats include:

1. Debian Package (.deb): Used by Debian-based distributions.

2. RPM package (.rpm): Used by Red-Hat-based distribution.

3. Arch Linux packages (.pkg.tar.sz): Used by Arch Linux.

Installing Docker

Install Jenkins

There is a slight change in installing Jenkins since March 2023. Please follow these steps from now onwards.

  1. For adding the repository key to your system
    curl -fsSL https://pkg.jenkins.io/debian/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 binary/ | sudo tee \
    /etc/apt/sources.list.d/jenkins.list > /dev/null
  2. Next, let’s append the Debian package repository address to the server’s sources.list:
    sudo sh -c ‘echo deb [signed-by=/usr/share/keyrings/jenkins.gpg] http://pkg.jenkins.io/debian-stable binary/ > /etc/apt/sources.list.d/jenkins.list’
  3. Next, you must update the ‘apt’ and install Jenkins with the following commands.
    sudo apt update -y
    sudo apt install jenkins -y

What is systemctl and systemd?

Systemd is a system and service manager for Linux operating systems that provides a range of features for managing the system’s startup process, services, and other system components. It is designed to improve performance, efficiency, and reliability compared to traditional init systems.

Systemctl, on the other hand, is a command-line utility that serves as the primary interface for interacting with systemd. It allows administrators to manage system services, view their status, start or stop them, enable or disable them at boot time, and perform various other operations related to system management.

Some common systemctl commands include:

  • systemctl start <service>: Start a service.
  • systemctl stop <service>: Stop a service.
  • systemctl restart <service>: Restart a service.
  • systemctl enable <service>: Enable a service to start automatically at boot.
  • systemctl disable <service>: Disable a service from starting automatically at boot.
  • systemctl status <service>: Check the status of a service.
  • systemctl list-units: List all active units and their statuses.
  • systemctl daemon-reload: Reload the systemd configuration after making changes.

In short, they provide a unified and efficient way to manage services and system components, offering advanced features like parallel startup, on-demand service activation, socket-based activation, and more.

  1. check the status of the docker service in your system (make sure you completed the above tasks, else docker won’t be installed)

2. stop the service Jenkins and post before and after screenshots

Read about the commands systemctl vs service

Systemctl and service are both command-line utilities used for managing services in Linux. However, there are some differences between the two:

  1. Functionality: Systemctl is a more advanced and feature-rich command that is part of the systemd system and service manager. It provides extensive control and management capabilities for services, including starting, stopping, restarting, and enabling/disabling at boot, viewing status, and more. Service, on the other hand, is a simpler command that is part of the traditional init system. It primarily focuses on starting, stopping, and checking the status of services.
  2. Compatibility: systemctl is compatible with systems that use systemd as the init system, such as most modern Linux distributions, including Ubuntu 16.04 and later, Fedora, CentOS 7 and later, and more. Service is compatible with systems that use traditional init systems, such as SysV init.
  3. Syntax: The syntax and command structure differ between systemctl and service. Systemctl commands generally follow the pattern systemctl <action> <service>, while service commands follow the pattern service <service> <action>.
    A few service Commands are as follows:
    3.1. service <service-name> start
    3.2. service <service-name> status
    3.3. service <service-name> stop
    3.4. service <service-name> restart
  4. Output: Systemctl provides more detailed and structured output, including status information, dependencies, and more. Service typically provides a simpler output that focuses on the status or result of the requested action.

In summary, systemctl is the more powerful and flexible command used in systems that utilize systemd as the init system. It offers extensive control and management capabilities for services. Service, on the other hand, is a simpler command used in systems with traditional init systems and provides basic service management functionality.

Please, feel free to drop any questions in the comments below. I would be happy to answer them.

If this post was helpful, please do follow and click the clap 👏 button below to show your support 😄

_Thank you for reading💚

--

--

No responses yet