Skip to main content

Command Palette

Search for a command to run...

(Day-7) : Understanding Package Manager and systemctl 🐧

Updated
β€’4 min read
(Day-7) : Understanding Package Manager and systemctl 🐧
S

Motivated and goal-oriented aspiring DevOps engineer with a strong passion for optimizing software development and deployment processes

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.

What is a Package Manager?πŸ”„πŸ“¦

  • In Linux, a package manager is a software tool that simplifies the process of installing, updating, configuring, and removing software packages on the system.

  • It is a central component of most Linux distributions and helps users efficiently manage software packages, libraries, and dependenciesπŸ“¦πŸ§

Kinds of Package ManagersπŸš€:

There are several package managers used in various Linux distributions. Some of the most commonly used ones are:

  1. APT (Advanced Package Tool): Used in Debian-based distributions like Ubuntu, Linux Mint, and Debian itself. πŸ”„πŸ“¦

  2. DNF (Dandified Yum): Used in Fedora and Red Hat Enterprise Linux (RHEL) distributions. 🎩🐧

  3. Pacman: Used in Arch Linux and its derivatives. πŸ‘ΎπŸ§

  4. Zypper: Used in openSUSE. πŸ“¦πŸ§

  5. Yum: Used in older versions of Fedora and RHEL, though it has been largely replaced by DNF. πŸš‚πŸ§

Install Docker 🐳 using Package Manager:

  • sudo apt update is an essential step in the package management process, ensuring that your system has the most up-to-date information about available packages, enabling smooth installations and upgrades, and maintaining the overall security and stability of your Linux system.

  • Then use sudo apt upgrade to download and install the latest versions of the packages that are already installed on your system. See below image for reference

  • Now execute the command sudo apt install docker.io to install docker on your machine. Here apt is the package manager that is used to install packages or software on Ubuntu.

  • After installing docker, you can check whether its active or not by using the command systemctl which we will be covering in the next topic.

Install Jenkins πŸ’»πŸ› οΈ using Package Managers:

  • To install Jenkins first, add the repository key to your system:

      wget -q -O - https://pkg.jenkins.io/debian-stable/jenkins.io.key |sudo gpg --dearmor -o /usr/share/keyrings/jenkins.gpg
    

    The gpg --dearmor command is used to convert the key into a format that apt recognizes.

  • Now, 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'
    

    The [signed-by=/usr/share/keyrings/jenkins.gpg] portion of the line ensures that apt will verify files in the repository using the GPG key that you just downloaded.

  • Now run sudo apt update so that apt will use the new repository.

      sudo apt update
    
  • Now install jenkins using the below commands :

      sudo apt install jenkins
    

systemctl & systemd:

  • systemdis a system and service manager for Linux. The systemctl command is the primary tool to manage systemd

The systemctl command manages both system and service configurations, enabling administrators to manage the OS and control the status of services. Further, systemctl is useful for troubleshooting and basic performance tuning.

Quick-read.txt : In linux we have an initialization process wherein individual services install relevant scripts on the /etc/init.d directory. SysVInit is the classic initialization process that works like this. On the other hand we have Systemd as the recent initialization system that aims to replace SysVInit.

Unlike SysVInit, SystemD continues to run as a daemon process after the initialization is completed. The systemctl command is the entry point for users to interact and configures the SystemD. With service you can only do commands related to the service (i.e. status, reload, restart) whereas with systemctl you can use more advanced commands.

Now let's look at some applications of systemctl command :)


Applications of systemctl:

  • To know the status of an application/ service we can use systemctl. In the below example lets try using systemctl for Docker (previously installed):

  • Lets start the service and then check the status again :

      sudo systemctl start docker
      #using sudo since we are signed in as ubuntu here, we need administrative/
      #root access here to start/ stop the service
    


Thats it for Day7 of #90daysofdevops. Upcoming blogs will be very important as part of our DevOps journey. We will be learning about Version Control System (GIT) and its web-based platform(Github). Stay tuned. Ciao!! :)πŸš€