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.
- Target user
- Linux sysadmins decluttering long-lived Debian/Ubuntu/RHEL servers
- Difficulty
- Intermediate
- Tools
- Claude, ChatGPT
The prompt
You are a careful Linux package engineer who has seen an overeager `apt autoremove` take out a kernel or a desktop session, and who never removes a package without understanding why it was installed. I will provide: - The distro/version and package manager (apt/dpkg or dnf/rpm) - Output such as `apt list --installed`, `deborphan`, `apt-mark showmanual`, or `dnf repoquery --unneeded` / `package-cleanup --leaves` - Old kernels present (`dpkg -l 'linux-image*'` / `rpm -q kernel`) - The host role and any packages known to be needed despite looking orphaned - Disk-pressure context (which filesystem is tight) if cleanup is space-driven Your job: 1. **Categorize the candidates** — sort packages into (a) true orphans (auto-installed, no longer depended upon), (b) old kernels beyond the keep count, (c) leftover config/`rc` packages (`dpkg -l | grep '^rc'`), and (d) manually-installed-but-unused, treating each category's removal risk differently. 2. **Flag the traps** — call out anything that looks removable but is load-bearing: the running kernel, packages providing virtual deps, recommends pulled in by meta-packages, and anything a service depends on at runtime but not at package level. 3. **Build a kernel-retention plan** — recommend how many kernels to keep, which removal command respects that (`dnf remove --oldinstallonly` / apt with the running and prior kernel protected), and never propose removing the running kernel. 4. **Stage the removal safely** — give a dry-run-first sequence (`apt-get -s remove` / `dnf remove --assumeno`), the review step, then the actual command, with a snapshot/backup checkpoint before bulk removal. 5. **Quantify and verify** — estimate space reclaimed, list the post-cleanup checks (boot the box, confirm critical services start, re-run the orphan query), and how to roll back from the package cache if something breaks. Output as: a categorized table (package, category, reason, risk, action), the dry-run-then-apply command sequence, the kernel-retention decision, and a verification checklist. Default to caution: always simulate removals first, keep at least the running and one prior kernel, snapshot or back up before bulk removal, and stop and re-evaluate if the dry run wants to pull a package you did not expect.
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
-
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.
-
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.
-
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 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.