Lesson 2: The Librarian (Advanced Package Management)
You've learned how to install software with apt. But a true DevOps engineer needs to search, inspect, and manage packages like a librarian managing a massive library.
Searching the Catalog: apt-cache search
Don't know the exact package name? Search for it:
apt-cache search web server
This searches through all available packages and returns matches. You'll see results like:
nginx - small, powerful, scalable web/reverse proxy server
apache2 - Apache HTTP Server
Inspecting a Package: apt-cache show
Before installing, check what a package does, its version, dependencies, and size:
apt-cache show nginx
This shows:
- Version — Which version is available.
- Depends — What other packages it needs.
- Size — How big the download is.
- Description — What the software actually does.
Listing Installed Packages: dpkg
dpkg is the lower-level package manager behind apt. To see what's already installed:
dpkg -l # List ALL installed packages
dpkg -l | grep nginx # Search for a specific one
Removing Packages
apt remove nginx # Remove but keep config files
apt purge nginx # Remove everything, including configs
apt autoremove # Clean up unused dependencies
booting...
Mission Objective
You're auditing a server to understand what's installed:
- Search the catalog: Run
apt-cache search nginxto find web server packages. - Read the details: Use
apt-cache show curlto inspect the curl package. - Audit the system: Run
dpkg -l | head -20to see the first 20 installed packages.
Pro Tip
Always run apt update before apt install to make sure you're getting the latest version. Stale package lists are a common source of "package not found" errors.