Package Manager in Linux

Nirmal MahaleNirmal Mahale
6 min read

What is a package manager?

๐Ÿ“ฆ A package manager in Linux is like a magical ๐Ÿง™โ€โ™‚๏ธ assistant that helps you find, install, update, and remove software easily! It's like having a personal ๐Ÿ›๏ธ store for all your software needs!

  • ๐Ÿญ Repositories: Package managers have access to vast collections of software called repositories. These are like online stores with tons of free and open-source software ready to be installed.

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

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

  • ๐Ÿ”„ Updates: The package manager also keeps your software up-to-date. It regularly checks for updates and lets you know 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, and it'll clean up all the related files for you.

  • ๐Ÿ“‹ Dependencies: Sometimes, the software relies on other software to work correctly. Package managers handle these dependencies automatically, ensuring that 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 like a ๐ŸŽ gift box filled with all the necessary goodies to install and use software hassle-free! It's a handy way to organize and distribute software

  • ๐Ÿ“ฆ Definition: A package is a single file or archive that holds all the ๐Ÿ“‚ files and ๐Ÿ“‹ information required for a software program.

  • ๐Ÿงฉ Dependencies: Sometimes, software needs other pieces (dependencies) to work correctly. Packages include these dependencies, like having all the ๐Ÿงฉ puzzle pieces in one box.

  • ๐Ÿš€ Installation: When you want to use the software, you can easily install the package. It's like unwrapping the ๐ŸŽ gift and setting up the software for you.

  • ๐Ÿ”„ Updates: Packages can be updated to newer versions. Just like getting the latest ๐Ÿ“š book edition with extra chapters and improvements.

  • โŒ Removal: If you no longer need the software, you can remove the package. It's like cleaning up and putting everything back in the box.

  • ๐Ÿ” Security: Packages are designed to be safe and secure. They come from trustworthy sources, like getting products from reputable ๐Ÿ›’ stores.

  • ๐ŸŒ Repositories: Packages are typically stored in repositories, which are like big online ๐Ÿฌ marketplaces. The package manager knows where to find the right package for you.

Different kinds of package managers?

๐Ÿ“ฆ APT (Advanced Package Tool) - APT is like a handy ๐Ÿ› ๏ธ command-line Swiss Army knife, working with Ubuntu's Advanced Packaging Tool. Here are some examples of its use:

  • Install the Package: sudo apt-get install package_name ๐Ÿš€๐Ÿ“ฆ (Getting and unboxing the software gift!)

  • Update the Package: sudo apt-get update followed by sudo apt-get upgrade ๐Ÿ”„๐Ÿ“ฆ (Refreshing the software gift box and getting the latest version!)

๐Ÿ… YUM (YellowDog Update Manager) - YUM is like a friendly ๐Ÿ• dog providing a command-line interface for managing packages in RHEL. Here are some examples of its use:

  • Install the Package: sudo yum install package_name ๐Ÿš€๐Ÿ“ฆ (Fetching and unwrapping the package gift!)

  • Update the Package: sudo yum update & sudo apt-get upgrade ๐Ÿ”„๐Ÿ“ฆ (Refreshing the package gift box and getting the updates!)

  • Remove the Package: sudo yum remove package_name โŒ๐Ÿ“ฆ (Removing the package gift from your system!)

๐ŸŽ 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!)

๐Ÿณ 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
    

๐Ÿ”„ Systemctl vs Service: Unveiling the Differences โš”๏ธ

In the Linux realm, both systemctl and service commands are powerful warriors that handle services, but they have some differences in their functionality and usage. Let's explore their unique traits! ๐ŸŒŸ

๐Ÿ” Systemctl: The SystemD Champion ๐Ÿ›ก๏ธโš™๏ธ

Systemctl is a fearless warrior that directly interacts with the SystemD service manager, wielding its might to manage services with finesse! ๐Ÿ’ช

โœจ Functionality:

  • Start, stop, and restart services with ease.

  • Enable or disable services to control their behavior.

๐Ÿ› ๏ธ Usage:

  • Start Jenkins services: ๐Ÿ”ฅ

      systemctl start jenkins
    
  • Check Jenkins services status: ๐Ÿ‘€

      systemctl status jenkins
    

๐Ÿ”ง Service: The Trusty Ally ๐Ÿคโš™๏ธ

Service is a loyal ally that manages services by interacting with the SystemD process, complementing systemctl in its mission! ๐Ÿค

โœจ Functionality:

  • Start, stop, and restart services smoothly.

  • Enable or disable services with precision.

๐Ÿ› ๏ธ Usage:

  • Start Jenkins services: ๐Ÿ”ฅ

      service jenkins start
    
  • Check Jenkins services status: ๐Ÿ‘€

      service jenkins status
    

Conclusion :

Both "systemctl" and "service" commands are powerful tools for managing services in Linux. While "systemctl" directly interacts with the SystemD service manager, "service" complements it by interacting with the SystemD process. Both commands provide essential functionalities to start, stop, restart, enable, and disable services. Choose the command that suits your preferences and distribution, and embrace their power to become a Linux hero! ๐Ÿง๐Ÿ’ช #LinuxMagic #ServiceManagement #SystemctlVsService

๐Ÿ“ข Stay in the โ˜๏ธ cloud loop and blast off into the ๐Ÿš€ DevOps universe! Join me on Hashnode, where I share my latest insights and articles about all things cloud and DevOps. Let's connect on LinkedIn (https://www.linkedin.com/in/nirmal-mahale-605565215/) and explore the boundless possibilities of the tech cosmos together. ๐ŸŒŒ And hey, if you want to peek under the hood of my projects, hop on over to my GitHub (https://github.com/nirmal7030). ๐Ÿ› ๏ธ

1
Subscribe to my newsletter

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

Written by

Nirmal Mahale
Nirmal Mahale

Passionate about Python, Cloud Computing, and DevOps. Architecting robust cloud solutions, mastering AWS & Azure, and automating with cutting-edge DevOps tools. Join me on this journey of innovation and collaboration. Let's shape the future together!