Day 7 Task: Understanding package manager and systemctl

·

4 min read

What is a package manager in Linux?

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.

Package manager have different names for different OS. In Linux it is Yum, in Ubuntu(Debian) it is apt-get.

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 packaging system but 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.

To install Docker on Linux, follow these steps:

sudo apt-get update

curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -

sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"

sudo apt-get update

sudo apt-get install docker-ce docker-ce-cli containerd.io

You can check status of docker using below command:

To install Jenkins on Ubuntu, you can follow these steps:

  1. Add the Jenkins repository key to the system:

    wget -q -O - https://pkg.jenkins.io/debian-stable/jenkins.io.key | sudo apt-key add -

    sudo sh -c 'echo deb https://pkg.jenkins.io/debian-stable binary/ > /etc/apt/sources.list.d/jenkins.list'

    sudo apt-get update

    sudo apt-get install jenkins

    sudo systemctl status jenkins

You can check status of jenkins using below command:

systemctl

systemctl is a command-line utility in Linux-based operating systems that is used to manage and control the systemd system and service manager.

Systemd is a system and service manager that manages the boot process, system services, and other critical system functions in Linux. systemctl is used to control and monitor systemd units, which include system services, timers, sockets, and devices.

Here are some common uses of systemctl:

  1. Starting and stopping services: systemctl start service-name or systemctl stop service-name.

  2. Enabling and disabling services: systemctl enable service-name or systemctl disable service-name. This configures the service to start automatically on boot or not.

  3. Restarting services: systemctl restart service-name.

  4. Checking the status of services: systemctl status service-name.

  5. Reloading systemd configuration: systemctl daemon-reload.

  6. Listing all available services: systemctl list-unit-files --type=service.

These are just a few examples of how systemctl can be used. It is a powerful tool that provides a centralized way to manage system services and other important functions in Linux-based systems.

Let's check the systemctl for the installed application i.e. Docker and Jenkins.

systemd

systemd is a system and service manager that is used in many modern Linux distributions. It is responsible for managing the system startup process, system services, and other critical system functions. It replaces the traditional SysV init system used in earlier versions of Linux.

Here are some of the main uses of systemd in Linux:

  1. Boot process management: systemd is responsible for managing the boot process, including loading the kernel and initializing system services and devices.

  2. Service management: systemd manages system services, which are programs that run in the background and provide functionality to the system. systemd can start, stop, restart, and manage the status of services.

  3. Resource management: systemd manages system resources, including CPU, memory, and I/O, to ensure that system performance is optimized.

  4. Logging: systemd provides a centralized logging system for system events and service output.

  5. Container management: systemd can be used to manage containerized applications using technologies like Docker.

  6. Timer management: systemd provides a timer system that can be used to schedule tasks and services.

  7. User session management: systemd manages user sessions and can start, stop, and manage user-level services.

In summary, systemd is a powerful system and service manager that provides a centralized way to manage critical system functions in modern Linux distributions.