Day -> 7 of #90DaysOfDevOps

Understanding Package Manager and Systemctl

What is a Package Manager in Linux?

On Linux, software is typically built as a package, distributed through repositories, and managed on the end-user’s system through package managers. Each Linux system typically contains thousands of packages, many of which are required dependencies for other packages.

What is Package?

Most software applications designed for Linux or Unix systems are distributed as packages, which are archives that contain the pre-compiled binary software files, installation scripts, configuration files, dependency requirements, and other details about the software.'

Installing package in Ubuntu

  1. Firstly we need to update our system

    sudo apt-get update

  2. Install packages to allow apt to use a repository over HTTPS

    sudo apt-get install apt-transport-https ca-certificates curl software-properties-common

  3. Add Docker’s official GPG key

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

  4. Set up the stable repository

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

  5. Update the package index again

    sudo apt-get update

  6. Install Docker CE

    sudo apt-get install docker-ce

Systemctl and Systemd

Linux operating systems are known for their robustness and versatility, and managing system services is a crucial aspect of maintaining a well-functioning system. With the advent of systemd, a system and service manager for Linux operating systems, the systemctl command has become an essential tool for managing services. In this article, we will explore the intricacies of systemctl and how it can be used to control and monitor system services.

Let's understand with example

Check Docker Service Status ->

sudo systemctl status docker

This command will show you the current status of the Docker service, including whether it is active (running), inactive, or if there are any issues.

This is the output :

If the service is inactive, active with the below command

sudo systemctl start docker

Managing service ->

Starts a service -> sudo systemctl start service-name

Stops a running service -> sudo systemctl stop service-name

Enables a service to start automatically during system boot -> sudo systemctl enable service-name

Disables automatic startup for a service -> sudo systemctl disable service-name

Displays the current status of a service -> sudo systemctl status serice-name

systemctl status docker vs. service docker status ->

systemctl status docker generally provides more detailed and extensive output compared to service docker status

On modern Linux systems, systemctl status docker is typically preferred due to its detailed output and compatibility with the systemd system manager. Use service docker status on older systems or for simpler status checks.