Package Management
Objective: Understand how Linux installs, updates, and removes software.
Every service you've installed used apt. But do you understand what happened? Where did the software come from? How does your system know what's available? What happens when packages conflict?
Instead of downloading .exe files from random websites, Linux pulls software from curated repositories. The package manager handles downloading, installing, dependency resolution, and updates.
Repositories: Servers that host software packages. Ubuntu has: main (officially supported), universe (community), restricted (proprietary), multiverse (non-free).
Dependencies: Software that other software needs to run. apt resolves these automatically.
PPAs: Personal Package Archives. Third-party repos. Use with caution.
Updating vs. Upgrading: apt update refreshes the package list. apt upgrade installs newer versions.
sudo apt updateRefresh the package index from all repossudo apt upgradeUpgrade all installed packages to latest availablesudo apt install [package]Install a packagesudo apt remove [package]Remove (keeps config files)sudo apt purge [package]Remove package and its config filessudo apt autoremoveRemove packages no longer needed as dependenciesapt search [keyword]Search available packagesapt show [package]Show detailed info about a packagedpkg -lList all installed packagesdpkg -L [package]List all files installed by a packageapt-cache policy [package]Show available versions and which repo they come from- 1
Run sudo apt update && sudo apt upgrade. Document what happened. How many packages were upgraded? Were any held back? Why?
- 2
Install a package you haven't used (e.g., tree, ncdu, tmux). Use dpkg -L to see every file it installed. Where did the binary end up? Where are the config files?
- 3
Remove with apt remove. Check if config files remain. Remove them with apt purge. Explain the difference.
- 4
Run apt-cache policy nginx. What version is available? Which repo is it coming from?
- 5
View /etc/apt/sources.list. Document what repos your system pulls from. Explain what main, universe, and restricted mean.
- 6
Simulate a broken dependency: install a package, manually remove a dependency with dpkg --remove. See what happens. Fix with sudo apt --fix-broken install.