Diagnosing and Fixing Package State Issues with dpkg on Domestic Linux Systems

Understanding Package Status Codes

The dpkg -l command provides a comprehensive overview of package states in Debian-based distributions. Each package entry displays three critical indicators: desired action, current status, and error flags.

user@workstation:~$ dpkg -l
desired action: unknown(u)/install(i)/remove(r)/purge(p)/hold(h)
current status: not-installed(n)/installed(i)/config-files(c)/unpacked(U)/failed-config(F)/half-installed(H)/triggers-awaited(W)/triggers-pending(t)
 error flags: none/(R)einstall-required
||/ Name                    Version                  Architecture Description
+++-=======================-========================-============-========================
ii  network-manager         1.22.10-1                amd64        network management framework
ii  vim-editor              2:8.1.2269-1             amd64        Vi IMproved - enhanced text editor
ii  apache-server           2.4.41-4ubuntu3.1        amd64        Apache HTTP Server
ii  containerd              1.5.9-0ubuntu3~20.04.4   amd64        daemon to control runC

Status Code Reference

Desired Action Flags:

  • u: Unknown state
  • i: Marked for installation
  • r: Marked for removal
  • p: Marked for purge
  • h: Placed on hold

Current Status Flags:

  • n: Not installed
  • i: Fully installed
  • c: Configuration files only remain
  • U: Unpacked but not configured
  • F: Configuration failed
  • H: Partially installed
  • W: Awaiting trigger processing
  • t: Trigger processing pending

Error Condition Flags:

  • (empty): No errors
  • R: Reinstallation required

State-Specific Resolution Procedures

ii - Normal Installation State

Indicates successful installation with no issues. No action required.

ii  bash-shell           5.0-6       amd64        GNU Bourne Again SHell

in - Unpacked but Unconfigured

The package files are extracted but configuration was not completed.

in  system-monitor       2.2.0-1     amd64        real-time system monitoring tool

Resolution:

Configure all pending packages:

sudo dpkg --configure --pending

Configure a specific package:

sudo dpkg --configure system-monitor

If configuration fails due to missing dependencies:

sudo apt-get update
sudo apt-get install -f
sudo dpkg --configure system-monitor

ic - Package Removed, Configurations Persist

The software was removed but configuration files remain in /etc.

ic  text-editor          4.8-1       amd64        lightweight text editing tool

Resolution:

Purge remaining configurations:

sudo dpkg --purge text-editor

Alternative approach using aptitude:

sudo aptitude purge ~c

For manual cleanup when necessary:

sudo find /etc -name "*text-editor*" -type f -delete

rn - Marked for Removal, Operation Pending

The package is queued for removal but the operation was not completed.

rn  graphics-driver      470.86-1    amd64        NVIDIA graphics driver

Resolution:

Execute removal:

sudo apt-get remove graphics-driver

Complete removal with configurations:

sudo apt-get purge graphics-driver

Force removal if standard methods fail:

sudo dpkg --remove --force-all graphics-driver

Clean residual dependencies:

sudo apt-get autoremove --purge

pc - Successfully Purged

Both package and configurations are completely removed. No further action needed.

pc  old-database         3.36.2-0    amd64        deprecated database client

hi - Installed and Held Back

Package is installed but blocked from automatic updates.

hi  secure-browser       80.0+build1 amd64        security-hardened web browser

Resolution:

Review held packages:

apt-mark showhold

Release hold to allow upgrades:

sudo apt-mark unhold secure-browser
sudo apt-get update
sudo apt-get upgrade secure-browser

Place a package on hold:

sudo apt-mark hold secure-browser

hr - Held and Marked for Removal

Package is on hold but simultaneously queued for removal, creating a conflict.

hr  legacy-compiler      9.3.0-1     amd64        outdated compiler toolchain

Resolution:

Remove hold status first:

sudo apt-mark unhold legacy-compiler
sudo apt-get purge legacy-compiler

hn - Held and Not Installed

Package is on hold in an uninstalled state, preventing installation attempts.

hn  office-suite         1:7.0.1-0   amd64        productivity applications bundle

Resolution:

Remove hold to enable installation:

sudo apt-mark unhold office-suite
sudo apt-get install office-suite

Or clear the hold and keep uninstalled:

sudo apt-mark unhold office-suite
sudo apt-get purge office-suite

pF - Purge Failed During Configuration

Attempted purge operation failed during the configuration phase.

pF  broken-service         1.2.3-1     amd64        malfunctioning daemon package

Resolution:

Force removal with dpkg:

sudo dpkg --remove --force-remove-reinstreq broken-service
sudo dpkg --purge broken-service

Repair dependency tree:

sudo apt-get install -f
sudo apt-get autoremove
sudo apt-get clean

pn - Successfully Purged and Not Installed

Package was completely removed and is not present on the system. No action required.

pn  experimental-tool      1.2.3-1     amd64        beta development utility

rc - Removed with Configuration Files Intact

Package binaries removed but /etc configurations preserved.

rc  web-server             2.4.41-4    amd64        Apache HTTP server

Resolution:

Complete purge operation:

sudo apt-get purge web-server

Verify and manually clean if needed:

sudo find /etc -path "*/web-server/*" -type f
sudo rm -rf /etc/web-server/

Querying Packages by State

Filter packages using pattern matching:

# List fully installed packages
dpkg -l | awk '/^ii/ {print $2}'

# Find packages with residual configurations
dpkg -l | awk '/^rc/ {print $2}'

# Identify unconfigured packages
dpkg -l | awk '/^in/ {print $2}'

# Show held packages
dpkg -l | awk '/^h/ {print $2}'

# Detect failed purge operations
dpkg -l | awk '/^pF/ {print $2}'

For a more structured output:

dpkg-query -W -f='${db:Status-Abbrev}\t${Package}\n' | grep '^rc'

Tags: dpkg package-management Linux troubleshooting debian

Posted on Wed, 13 May 2026 19:51:13 +0000 by Entire