apt / dpkg Broken Dependency Recovery Prompt
Recover Debian/Ubuntu hosts stuck in half-configured packages, held broken dependencies, interrupted dpkg, or a wedged apt state — without nuking the system.
- Target user
- Debian/Ubuntu admins untangling broken package state
- Difficulty
- Intermediate
- Tools
- Claude, ChatGPT
The prompt
You are a senior Debian/Ubuntu engineer who has rescued production hosts from "dpkg was interrupted, run dpkg --configure -a" loops and broken-held-package deadlocks without reinstalling the OS. I will provide: - The exact failing command and its full error output - `apt-get -f install` and `dpkg --configure -a` output - `dpkg -l | grep -E '^.[^ic]'` (half-installed/half-configured packages) - `apt-mark showhold` and any pinned/held packages - Contents of /etc/apt/sources.list.d/* and whether a third-party repo or PPA is involved - Whether disk is full (`df -h`) — a frequent hidden cause Your job: 1. **Triage the wedge** — classify the failure: interrupted dpkg (needs `--configure -a`), unmet dependency, conflicting versions, broken maintainer script (postinst/prerm exit nonzero), held package blocking an upgrade, or disk-full mid-unpack. 2. **Read dpkg state codes** — explain the `ii`/`iU`/`iF`/`rc`/`pH` columns so I can spot exactly which packages are half-installed vs. half-configured vs. config-only-removed. 3. **The recovery ladder** (least to most invasive) — `dpkg --configure -a` → `apt-get -f install` → `apt-get install --reinstall <pkg>` → manually patching a failing maintainer script under /var/lib/dpkg/info/ → `dpkg --remove --force-remove-reinstreq` as a last resort. Explain the blast radius of each step. 4. **Maintainer-script failures** — how to read the failing `postinst`, run it with `sh -x`, and fix the actual cause (missing user, failed service start, full disk) rather than force-removing. 5. **Repo & pinning issues** — detect a third-party repo causing version conflicts, decode `apt-cache policy <pkg>`, and resolve holds/pins safely. 6. **Verify integrity** — `debsums` (if available), `apt-get check`, and confirm critical services restarted. Output as: (a) a precise diagnosis of which packages are in which state, (b) an ordered, copy-pasteable recovery command list with a one-line risk note per command, (c) the root cause, (d) a prevention note (snapshots before upgrades, `unattended-upgrades` hygiene, disk-space preflight). Anti-patterns to reject: leading with `--force-*` flags, deleting /var/lib/dpkg/* files blindly, `rm`-ing lock files while apt is actually running, and reinstalling the OS for a fixable half-configured package.
Run this prompt with AI
Test it, get an AI-improved version, or compare models — live in the Prompt Workspace. No copy-paste.
Related prompts
-
Orphan Package Cleanup Audit Prompt
Audit a server for orphaned, unused, and held-back packages across apt or dnf, then produce a safe removal plan that reclaims space and reduces attack surface without breaking dependencies.
-
Arch pacman & AUR Recovery and Hygiene Prompt
Untangle a broken Arch Linux package state — partial upgrades, conflicting files, keyring failures, .pacnew config drift, and risky AUR builds — without resorting to a reinstall.
-
Linux Patch & Package Update Automation Prompt
Design safe automated patching for apt or dnf fleets — security-only auto-updates, staged rollouts, reboot coordination, and held packages — with rollback and reporting.
-
Linux bcache SSD Caching Setup Prompt
Design a bcache SSD-in-front-of-HDD caching tier with the right cache mode, write policy, and sequential-bypass tuning, and plan the attach/detach and failure behavior so a cache device loss never means data loss.
More Linux Admins prompts & error guides
Browse every Linux Admins prompt and troubleshooting guide in one place.
Reading prompts? Get all 500 in one free PDF
500 battle-tested, copy-paste AI prompts engineered by a senior systems engineer — every one with fill-in placeholders and safety/back-out notes. Drop your email and it's yours.
- 500 prompts: Linux · Kubernetes · Terraform · OpenStack · GitLab · Docker · Monitoring · Incident Response
- Instant PDF download — yours free, forever
- Plus one practical AI-workflow email a week (no spam)
Single opt-in · unsubscribe anytime · no spam.