Display package desired state, current state, name, and version from the dpkg database.
Do not change system state.
Which command is appropriate?
dpkg -l prints package selection and status in a compact table. A leading ii is one example of an installed state.
Detailed explanation
dpkg -iIncorrect. -i installs a deb archive.
dpkg -rIncorrect. -r removes a package.
Incorrect. -r is a removal operation.
dpkg -sIncorrect. -s shows a detailed record for a specified package.
Incorrect. -s is a detailed query for a named package.
dpkg -lCorrect. dpkg -l prints the package status table.
Correct. -l prints the package status table.
Try it yourself
An example you can run in a temporary verification environment.
dpkg -l | sed -n '1,8p'Expected result
Desired、Status、Name、Version、Architecture等の見出しとパッケージ行Key points
- -l lists packages
- ii is an installed-state example
- The operation is read-only
Notes
- Environment: dpkg 1.21以降 / ローカルデータベース
- Use a disposable package or read-only help when testing package commands.
- Package behavior can vary with dpkg and debconf versions.
Foundation review
Place the operation
The list view is broad and compact; status inspection for one package uses a different query.
Check the side effect
Inspect the first lines of dpkg -l output without changing package state.