LPIC-1 Linux Installation and Package Management Practice Question
Which command lists all installed packages on a Debian-based system by querying the dpkg database?
⚠ Common exam trap
A common mix-up: candidates confuse `dpkg -L` (which lists files for a specific package) with a command that lists all installed packages, or they assume `apt-cache search .` shows only installed packages when it actually queries the entire repository cache.
Answer choices
Why each option matters
Answer the question above first, then reveal the full breakdown to understand why each option is right or wrong.
Correct answer & explanation
✓
dpkg --get-selections
`dpkg --get-selections` queries the dpkg database directly and outputs a list of all installed packages along with their installation state (e.g., 'install'). This command does not rely on remote repositories or cache files, making it a reliable method for listing installed packages on a Debian-based system.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✗
apt-cache search .
Why it's wrong here
apt-cache search . queries the APT package cache for available packages matching a pattern, including ones not installed, so it cannot enumerate installed packages. It is tempting because apt-cache inspects package metadata, but only dpkg-query -l or dpkg --list reads the local dpkg status database of installed packages.
- ✗
dpkg -L
Why it's wrong here
dpkg -L lists the files installed by a named package, requiring a package argument, so it cannot enumerate every installed package. It is tempting because it queries the dpkg database, but it would be correct when verifying which files a specific package placed on disk.
- ✓
dpkg --get-selections
Why this is correct
`dpkg --get-selections` reads the local dpkg status database directly, printing every package with its selection state (install, hold, deinstall). This satisfies the stem's requirement to list all installed packages by querying dpkg, unlike `apt list --installed`, which consults APT's extended states rather than the dpkg database itself.
- ✗
apt-show-versions
Why it's wrong here
apt-show-versions reports installed and available versions, including upgrade status, rather than enumerating all installed packages from the dpkg database. It is tempting as a Debian package query tool, but it would be correct when checking whether installed packages are outdated.
Go deeper
Related to this question
About these practice questions
Courseiva writes every LPIC-1 question from scratch — 402 in total, each with an explanation and a wrong-answer breakdown. None are copied from real exams or dumps. Learn why practice questions differ from exam dumps →
JA
Written by Johnson Ajibi, MSc IT Security
Senior Network & Security Engineer · founder of Courseiva
This LPIC-1 practice question is part of Courseiva's free LPI certification practice question bank. Courseiva provides original exam-style practice questions with explanations, topic-based practice, mock exams, readiness tracking, and study analytics to help learners prepare for the LPIC-1 exam.