Day 7 : Understanding package manager and systemctl

·

6 min read

Package Manager

What is a package manager in Linux?

A package manager is like a librarian for our computer. It helps us find, install, and update software on our Linux system. Just like how a librarian can help us find a book in a library, a package manager can help us find and install software packages (like programs or tools) on our computer.

What is a package?

A package is like a box that contains something inside. In the case of Linux, a package is a collection of files that work together to do something specific, like play a game or edit photos.

They are collections of files that are bundled together so they can be easily installed, updated, and removed. They make it easier to manage software on our computer because we can just tell the package manager "I want to install this package" and it will take care of everything for us!

What are different kinds of package manager?

Different packaging systems can have multiple package managers, each with their own set of features and capabilities. Here are some examples of package managers for popular packaging systems:

  1. RPM:
  • Yum: Yum is a powerful and widely-used package manager for RPM-based distributions like CentOS, Fedora, and Oracle Linux. It provides a command-line interface and supports features like dependencies resolution, package updates, and repository management.

  • DNF: DNF (Dandified YUM) is a newer package manager for RPM-based distributions that aims to improve upon Yum's performance and functionality. It includes features like parallel downloading, improved dependency handling, and support for transactional updates.

  1. DEB:
  • Apt-get: Apt-get is a classic package manager for DEB-based distributions like Ubuntu, Debian, and Linux Mint. It provides a command-line interface and supports features like dependencies resolution, package updates, and repository management.

  • Aptitude: Aptitude is a more advanced package manager for DEB-based distributions that offers a graphical user interface and additional features like automatic package upgrades and package removal.

  1. Pacman:
  • Pacman: Pacman is a package manager for Arch Linux and other rolling-release distributions. It provides a simple command-line interface and supports features like dependencies resolution, package updates, and repository management.

  • Sync: Sync is a package manager for Arch Linux that provides a more intuitive and user-friendly interface than Pacman. It allows users to easily install, update, and remove packages, and includes features like dependency resolution and repository management.

  1. Portage:
  • Emerge: Emerge is a package manager for Gentoo Linux and other Source-based distributions. It provides a command-line interface and supports features like dependencies resolution, package builds, and repository management.

  • Equo: Equo is a package manager for Gentoo Linux that provides a more user-friendly interface than Emerge. It allows users to easily install, update, and remove packages, and includes features like dependency resolution and repository management.

    Each package manager has its own strengths and weaknesses, and some may be better suited to specific use cases or workflows.

Installing Docker and Jenkins on Ubuntu and CentOS Using Package Managers

Introduction:
Docker and Jenkins are two popular tools for containerization and continuous integration, respectively.We will explore how to install these tools on Ubuntu and CentOS using package managers. We will cover the step-by-step process for installing Docker and Jenkins on these platforms.

Installing Docker on Ubuntu and CentOS:
Docker can be installed on Ubuntu and CentOS using the package manager of each distribution. Here are the steps to install Docker on Ubuntu and CentOS:
Ubuntu:

  1. Open the Terminal application on your Ubuntu system.

  2. Update the package list by running the command sudo apt-get update.

  3. Install Docker by running the command sudo apt-get install docker.io.

  4. Once Docker is installed, start the Docker service by running the command sudo systemctl start docker.

  5. Check if Docker is running by running the command sudo systemctl status docker.

CentOS:

  1. Open the Terminal application on your CentOS system.

  2. Update the package list by running the command sudo yum update.

  3. Install Docker by running the command sudo yum install docker.

  4. Once Docker is installed, start the Docker service by running the command sudo systemctl start docker.

  5. Check if Docker is running by running the command sudo systemctl status docker.

Similarly replicate the exact steps for Jenkins.

Things to keep in mind when installing Docker and Jenkins on Ubuntu and CentOS using package managers:

  1. Make sure the system is updated with the latest package lists before installing Docker and Jenkins.

  2. Use the appropriate package manager for your distribution. For example, Ubuntu uses apt-get, while CentOS uses yum.

  3. Start the Docker and Jenkins services after installation to enable them to run automatically.

  4. Check the status of Docker and Jenkins regularly to ensure they are running smoothly.


systemctl and systemd

systemd and systemctl are two related but distinct concepts in Linux system management.
Systemd is a system and service manager for Linux distributions. It provides a number of features such as:

  • Service management: Systemd allows us to manage services (e.g., web servers, database servers, etc.) and their dependencies.

  • Unit management: Systemd treats services as "units" that can be started, stopped, and enabled/disabled as needed.

  • Dependency management: Systemd tracks dependencies between units and ensures that they are properly started and stopped in the correct order.

  • Configuration management: Systemd allows us to configure services and their settings through a declarative configuration file.

On the other hand, systemctl is a command-line utility that allows us to interact with systemd. It provides a set of subcommands for performing various tasks such as:

  • Starting and stopping services: systemctl start/stop <service_name>

  • Enabling and disabling services: systemctl enable/disable <service_name>

  • Querying service status: systemctl status <service_name>

  • Viewing service configurations: systemctl cat <service_name>.conf

The main difference between systemd and systemctl is that systemd is a daemon that runs in the background and manages services, while systemctl is a command-line tool that allows you to interact with systemd. In other words, systemd is the engine that powers systemctl.

systemctl vs service

a brief comparison of the systemctl and service commands:
Systemctl:

  • Provides more advanced features and options for managing services.

  • Uses the systemd initialization system, which is the default on most modern Linux distributions.

  • Offers more flexibility and control over service management, including dependency management and socket activation.

  • Has a steeper learning curve due to its complexity.

Service:

  • A simpler, more lightweight command for managing services.

  • Compatible with both systemd and the traditional init system.

  • Easier to learn and use, but less powerful than systemctl.

  • Limited to managing services in the traditional init style.

Now, let's look at some specific examples to illustrate the differences:Systemctl Status Docker:

  • Shows the current status of the Docker service, including its state and any error messages.

  • Allows you to view detailed information about the service, such as its configuration and dependencies.

Service Docker Status:

  • Displays the current status of the Docker service in a simpler, more straightforward manner.

  • Does not provide as much detail or functionality as systemctl.

In general, if you need more advanced features and control over your services, you may want to use systemctl. However, if you prefer a simpler, more lightweight command line interface, you may prefer to use service.


In conclusion, understanding package managers and systemctl is essential for anyone working with Linux and open source technologies. By mastering these tools, we can efficiently manage software packages and services, streamline your workflow, and improve overall productivity.

Thank you for being patient and reading until here.Happy Coding!