Understanding package manager and systemctl

Harish GawandeHarish Gawande
4 min read

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?

In simpler words, 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.

Key functions of a package manager in Linux include:

  1. Package Installation: The package manager allows users to easily install software packages by providing a command or graphical interface. It retrieves the necessary files from repositories and installs them on the system.

  2. Dependency Resolution: Software often relies on other libraries or components (dependencies). A package manager automatically resolves and installs the required dependencies for a given software package.

  3. Version Management: Package managers keep track of software versions and allow users to install, upgrade, or downgrade to specific versions of packages.

  4. Update Management: Package managers provide a streamlined way to update installed software packages to newer versions. This ensures that the system stays up-to-date with the latest security patches and features.

  5. Uninstallation: Users can easily remove installed software packages using the package manager, and it will handle the removal of associated files and dependencies.

  6. Repository Management: Package managers interact with repositories, which are online or local collections of software packages. They fetch information about available packages, dependencies, and updates from these repositories.

Common package managers in Linux include:

  • Advanced Package Tool (APT): Used by Debian-based distributions like Ubuntu. Commands include apt-get and apt.

  • Yellowdog Updater, Modified (YUM): Used by Red Hat-based distributions like CentOS and Fedora. Commands include yum.

  • zypper: Used by openSUSE.

  • Pacman: Used by Arch Linux.

  • Dnf (Dandified YUM): An updated version of YUM, used by some newer Red Hat-based distributions.

  • Portage: Used by Gentoo.

Package managers enhance the efficiency of software management in Linux, making it easier for users to maintain a well-organized and up-to-date system.

How to install docker and Jenkins in the system from the terminal using package managers.

Embracing DevOps practices often involves leveraging powerful tools that streamline the software development lifecycle. In this guide, we'll explore the hassle-free installation and uninstallation of two crucial tools—Docker and Jenkins—using package managers on Ubuntu and CentOS.

Installing / Uninstalling Docker on Ubuntu:

Step 1: Update Package Repositories

sudo apt-get update

Step 2: Install Docker

sudo apt-get install docker.io

Step 3: Start and Enable and Check Docker Status

sudo systemctl start docker
sudo systemctl enable docker
sudo systemctl status docker
#sudo systemctl stop docker

Step 4: Uninstalling Docker

sudo apt remove --purge docker.io

Installing / Uninstalling Docker on CentOS:

Step 1: Enable Docker CE Repository

sudo yum install -y yum-utils
sudo yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo

Step 2: Install Docker

 sudo yum install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin

Step 3: Start and Enable Docker

sudo systemctl start docker
sudo systemctl enable docker
sudo systemctl status docker

Step 4: Stop Docker

Step 5: Uninstalling Docker

sudo yum install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
sudo rm -rf /var/lib/docker
sudo rm -rf /var/lib/containerd

Installing / Uninstalling Jenkins on Ubuntu:

Step 1: Install Java

sudo apt install openjdk-17-jdk

Step 2: Add Jenkins Repository Key

sudo wget -O /usr/share/keyrings/jenkins-keyring.asc \
  https://pkg.jenkins.io/debian-stable/jenkins.io-2023.key

Step 3: Add Jenkins Repository

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

Step 4: Update Package Repositories

sudo apt-get update

Step 5: Install Jenkins

sudo apt-get install jenkins

Step 6: Start and Enable Jenkins

sudo systemctl start jenkins
sudo systemctl enable jenkins
sudo systemctl status jenkins

Step 7: Stop the Jenkins

sudo systemctl stop jenkins

Step 8: Uninstalling Jenkins

sudo apt remove --purge jenkins
sudo rm -rf /var/lib/jenkins

Installing / Uninstalling Jenkins on CentOS:

Step 1: Install Java & wget

sudo yum install java-17-openjdk
sudo yum install wget

Step 2: Add Jenkins Repository

sudo wget -O /etc/yum.repos.d/jenkins.repo https://pkg.jenkins.io/redhat/jenkins.repo
sudo rpm --import https://pkg.jenkins.io/redhat/jenkins.io.key

Step 3: Install Jenkins

sudo yum install jenkins

Step 4: Start and Enable Jenkins

sudo systemctl start jenkins
sudo systemctl enable jenkins
sudo systemctl status jenkins

Step 5: Stop Jenkins

sudo systemctl stop jenkins
sudo systemctl status jenkins

Step 6: Uninstalling Jenkins

sudo yum remove jenkins
sudo rm -rf /var/lib/jenkins

By following these straightforward steps, you've effortlessly installed and uninstalled Docker and Jenkins on both Ubuntu and CentOS. These tools are now at your disposal, ready to enhance your DevOps journey. Whether you're containerizing applications with Docker or orchestrating CI/CD pipelines with Jenkins, these package manager commands simplify the management of these essential DevOps tools.

Happy DevOps-Learning!

0
Subscribe to my newsletter

Read articles from Harish Gawande directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Harish Gawande
Harish Gawande