Linux Survival Basics
Find Broken or Leftover dpkg States
A host has package trouble and you need to spot half-configured packages or removed packages with leftover config.
Command
dpkg-query -W -f='${db:Status-Abbrev}\t${Package}\n' | awk '$1 !~ /^ii$/'
What changed
Nothing changes. The command filters dpkg status abbreviations to rows that are not clean ii installed packages.
Danger
safe
When to use it
Use after interrupted installs, failed upgrades, or package repair sessions.
When not to use it
Do not delete packages based only on this output; inspect each state and package purpose first.
Undo or recovery
No undo needed because the command is read-only.
Expected output
Rows such as iF app-agent or rc old-kernel-tools that need review.
demo script
Disposable terminal steps
dpkg-query -W -f='${db:Status-Abbrev}\t${Package}\n'dpkg-query -W -f='${db:Status-Abbrev}\t${Package}\n' | awk '$1 !~ /^ii$/'
simulated output
What it looks like
::fixture-ready::
$ dpkg-query -W -f='${db:Status-Abbrev}\t${Package}\n'
ii base-files
ii bash
ii curl
ii libc6
ii linux-image-6.8.0-60-generic
ii nginx
ii openssl
ii python3
ii zlib1g
iF app-agent
rc old-kernel-tools
::exit-code::0
$ dpkg-query -W -f='${db:Status-Abbrev}\t${Package}\n' | awk '$1 !~ /^ii$/'
iF app-agent
rc old-kernel-tools
::exit-code::0
YouTube Short
Find messy dpkg states.
When apt feels broken, inspect dpkg states. Anything not clean ii deserves a closer look before the next repair command.
LinkedIn hook
Not every package row is cleanly installed.
Question: Do you check dpkg status abbreviations after failed package installs?
experiments
A/B tests to run
Metric: completion_rate
A: Find half-configured packages.
B: When apt feels broken, inspect dpkg.