Linux server ops

From jsath/claude-skills · View interactive version

Linux server ops is an AI agent skill from the GitHub repository jsath/claude-skills. Audits and fixes Linux server resource pressure safely, with evidence. Covers full disks (ENOSPC, Errno 28), inode exhaustion, runaway logs, oversized journald, Docker images, volumes, logs and build cache, old kernels, package caches, core dumps, /tmp, memory and swap pressure, and runaway processe

How to use this skill

Skill file

Linux Server Ops

A full disk or a starved server usually has one boring cause: a log nobody rotates, a cache nobody prunes, a process that leaks. The real danger is the cleanup, like docker system prune -a --volumes on a live box deleting a database. This skill finds the cause with measurements, frees space in the safest order, and stops it coming back.

Commands target Ubuntu and Debian. Notes for RHEL-family, Alpine and Arch are in references/commands.md, which holds every copy-paste command this file refers to.

What it does

  1. Inventory the server read-only: disks, inodes, memory, swap, top processes, services, containers.
  2. Diagnose what is actually growing and why, with numbers.
  3. Fix in a fixed order, safest first, measuring each step. Anything destructive waits for a yes.
  4. Prevent recurrence: rotation, size limits, alerts.
  5. Verify services are healthy and write SERVER-REPORT.md from templates/SERVER-REPORT.md.

Safety rules

Steps

1. Inventory (read-only)

Run the inventory block in references/commands.md: df in bytes and inodes (separate problems), memory and swap, top processes, failed units, docker system df, journalctl --disk-usage, and the timestamp. Write the numbers into the report's "Before" section straight away.

2. Diagnose

Work out which of these it is. More than one is common.

| Symptom | Likely cause | How to confirm |

|---|---|---|

| df at 100% | big files or directories | du -x by level, largest files list |

| df says full, du total is much smaller | deleted files still held open | lsof +L1 |

| df has space, writes fail | inodes exhausted | df -i at 100%, count files per directory |

| /var/log huge | a log with no rotation, or a debug flag left on | measure the file twice 30 s apart for growth rate |

| /var/lib/docker huge | container JSON logs, dangling images, build cache, volumes | docker system df -v, per-container log sizes |

| /var/log/journal huge | no journald size limit | journalctl --disk-usage |

| /boot full | old kernels piling up | dpkg -l 'linux-image-*' vs uname -r |

| /var/cache/apt or ~/.cache large | package caches | du -sh each |

| /var/crash or /var/lib/systemd/coredump large | crashing process dumping core | coredumpctl list |

| high load, slow, OOM in dmesg | a process leaking memory, too little RAM, no swap | dmesg -T, journalctl -k, RSS over time |

Rules for diagnosis:

3. Fix (safest first)

Go in this order and stop once there is comfortable headroom (at least 15% or a few GB free). Record bytes freed per step.

  1. Stop the bleeding. Truncate a fast-growing file in place (truncate -s 0 FILE) once you know its producer. Deleting it frees nothing while the process holds it open.
  2. Deleted-but-open files. Restart or reload the owning service. Ask first on production.
  3. Package caches. apt-get clean; language caches only if nothing is mid-install.
  4. Journald. journalctl --vacuum-size=500M.
  5. Rotated logs, core dumps, crash reports past retention, after noting any crash in the report.
  6. Old kernels. apt-get autoremove --purge, never the one from uname -r.
  7. Docker: truncate oversized container logs, then dangling images, build cache, identified stopped containers. Ask first before docker image prune -a. Never remove volumes unless the owner names each one: that is where databases live.
  8. /tmp: only files past a stated age, not open, from a producer you recognise.
  9. Memory: restart a leaking process through systemd, cap it with MemoryMax=, or add swap if there is none. Do not disable the OOM killer.

If the disk is still full after the safe steps, more deletion is not the answer. Give the owner options with measured sizes: bigger disk, move data to another volume, or retire a workload.

4. Prevent

Add only what addresses the cause you found, and validate each config with its own checker. Snippets are in references/commands.md.

5. Verify

Output

Fill templates/SERVER-REPORT.md (off the full disk if possible): a three-line summary (what was wrong, what was done, current headroom), before and after numbers, actions with bytes freed, what was kept and why, prevention added, and decisions waiting on the owner. In the chat, give only the summary, the before and after line, and pending yes or no questions.

Honest limits

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.