Hey everyone! If you’re new to the world of Linux, you might have heard the term package manager thrown around. It might sound a bit technical, but trust me, it’s one of the most user-friendly and powerful aspects of the Linux operating system. Think of it as your personal software assistant, always ready to help you get the applications you need, keep them up-to-date, and even clean up when you no longer need them.

In this blog post, I want to decode the Linux package managers. We’ll explore why they are absolutely essential, how they work their behind-the-scenes, and look at some of the most popular package managers you’ll encounter in different Linux distributions.

Imagine Software Installation Without a Package Manager… Chaos! It’s like lacking essential tools to run an application or to build something or to fix a problem.

To truly appreciate the beauty of package managers, let’s imagine what installing software on Linux would be like without them. It would be a bit like the Wild West of computing!

  • Dependencies: Software applications rarely work in isolation. They often rely on other software components, called dependencies, to function correctly. Without a package manager, you’d be responsible for finding and installing all these dependencies yourself. Imagine trying to install a web browser and then having to manually hunt down and install dozens of supporting libraries – it would take more time to collect all libraries and packages!

  • Manual Installation and Configuration: You’d likely have to download software files from various websites, figure out how to install them (often involving complex command-line instructions), and then manually configure them to work with your system. This process would be time-consuming, error-prone, and require a significant amount of technical knowledge.

  • Keeping Software Up-to-Date: Updating your software would be another manual headache. You’d have to track down new versions, download them, and then figure out how to replace the old ones without breaking anything.

  • Clean Uninstallation: Removing software cleanly would also be a challenge. Simply deleting the main application files might leave behind configuration files, libraries, and other remnants, potentially cluttering your system over time.

Sounds pretty messy, right? This is precisely the problem that package managers solve!

The Package Manager

A package manager is a powerful tool that automates the entire process of managing software on your Linux system. It acts as a central hub for installing, updating, configuring, and removing software, ensuring a smooth and consistent experience. Think of it as an intelligent librarian for your software.

How Does PM's Work?

Package managers work through a few key concepts:

os-1 Figure 1: Package Managers
  1. Repositories (Repos):

    • At the heart of the package manager system are repositories (repos). These are essentially online storage locations, maintained by the Linux distribution or trusted third parties, that contain collections of software packages. Think of them as well-organized digital warehouses filled with all the software you might need.
    • Each Linux distribution typically has its own set of official repositories that are regularly updated and tested. For example, Ubuntu gets its software from repositories like archive.ubuntu.com, Debian has its own repositories, and so on.
    • These repositories not only contain the software itself but also crucial information about each package, such as its name, version, description, dependencies, and installation instructions.
  2. Packages:

    • Software in these repositories is packaged into manageable units called packages. A package is essentially an archive file that contains the software application itself, along with metadata like installation scripts, configuration files, and information about its dependencies. Think of a package as a neatly wrapped software product ready for installation.
  3. Dependencies:

    • As we discussed earlier, software often relies on other software to function. The package manager keeps track of these dependencies. When you want to install a package, the package manager automatically identifies and installs any other packages that the software needs to run correctly. This eliminates the headache of manually finding and installing all those supporting components.
  4. The Package Manager Tool:

    • You, the user, interact with the package manager through a command-line tool (or sometimes a graphical interface). This tool allows you to issue commands to search for, install, update, and remove packages.


View the Reddit Discussion on Package Managers


The Step-by-Step Installation:

Let’s walk through what happens when you use a package manager to install a piece of software, say, the neofetch tool on Ubuntu using the apt package manager:

  1. You Tell the Package Manager What You Want: You open your terminal and type a command like sudo apt install neofetch and press Enter. This tells the apt package manager that you want to install the neofetch package. The sudo part gives the command the necessary administrative privileges to make changes to your system.

  2. The Package Manager Checks Its Inventory: The apt tool then consults its local database, which contains information about the packages available in the repositories that your system is configured to use. This database is like the index of the software library.

  3. Resolving Dependencies: The apt tool looks at the neofetch package information and identifies any other packages (dependencies) that neofetch needs to run. For example, neofetch might depend on certain shell utilities or terminal libraries.

  4. Fetching the Software Goodies: The apt tool then connects to the configured Ubuntu repositories (like archive.ubuntu.com) and downloads the neofetch package and all its required dependencies. It’s like your software assistant going to the warehouse and gathering all the necessary items.

  5. Installing the Packages: Once the packages are downloaded, the apt tool unpacks them and installs the software files in the correct locations on your system. It also runs any necessary installation scripts and configures the software to work properly.

  6. Updating the Local Database: Finally, the apt tool updates its local database to reflect the newly installed software.

Keeping Things Fresh: Updating Your System

Package managers also make it incredibly easy to keep your software up-to-date. On Ubuntu, you would typically run these commands:

> sudo apt update
> sudo apt update -y
  • sudo apt update: This command tells apt to connect to the configured repositories and download the latest information about the available packages and their versions. It updates the local package index without actually installing or upgrading any software. Think of it as checking the library catalog for new arrivals and updates.

  • sudo apt upgrade -y: This command tells apt to upgrade all the packages currently installed on your system to their newest versions available in the repositories. The -y flag automatically confirms the upgrade, so you don’t have to manually say “yes” to each package. This ensures that you have the latest features, bug fixes, and security patches.

Removing Software

When you no longer need a piece of software, the package manager can cleanly remove it from your system:

> sudo apt remove <package-name>

This command tells apt to remove the nginx package. It typically removes the main application files but might leave behind some configuration files in case you want to reinstall the software later.

If you want to completely remove the software and its configuration files, you can use:

> sudo apt purge <package-name>

Furthermore, package managers often have a command to automatically remove any dependencies that were installed for a specific package and are no longer needed by any other software on your system. On apt, this is:

> sudo apt autoremove

This helps keep your system clean and avoids wasting disk space on unnecessary libraries.

Different Linux distributions use different package managers. Here’s a quick look at some of the most common ones:

Linux Distribution(s) Package Manager
Ubuntu, Debian apt (Advanced Package Tool)
Fedora, Red Hat Enterprise Linux (RHEL), CentOS (Legacy) dnf (Dandified Yum) / yum (Yellowdog Updater, Modified - older)
Arch Linux pacman (Package Manager)
openSUSE zypper

Why You Absolutely Need to Run apt update (or its Equivalent) After a Fresh Install:

When you install a Linux distribution like Ubuntu from an ISO image, the software packages included in that image were current at the time the image was created. However, software development is constantly ongoing, and newer versions with bug fixes, security updates, and new features are regularly released to the repositories.

Therefore, the very first thing I always recommend doing after installing a fresh copy of Ubuntu (or any other Linux distribution) is to update the package lists using sudo apt update (or the equivalent command for your distribution). This ensures that your system has the latest information about the available software. Only after updating the package lists should you proceed to install new software or upgrade existing packages using sudo apt upgrade.

Best Practices for a Happy Package Manager Experience:

Always Update Before Installing: Make it a habit to run the update command (sudo apt update or its equivalent) before you try to install a new package. This ensures that you’re working with the latest information from the repositories.

  • Clean Up Unused Dependencies: Regularly use the autoremove command (or its equivalent) to remove any orphaned dependencies that are no longer required by any installed software. This helps keep your system lean and tidy.

  • Consider Automatic Security Updates: For enhanced security, especially on server systems, consider enabling automatic security updates. On Ubuntu, you can do this using the unattended-upgrades package.

Embrace Your Package Manager!

Linux package managers are truly a fantastic invention. They simplify software management, ensure consistency, and help keep your system secure and up-to-date. As you delve deeper into the world of Linux, you’ll find yourself relying on your package manager more and more. Embrace it, learn its basic commands, and you’ll have a much smoother and more enjoyable Linux experience!


Video Explanation here
A Great Reference and Guide to Linux Package Management!!


home