System Administration · #11 of 19
Package Management
apt & Software Installation
What is a Package Manager?
A package manager is like an app store for the command line:
- Downloads software from trusted repositories
- Installs it in the right locations
- Handles dependencies (libraries it needs)
- Updates everything with one command
- Removes software cleanly
Ubuntu uses APT (Advanced Package Tool).
The apt Command
Updating Package Lists
sudo apt update # Refresh available packages
# This doesn't install anything — just updates the catalog
Upgrading Installed Packages
sudo apt upgrade # Upgrade all packages
sudo apt full-upgrade # Upgrade, including removals if needed
Installing Software
sudo apt install firefox # Install Firefox
sudo apt install vim git # Install multiple packages
sudo apt install ./package.deb # Install local .deb file
Removing Software
sudo apt remove firefox # Remove package (keep config)
sudo apt purge firefox # Remove package AND config files
sudo apt autoremove # Remove unused dependencies
Finding Packages
Search
apt search "text editor" # Search by keywords
apt search ^vim # Packages starting with 'vim'
Package Information
apt show vim # Details about a package
apt list --installed # All installed packages
apt list --upgradable # Packages with updates available
Check if Installed
dpkg -l | grep vim # Search installed packages
which vim # Find where it's installed
Repository Management
Packages come from repositories (repos). Ubuntu has:
- Main: Officially supported open source
- Universe: Community-maintained open source
- Restricted: Proprietary drivers
- Multiverse: Software with restrictions
Adding Repositories
# Add a PPA (Personal Package Archive)
sudo add-apt-repository ppa:user/repo
sudo apt update
# Add third-party repo manually
sudo add-apt-repository "deb http://example.com/repo stable main"
Repository Configuration
cat /etc/apt/sources.list # Main sources
ls /etc/apt/sources.list.d/ # Additional sources
Common Tasks
Update Everything
sudo apt update && sudo apt upgrade -y
Clean Up
sudo apt autoremove # Remove orphaned packages
sudo apt clean # Clear package cache
Fix Broken Packages
sudo apt --fix-broken install
sudo dpkg --configure -a
dpkg — Low-Level Tool
APT uses dpkg under the hood:
dpkg -l # List all installed packages
dpkg -i package.deb # Install a .deb file
dpkg -r package # Remove a package
dpkg -L vim # List files installed by vim
dpkg -S /usr/bin/vim # Which package owns this file?
Other Package Formats
Snap
snap find vlc # Search
snap install vlc # Install
snap list # List installed snaps
snap remove vlc # Remove
Flatpak
flatpak search gimp # Search
flatpak install flathub org.gimp.GIMP # Install
flatpak list # List installed
flatpak uninstall org.gimp.GIMP # Remove
Try It!
Practice package management in the terminal:
Exercises:
- Update package lists:
apt update(simulated) - Search for packages:
apt search editor - Show package info:
apt show vim - Install a package:
apt install htop - List installed:
apt list --installed
Try it in the terminal
A sandboxed shell with this lesson’s commands. Type help to see what’s available.