๐Ÿงฐ What is a package manager in Linux?

๐Ÿงฐ What is a package manager in Linux?

ยท

5 min read

A ๐Ÿ“ฆpackage manager is a tool that is used to install, upgrade, manage, and remove packages. It is responsible to manage dependencies and to track all installed packages.

๐Ÿญ Repositories: Package managers have access to vast collections of software called repositories, like online stores filled with free and open-source software ready for installation.

๐Ÿ” Searching: You can search for software packages by name or keywords using the package manager, just like searching for products in an online marketplace.

โž• Installation: Once you find the software you want, simply ask the package manager to install it. It takes care of all the complex steps, such as downloading, verifying, and setting up the software.

๐Ÿ”„ Updates: The package manager also updates your software by regularly checking for updates and notifying you when new versions are available. Upgrading is as easy as clicking a button.

โŒ Removal: If you no longer need a software package, you can ask the package manager to remove it, which will clean up all related files for you.

๐Ÿ“‹ Dependencies: Some software relies on other software to work correctly. Package managers handle these dependencies automatically, ensuring everything works smoothly together.

๐Ÿ” Security: Package managers verify the authenticity of the software you install, reducing the risk of malicious or compromised packages.

๐ŸŒŸ Convenience: With a package manager, you save time and effort. No need to visit different websites, download installers, or worry about updates. Everything is streamlined and managed in one place. ๐Ÿ˜Š

๐Ÿ“ฆ What is a package?

In Linux, a package is a software distribution format that contains all the necessary files and information ๐Ÿ“ƒ required to install and manage a specific piece of software. Packages typically include the executable binaries ๐Ÿ’พ, libraries ๐Ÿ“š, configuration files ๐Ÿ“, and documentation ๐Ÿ“„ needed to run the software on a Linux system ๐Ÿง.

  • dpkg (Debian Package Manager)

  • APT (Advanced Package Tool)

  • rpm (RedHat Package Manager)

  • yum (Yellowdog Update Modified)

  • dnf (Dandified Yum)

  • zypper

  • flatpak

  • pacman

APT (Advanced Package Tool):

APT is widely used in Debian-based distributions like Ubuntu and is known for its user-friendly command-line interface. This package manager simplifies the process of interacting with the package management system, making it easier for users to perform various operations. ๐Ÿ› ๏ธ

With APT, you can effortlessly install, update, and remove packages using simple commands:

  • To install a package: sudo apt-get install package_name

  • To update packages: sudo apt-get update followed by sudo apt-get upgrade

  • To remove a package: sudo apt-get remove package_name

YUM (Yellowdog Updater Modified):

YUM is commonly used in Red Hat-based distributions like CentOS and Fedora. Similar to APT, YUM provides a command-line interface for managing packages, making it convenient for users to handle software installations. ๐Ÿ› ๏ธ

  • To install a package: sudo yum install package_name

  • To update packages: sudo yum update followed by sudo apt-get upgrade

To remove a package: sudo yum remove package_name

๐ŸŽ RPM (Red Hat Package Manager)

RPM is like a well-known ๐ŸŽ gift box manager, the default package manager for Red Hat-based systems like Fedora, CentOS, and RHEL. Here's how you use it:

  • Install the Package: sudo apt install rpm ๐Ÿš€๐Ÿ“ฆ (Unpacking the RPM gift!)

    ๐Ÿ” Understanding systemctl and systemd

    systemd: systemd is a system and service manager for Linux. It serves as the init system, replacing SysVinit in modern distributions due to enhanced features and improved performance.

    It manages system initialization, processes, startup, shutdown, and resource utilization efficiently. One key advantage is starting services in parallel, reducing boot times. It provides socket activation for on-demand service start.

    Commonly used commands: systemctl and journalctl.

    systemctl: Systemctl is a command-line utility used to manage system services in Linux distributions that adopt the systemd init system. Systemd is a system and service manager that provides advanced features such as process management, logging, and service dependencies.

    Commands:

    • ๐Ÿ” sudo systemctl start service_name

    • ๐Ÿ› ๏ธ sudo systemctl stop service_name

    • ๐Ÿ”„ sudo systemctl restart service_name

    • ๐Ÿ”” sudo systemctl enable service_name

    • ๐Ÿ”• sudo systemctl disable service_name

      ๐Ÿณ Docker Installation using Package Managers ๐Ÿ“ฆ

      Docker, the containerization marvel, allows us to encapsulate applications and dependencies in lightweight containers. Let's install Docker on both Ubuntu and CentOS using their respective package managers.

      ๐Ÿ“Œ Ubuntu Installation (using apt):

      • Open your terminal and update package lists:

            codesudo apt update
        
      • Install Docker using apt:

            codesudo apt install docker.io
        
      • Verify Docker installation:

            codedocker --version
        

๐Ÿ“Œ CentOS Installation (using yum):

  • Open your terminal and update package lists:

        codesudo yum update
    
  • Install Docker using yum:

        codesudo yum install docker
    
  • Start Docker service:

        codesudo systemctl start docker
    
  • Enable Docker to start on boot:

        sudo systemctl enable docker
    
  • Verify Docker installation:

        codedocker --version
    

๐Ÿ—๏ธ Jenkins Installation using Package Managers ๐Ÿ“ฆ

Jenkins, the automation powerhouse, empowers us to build, test, and deploy projects. Let's install Jenkins on both Ubuntu and CentOS using their respective package managers.

๐Ÿ“Œ Ubuntu Installation (using apt):

  • Add Jenkins repository key:

        wget -q -O - https://pkg.jenkins.io/debian/jenkins.io.key | sudo apt-key add -
    
  • Add Jenkins repository to sources list:

        sh -c 'echo deb http://pkg.jenkins.io/debian-stable binary/ > /etc/apt/sources.list.d/jenkins.list'
    
  • Update package lists:

        sudo apt update
    
  • Install Jenkins using apt:

        sudo apt install jenkins
    
  • Start Jenkins service:

        sudo systemctl start jenkins
    
  • Enable Jenkins to start on boot:

        sudo systemctl enable jenkins
    

๐Ÿ“Œ CentOS Installation (using yum):

  • Add Jenkins repository to yum repository list:

        sudo wget -O /etc/yum.repos.d/jenkins.repo http://pkg.jenkins.io/redhat-stable/jenkins.repo
    
  • Import Jenkins repository key:

        sudo rpm --import http://pkg.jenkins.io/redhat-stable/jenkins.io.key
    
  • Install Jenkins using yum:

        sudo yum install jenkins
    
  • Start Jenkins service:

        sudo systemctl start jenkins
    
  • Enable Jenkins to start on boot:

            sudo systemctl enable jenkins
    

    These commands can be useful for managing system services on Linux systems, including starting, stopping, and monitoring services as well as configuring which services start at boot.

Did you find this article valuable?

Support DevOps_journey by becoming a sponsor. Any amount is appreciated!

ย