← Linux Mastery: From Zero to Hero

Package Management and Repositories

Task 1
Package Managers in Linux

A package manager is a collection of software tools that automates the process of installing, upgrading, configuring, and removing software on a Linux system.

You can think of it as the App Store or Play Store for your operating system.

The Role of a Package Manager

  • Simplified Installation and Uninstallation: A package manager installs all components of an application in a single operation. It also keeps a database of installed software, allowing complete removal of programs along with their related files and configurations.
  • Dependency Resolution: Many programs depend on other libraries or packages. A package manager automatically installs all required dependencies.
  • Software Updates and Upgrades: Package managers download updates from online repositories, making it easy to keep your system updated with the latest versions and security patches.
  • Configuration Management: Package installers recognize configuration files and avoid overwriting custom settings. They may create backup copies or provide example configuration files.
  • Repository Management: Most Linux software is distributed through central repositories maintained by distribution vendors and third parties. Package managers interact with these repositories to locate and download software.

Debian / Ubuntu Package Management (APT & dpkg)

The Low-Level Tool: dpkg

The dpkg tool installs, removes, and provides information about individual .deb package files. However, it does not handle dependencies automatically.

Common Usage:

# Install a package from a .deb file
sudo dpkg -i package_file.deb

# List all installed packages
dpkg -l

# Check if a package is installed
dpkg -s package_name

# Find which package installed a specific file
dpkg -S file_name

The High-Level Tool: apt

The Advanced Package Tool (APT) is a higher-level package management system built on top of dpkg.

APT automatically resolves dependencies and manages software repositories.

Common APT Commands:

# Update package list from repositories
sudo apt update

# Search for packages
apt search package_name

# Install a package (with dependencies)
sudo apt install package_name

# Remove a package
sudo apt remove package_name

# Upgrade installed packages
sudo apt upgrade