Introduction
This lesson is about Debian-style package management.
The main question is:
How do you install, remove, inspect, and search packages on Debian-based systems?
What you should be able to do after this lesson:
- Use
dpkgfor local package operations. - Use
apt-getandapt-cachefor repository-based work. - Find which package owns a file.
- Read package status and dependency information.
- Recognize
/etc/apt/sources.list.
Two Layers: dpkg and apt
dpkg
This is the low-level Debian package tool.
It works directly with .deb packages.
apt
This is the higher-level tool that works with repositories and dependency resolution.
Simple way to remember it:
dpkgworks on package files;aptworks on package sources and dependencies
Basic dpkg Commands
Install a local package
sudo dpkg -i package.deb
Important beginner note:
dpkg -iworks directly on a local package file- if dependencies are missing, the package may not end up fully configured until you fix them
Remove a package but keep config files
sudo dpkg -r package-name
Remove a package and its config files
sudo dpkg -P package-name
Show package status
dpkg -s package-name
Show installation status in a package list
dpkg -l | head
List installed files from a package
dpkg -L package-name
Find which package owns a file
dpkg -S /usr/bin/ssh
Representative example output:
openssh-client: /usr/bin/ssh
What this shows:
- the package name is on the left
- the owned file path is on the right
Basic apt-get Commands
Update package lists
sudo apt-get update
Install a package
sudo apt-get install package-name
Upgrade packages
sudo apt-get upgrade
Remove a package
sudo apt-get remove package-name
apt-cache: Search and Inspect
Search by keyword
apt-cache search nginx
Representative example output:
nginx - small, powerful, scalable web/proxy server
nginx-common - small, powerful, scalable web/proxy server - common files
What this shows:
apt-cache searchreturns matching package names and short descriptions- one search term can return multiple related packages
Show package information
apt-cache show nginx
Check version and repository info
apt-cache policy nginx
Show dependencies
apt-cache depends nginx
Package Sources
Repository definitions often live in:
/etc/apt/sources.list
/etc/apt/sources.list.d/
The exam idea is simple:
- these files tell APT where packages come from
dpkg-reconfigure
This tool lets you re-run package configuration questions for some packages.
Example:
sudo dpkg-reconfigure tzdata
Reinstall and Package Integrity Awareness
LPIC expects more than just install/remove basics.
Useful ideas to recognize:
- a package can be installed but misconfigured
- a file can exist even when the package is not currently installed
- dependency information matters when troubleshooting broken package states
Common reinstall pattern:
sudo apt-get install --reinstall package-name
Common package questions:
- Is it installed?
- What version is it?
- What files does it contain?
- What does it depend on?
A Safe Mental Workflow
When using Debian package tools:
apt-get update- inspect package info if needed
- install or upgrade
- use
dpkgwhen you need package-file details
Practice Step by Step
1) Find which package owns a file
- Run:
dpkg -S /usr/bin/ssh - Read the package name on the left.
2) Search for a package before installing it
- Update metadata:
sudo apt-get update - Search:
apt-cache search editor - Inspect a candidate:
apt-cache show nano
3) Reconfigure an installed package
- Run:
sudo dpkg-reconfigure tzdata - Follow the prompts.
Cheat Sheet
dpkg -i= install a local.debdpkg -r= remove package, keep configsdpkg -P= purge package and configsdpkg -s= show package statusdpkg -L= list files from a packagedpkg -S <file>= find package owning a fileapt-get update= refresh package listsapt-get install= install from reposapt-get upgrade= upgrade packagesapt-cache search= search packagesapt-cache show= show package details/etc/apt/sources.list= package source configuration
Test Your Knowledge
Complete the quiz to assess your understanding of this course's concepts.
