Understanding package manager and systemctl

Understanding package manager and systemctl

What is a package manager in Linux?

  • Package management is very important in Linux, and knowing how to use multiple package managers can prove life-saving for a power user since downloading or installing software from repositories, plus updating, handling dependencies and uninstalling software is very vital and a critical section in Linux System Administration.

  • There are many Package Managers today for Unix/Linux-based systems.

    What is a package?

    • A package is simply an archive that combines all the libraries and binaries, configuration and dependencies required to install the programs.

    • A package is usually referred to as an application but it could be a GUI application, command line tool, or a software library.

Different kinds of package managers

1. DPKG – Debian Package Management System

  • Dpkg is a base package management system for the Debian Linux family, it is used to install, remove, store, and provide information about .deb packages.

APT (Advanced Packaging Tool)

  • Apt or Advanced Packaging Tool is free and open-source software that gracefully handles software installation and removal. Initially, it was designed for Debian’s .deb packages but it has been made compatible with RPM Package Manager.

  • Ubuntu and Linux Mint should be familiar with this package management tool.

Aptitude Package Manager

  • Aptitude is a front-end to advanced packaging tool which adds a user interface to the functionality, thus allowing a user to interactively search for a package and install or remove it.

2. RPM (Red Hat Package Manager)

YUM (Yellowdog Updater, Modified)

  • YUM (Yellowdog Updater Modified) is an open-source command line as well as a graphical-based package management tool for RPM (RedHat Package Manager) based Linux systems.

  • It allows users and system administrators to easily install, update, remove, or search software packages on a system.

DNF – Dandified Yum

  • It is also a package manager for RPM-based distributions, introduced in Fedora 18 and it is the next generation of the version of YUM.

3. Pacman Package Manager

  • It is a popular and powerful yet simple package manager for Arch Linux and some little-known Linux distributions, it provides some of the fundamental functionalities that other common package managers provide including installing, automatic dependency resolution, upgrading, uninstalling, and also downgrading software.

4. Zypper Package Manager

  • It is a command line package manager on OpenSUSE Linux and makes use of the libzypp library, its common functionalities include repository access, package installation, resolution of dependencies issues, and many more.

5. Portage Package Manager

  • It is a package manager for Gentoo, a less popular Linux distribution as of now, but this won’t limit it as one of the best package managers in Linux.

Install Docker

  1. Remove any Docker files that are running in the system, using the following command:

     $ sudo apt-get remove docker docker-engine docker.io
    
  2. Check if the system is up-to-date using the following command

     $ sudo apt-get update
    
  3. Install Docker using the following command

     $ sudo apt install docker.io
    
  4. Install all the dependency packages using the following command

     $ sudo snap install docker
    
  5. check the version installed using the following command

     $ docker --version
    

Install Jenkins

  1. Install JAVA

    • Jenkins requires Java in order to run, yet certain distributions don’t include this by default and some Java versions are incompatible with Jenkins.

        $ sudo apt update
        $ sudo apt install openjdk-11-jre
        $ java -version
      
  2. Add the repository key to your system:

     curl -fsSL https://pkg.jenkins.io/debian-stable/jenkins.io-2023.key | sudo tee \
       /usr/share/keyrings/jenkins-keyring.asc > /dev/null
    
  3. Append the Debian package repository address to the server’s sources.list

     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
    
  4. run apt update so that apt will use the new repository.

     sudo apt-get update
    
  5. Finally, install Jenkins and its dependencies

     sudo apt-get install jenkins
    
  6. start the Jenkins service and check the status:

     sudo systemctl start jenkins
     sudo systemctl status jenkins
    
  7. Open the 8080 port in the firewall

    1.    sudo ufw allow 8080
      
    2.    sudo ufw allow OpenSSH
         sudo ufw enable
         sudo ufw status
      
    3.    Output
         Status: active
      
         To                         Action      From
         --                         ------      ----
         OpenSSH                    ALLOW       Anywhere
         8080                       ALLOW       Anywhere
         OpenSSH (v6)               ALLOW       Anywhere (v6)
         8080 (v6)                  ALLOW       Anywhere (v6)
      

systemctl and systemd

  • systemd is a Linux initialization system and service manager that includes features like on-demand starting of daemons, mount and automount point maintenance, snapshot support, and processes tracking using Linux control groups.

  • systemd provides a logging daemon and other tools and utilities to help with common system administration tasks.

  • systemctl is a controlling interface and inspection tool for the widely-adopted init system and service manager systemd. This guide will cover how to use systemctl to manage systemd services, work with systemd Targets and extract meaningful information about your system’s overall state.

Check the status of Docker service in your system

systemctl status docker

Stop the service jenkins and post before and after screenshots

systemctl status jenkins

sudo systemctl stop jenkins
sudo systemctl start jenkins

systemctl vs service

  • Systemctl is the newer command for systems that boot with systemd instead of init.

  • systemctl is a combination of service and chkconfig for those newer systems.

  • “service” is the legacy command, which normally works with classical init.

  • Although on systems that use systemd it’s actually more of a wrapper over the actual systemd native means of managing services, namely systemctl.


Happy Learning :)

Thanks For Reading.

Hope this blog is useful to you.

Vishal Ranmale

https://www.linkedin.com/in/vishal-ranmale-907307114/