On Windows, installing software means: Google it → Find a website → Hope it’s not malware → Click “Next” 12 times. On Linux, it’s one command. And it’s safer.
Introduction
A package manager is one of Linux’s most underrated superpowers. It’s a command-line tool that can install, update, verify, and remove software — automatically handling all dependencies for you. No hunting for installers, no sketchy download sites.
- What a package manager actually does under the hood
aptcommands for Ubuntu and Debiandnfcommands for Red Hat, Fedora, and Rocky Linuxsnapfor cross-distro universal packages- How to keep your system clean and updated
A package manager is like your phone’s App Store — but for your entire system:
- The repository = the App Store’s catalog (thousands of free, verified apps)
apt install nginx= tapping “Install” on an appapt update= refreshing the catalog to see new versions- Dependencies = apps that require other apps to work (handled automatically)
The key difference? Everything is verified, free, and updated forever.
How Package Management Works
The flow in plain English:
apt update— Downloads the latest catalog from the repository serverapt install nginx— Finds nginx in the catalog, downloads it and all its dependencies- Packages go into a local cache (
/var/cache/apt/archives/) - Files are installed into the correct system locations (
/usr/bin/,/etc/, etc.)
apt — Ubuntu, Debian, Kali, Mint
apt (Advanced Package Tool) is the dominant package manager on Debian-based distributions.
The Essential Workflow
Always update before installing:
Refresh the package list from repositories
Upgrade all installed packages to latest versions
apt update only refreshes the list — it downloads no packages.
apt upgrade actually downloads and installs new versions.
Run update first, then upgrade.
Install, Remove, Search
Install nginx web server
Install multiple packages at once (-y skips confirmation)
Remove nginx (keeps config files)
Remove nginx AND all its config files
Search available packages by name
Show details about a package
Keeping the System Clean
Remove packages no longer needed by anything else
Delete all cached package files (free up disk space)
Show what’s installed:
List all installed packages
Check if nginx is installed
dnf — Red Hat, Fedora, Rocky, AlmaLinux
dnf (Dandified YUM) replaced the older yum on modern Red Hat-based systems. The commands map 1:1 with apt.
| apt command | dnf equivalent |
|---|---|
apt update | dnf check-update |
apt install X | dnf install X |
apt remove X | dnf remove X |
apt upgrade | dnf upgrade |
apt search X | dnf search X |
apt autoremove | dnf autoremove |
Check for available updates
Install nginx
Remove nginx
Upgrade all packages
Check what’s installed:
List all installed packages (RPM)
Check if nginx is installed
snap — Universal Packages for Any Distro
snap packages are self-contained — they bundle their own dependencies so the same snap works on Ubuntu, Fedora, Arch, everywhere. They’re sandboxed for security.
Use snap when:
- You need the latest version of an app (e.g., VS Code, Discord, Firefox)
- You’re on a distro where the package is outdated in the official repos
- You want easy rollback to previous versions
Search for VS Code in the snap store
Install VS Code (--classic for filesystem access)
Remove VS Code snap
Update all installed snaps
List all installed snaps
Roll back VS Code to its previous version
Snaps start slightly slower than native packages (they mount a filesystem image). For desktop apps, this is fine. For servers, prefer apt/dnf.
Real-World Scenarios
Scenario 1: Set Up a New Server
# Update everything first
sudo apt update && sudo apt upgrade -y
# Install your stack
sudo apt install -y nginx postgresql git curl ufw
# Clean up
sudo apt autoremove -y && sudo apt clean
Scenario 2: Find Which Package Owns a File
Which package installed this file? (Debian/Ubuntu)
Which package installed this file? (Red Hat)
Scenario 3: Install a .deb file Manually
Install a downloaded .deb file
Fix broken dependencies after dpkg
The Golden Rules of Package Management
- Always
sudo apt updatebefore installing — otherwise you get outdated versions. - Use
purgenotremovewhen you’re done with software permanently. - Run
autoremoveregularly — orphaned dependencies waste disk space. - Don’t mix sources — stick to official repos when possible. Third-party PPAs can break things.
Hands-On Challenge
- Run
sudo apt updateand count how many packages are listed. - Install
treewithsudo apt install tree. - Run
tree /etc/nginx(if nginx is installed) to see its config structure. - Remove
treewithsudo apt remove tree. - Run
sudo apt autoremoveto clean up.
Key Takeaways
- Package managers handle installation, updates, and removal — with dependency resolution built in.
apt= Ubuntu/Debian.dnf= Red Hat/Fedora.snap= any distro.- Always
apt updatebefore installing to get the latest package information. - Use
apt purge(notremove) to completely uninstall software including configs. - Run
apt autoremoveregularly to keep your system clean.
Test Your Knowledge
Take a quick 4-question quiz to check your understanding.