In traditional operating systems, installing software involves manually searching websites for .exe or installer files, risking malware and broken dependencies. In Linux, software is organized into cryptographically signed, pre-compiled archives called packages, maintained in official repositories (repos), and managed automatically by a Package Manager.
A package manager automatically calculates prerequisites (dependencies), downloads required libraries, installs binaries into /usr/bin, registers service units, and allows seamless updates and clean uninstallation across the entire system.
The Linux world is divided into two primary packaging formats and a few emerging universal standards:
| Distro Family | Package Extension | Low-Level Tool | High-Level Package Manager | Repo Config Directory |
|---|---|---|---|---|
| Debian / Ubuntu / Mint | .deb |
dpkg |
apt, apt-get |
/etc/apt/sources.list, /etc/apt/sources.list.d/ |
| RHEL / Fedora / Rocky | .rpm |
rpm |
dnf (formerly yum) |
/etc/yum.repos.d/ |
| openSUSE / SLES | .rpm |
rpm |
zypper |
/etc/zypp/repos.d/ |
| Arch Linux / Manjaro | .pkg.tar.zst |
pacman |
pacman, yay (AUR) |
/etc/pacman.conf |
On Debian-based distributions like Ubuntu and Linux Mint, the unified apt CLI tool is the primary package manager:
# STEP 1: Refresh local metadata index from remote repositories
$ sudo apt update
# STEP 2: Upgrade all installed packages to their latest versions
$ sudo apt upgrade -y
# STEP 3: Search for software by keyword
$ apt search nginx
# STEP 4: Display package metadata, dependencies, and installed size
$ apt show nginx
# STEP 5: Install single or multiple packages with automatic dependency resolution
$ sudo apt install -y nginx git htop curl
# STEP 6: Remove software (preserves configuration files in /etc)
$ sudo apt remove nginx
# STEP 7: Completely purge software AND all related configuration files
$ sudo apt purge nginx
# STEP 8: Clean up orphaned dependency libraries no longer required
$ sudo apt autoremove --purge
When you download a standalone .deb file directly from a vendor (e.g., Google Chrome or VS Code):
# Install downloaded local deb package
$ sudo dpkg -i google-chrome-stable_current_amd64.deb
# Resolve missing dependencies after dpkg installation
$ sudo apt install -f
# List all installed Debian packages matching a pattern
$ dpkg -l | grep python
# Find which installed package owns a specific system file
$ dpkg -S /usr/bin/curl
curl: /usr/bin/curl
In Red Hat Enterprise Linux and Fedora, DNF (Dandified YUM) provides high-speed SAT-based dependency calculations:
# Refresh repository cache and check for security updates
$ sudo dnf check-update
# Upgrade all system packages
$ sudo dnf upgrade -y
# Install an enterprise web server stack
$ sudo dnf install -y httpd mariadb-server
# Search and inspect package details
$ dnf info httpd
# Remove software and its unused dependencies
$ sudo dnf remove httpd
# View transaction history with full rollback capability!
$ sudo dnf history
ID | Command Line | Date and time | Action(s) | Altered
4 | install -y httpd | 2026-11-02 08:30 | Install | 8
3 | upgrade -y | 2026-11-01 10:15 | Upgrade | 42
# Rollback a bad installation
$ sudo dnf history undo 4
Linux package managers enforce digital security: every downloaded package is verified using the creator's GPG public key. Installing cutting-edge packages often requires adding third-party repositories:
# Modern Ubuntu/Debian Signed-by PPA addition:
$ sudo curl -fsSL https://download.docker.com/linux/ubuntu/gpg -o /etc/apt/keyrings/docker.asc
$ echo "deb [arch=amd64 signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list
$ sudo apt update
To overcome distro fragmentation and conflicting shared library versions, universal sandboxed packaging formats have gained immense popularity:
• Snap (Canonical): Bundles all dependencies; auto-updates in the background; managed via snap install <package>.
• Flatpak: Desktop application sandbox favored by Fedora and Flathub; runs apps isolated from host root libraries via Bubblewrap.
• AppImage: Single executable file requiring zero installation; just download, chmod +x App.AppImage, and run directly.
# Task 1: Check your distribution release and package manager version
$ cat /etc/os-release
$ apt --version || dnf --version
# Task 2: Query which package installed a specific command binary
$ which ping
$ dpkg -S $(which ping) || rpm -qf $(which ping)
# Task 3: Simulate package installation without actually writing to disk
$ apt install -s htop
# Task 4: View disk cache consumed by downloaded package archives
$ du -sh /var/cache/apt/archives/ || du -sh /var/cache/dnf/
# Task 5: Clean up old cached package files to reclaim storage
$ sudo apt clean || sudo dnf clean all
apt is the modern, user-friendly CLI tool introduced in Debian 8 / Ubuntu 14.04. It consolidates options from apt-get, apt-cache, and apt-config, displaying colorized progress bars and useful hints. apt-get is preserved for backward compatibility in shell scripts due to its consistent, machine-parseable output format.
If an interrupted installation locks the packaging database or leaves missing dependencies, run: sudo apt update --fix-missing followed by sudo apt install -f (fix broken). If the lockfile is held by a hung process, terminate it with sudo fuser -vki /var/lib/dpkg/lock-frontend and run sudo dpkg --configure -a.
apt remove deletes the executable binaries and libraries of a program but leaves its configuration files in /etc intact so settings persist if reinstalled. apt purge removes both the application binaries AND all related system configuration files, returning the OS to a clean state.
Learn how Linux boots, manages background daemons, and controls system state in Class 49: Systemd & Service Management (systemctl, journalctl).
Continue to Class 49: Systemd & Services → Previous: ← Class 47: Telnet & FTP | Full Syllabus