What is a Package Manager in Linux?

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.

You’ll often find me using the term ‘package’ in tutorials and articles. To understand a package manager, you must understand what a package is.

What is a Package?

A package is usually referred to as 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.

Different Kinds of Package Managers

Package managers differ based on the packaging system but the same packaging system may have more than one package manager.
For example, RPM has Yum and DNF package managers. For DEB, you have apt-get, aptitude command line-based package managers.

Package Managers for Different Linux Distributions

Different Linux distributions use different package management systems. Here are the main ones:

Debian-based Distributions (Debian, Ubuntu, Linux Mint)

  • APT (Advanced Package Tool)

    • Commands: apt, apt-get, aptitude

    • Package format: .deb

    • Example: sudo apt install package-name

    • Package repository: /etc/apt/sources.list

Red Hat-based Distributions (RHEL, CentOS, Fedora)

  • YUM/DNF (Yellowdog Updater Modified/Dandified YUM)

    • Commands: yum (older versions), dnf (newer versions)

    • Package format: .rpm

    • Example: sudo dnf install package-name

    • Package repository: /etc/yum.repos.d/

Arch Linux-based Distributions (Arch, Manjaro)

  • Pacman

    • Command: pacman

    • Package format: .pkg.tar.xz

    • Example: sudo pacman -S package-name

    • Package repository: /etc/pacman.conf

SUSE-based Distributions (openSUSE, SLES)

  • Zypper

    • Command: zypper

    • Package format: .rpm

    • Example: sudo zypper install package-name

    • Package repository: /etc/zypp/repos.d/

Common Package Management Operations:

  1. Update package list:

    • Debian: sudo apt update

    • RHEL: sudo dnf update

    • Arch: sudo pacman -Sy

    • SUSE: sudo zypper refresh

  2. Upgrade packages:

    • Debian: sudo apt upgrade

    • RHEL: sudo dnf upgrade

    • Arch: sudo pacman -Syu

    • SUSE: sudo zypper update

  3. Remove packages:

    • Debian: sudo apt remove package-name

    • RHEL: sudo dnf remove package-name

    • Arch: sudo pacman -R package-name

    • SUSE: sudo zypper remove package-name

  4. Search for packages:

    • Debian: apt search keyword

    • RHEL: dnf search keyword

    • Arch: pacman -Ss keyword

    • SUSE: zypper search keyword

How to Install Packages on Ubuntu and CentOS

Introduction

In this article, we will use Docker as examples for package installation on Ubuntu and CentOS Linux distributions.

Docker is an essential tools in the DevOps toolkit. Docker allows you to containerize applications, while Jenkins automates the building, testing, and deployment of software. This guide will walk you through installing both tools on Ubuntu and CentOS using package managers.

Installing Docker on Ubuntu and CentOS

On Ubuntu

  1. Update the Package Index:

     sudo apt-get update
    
  2. Install Required Packages:

     sudo apt-get update && sudo apt install docker.io
    
  3. Verify Docker Installation:

     sudo systemctl status docker
    

On CentOS

  1. Update the System:

     sudo yum update
    
  2. Install Docker:

     sudo yum install docker-ce
    
  3. Start Docker:

     sudo systemctl start docker
    
  4. Enable Docker to Start at Boot:

     sudo systemctl enable docker
    
  5. Verify Docker installation:

        sudo systemctl status docker
    

Conclusion

By following these steps, you can easily install Docker or any other package on Ubuntu, CentOS, or any Linux distribution. These tools will help streamline your development and deployment processes.

Follow for more useful content!🙃🙃