Skip to main content

Command Palette

Search for a command to run...

Day 7 Task: Understanding package manager and systemctl

Updated
3 min read
Day 7 Task: Understanding package manager and systemctl
  • Package Manager:

  • Linux has several package managers that are used to install and manage software packages. Here are some of the popular package managers for Linux:

  1. Advanced Package Tool (APT) - APT is the default package manager for Debian and its derivatives, such as Ubuntu and Linux Mint. It uses .deb packages.

  2. Yellowdog Updater Modified (YUM) - YUM is the default package manager for Red Hat Enterprise Linux (RHEL) and its derivatives, such as CentOS and Fedora. It uses .rpm packages.

  3. Pacman - Pacman is the package manager for Arch Linux and its derivatives. It uses .pkg.tar.xz packages.

  4. Zypper - Zypper is the default package manager for SUSE Linux Enterprise and openSUSE. It uses .rpm packages.

  5. Portage - Portage is the package manager for Gentoo Linux. It uses .ebuild scripts to build and install software packages from source code.

  • These package managers provide a simple and efficient way to install, update, and remove software packages on Linux. They also handle dependencies and ensure that all required software components are installed, which makes it easier to manage software on a large scale.

  • Task: Installing docker and Jenkins in your system from your terminal using package managers

Installing Docker:

  1. Update the package list:
sudo apt-get update
  1. Install the required packages to allow the use of Docker repositories over HTTPS:
sudo apt-get install -y apt-transport-https ca-certificates curl gnupg-agent software-properties-common
  1. Add Docker's official GPG key:
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
  1. Add the Docker repository to the APT sources:
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
  1. Update the package list again:
sudo apt-get update
  1. Install Docker:
sudo apt-get install -y docker-ce docker-ce-cli containerd.io
  1. Verify that Docker is installed correctly by running the following command:
sudo docker run hello-world

Installing Jenkins:

  1. Add the Jenkins repository key:
wget -q -O - https://pkg.jenkins.io/debian/jenkins.io.key | sudo apt-key add -
  1. Add the Jenkins repository to the APT sources:
sudo sh -c 'echo deb http://pkg.jenkins.io/debian-stable binary/ > /etc/apt/sources.list.d/jenkins.list'
  1. Update the package list:
sudo apt-get update
  1. Install Jenkins:
sudo apt-get install -y jenkins
  • Check the status of the docker service in your system:

$systemctl status docker

  • Stop the service Jenkins and post before and after screenshots:

$sudo systemctl stop jenkins

  • Systemctl vs Service

  • Both systemctl and service are command-line utilities in Linux that are used to manage system services, but they have some differences in their usage and functionality.

  • service is a traditional SysV init command used to manage services on older Linux systems. It is still included in many modern Linux distributions for compatibility reasons. The service command can be used to start, stop, restart, and check the status of a service, among other things.

  • systemctl is a newer and more powerful command used to manage services on modern Linux systems that use systemd as their init system. The systemctl command can be used to start, stop, restart, reload, and check the status of a service, as well as enable or disable a service so that it starts automatically at boot time.

  • One of the key differences between service and systemctl is that systemctl is more granular in its control of services. It allows us to manage individual units, such as services, targets, timers, and sockets. systemctl also provides more detailed information about services and their dependencies, making it easier to troubleshoot issues.

  • Overall, if you are using a modern Linux system with systemd, systemctl is likely the better option for managing services. However, if we are using an older Linux system or need to manage a specific service that only supports service, then we may need to use service instead.