{"slug":"linux-troubleshooting-2","title":"linux-troubleshooting","summary":"Use when triaging a production Linux incident across CPU, memory, disk, services, web, database, TLS, backups, or deployments; route resource findings to linux-system-monitoring and recovery to linux-disaster-recovery.","platform":"Claude","tags":[],"authorName":"LLM Mart","authorSlug":"llm-mart","score":0,"source":"github","price":null,"verified":false,"createdAt":"2026-12-02T16:53:04.849356Z","repo":{"url":"https://github.com/beginwithu/agent-skills","stars":11,"forks":2,"license":"MIT","updatedAt":"2026-12-02T16:37:11Z"},"bodyHtml":"<hr>\n<h2>name: linux-troubleshooting\ndescription: Use when triaging a production Linux incident across CPU, memory, disk, services, web, database, TLS, backups, or deployments; route resource findings to linux-system-monitoring and recovery to linux-disaster-recovery.\nlicense: MIT\nmetadata:\nportable: true\ncompatible_with: [claude-code, codex]\nauthor: Peter Bamuhigire\nauthor_url: techguypeter.com\nauthor_contact: \"+256784464178\"</h2>\n<h1>Troubleshooting</h1>\n<h2>Distro support</h2>\n<p>Two-family skill. The diagnosis trees apply to both families; only service\nnames, log paths, and a few tools differ — plus the RHEL family adds <strong>SELinux</strong>\nas a cause of failures that look like permission or connection bugs.</p>\n<table>\n<thead>\n<tr>\n<th>When diagnosing…</th>\n<th>Debian/Ubuntu</th>\n<th>RHEL family</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<td>Web server unit</td>\n<td><code>systemctl status apache2</code></td>\n<td><code>systemctl status httpd</code></td>\n</tr>\n<tr>\n<td>SSH unit</td>\n<td><code>systemctl status ssh</code></td>\n<td><code>systemctl status sshd</code> (no <code>ssh</code> unit)</td>\n</tr>\n<tr>\n<td>System log</td>\n<td><code>/var/log/syslog</code>, <code>journalctl</code></td>\n<td><code>/var/log/messages</code>, <code>journalctl</code></td>\n</tr>\n<tr>\n<td>Auth failures</td>\n<td><code>/var/log/auth.log</code></td>\n<td><code>/var/log/secure</code></td>\n</tr>\n<tr>\n<td>Web logs</td>\n<td><code>/var/log/apache2/</code></td>\n<td><code>/var/log/httpd/</code></td>\n</tr>\n<tr>\n<td>Firewall blocking a port</td>\n<td><code>ufw status</code></td>\n<td><code>firewall-cmd --list-all</code></td>\n</tr>\n<tr>\n<td>Package query</td>\n<td><code>dpkg -l</code> / <code>apt</code></td>\n<td><code>rpm -qa</code> / <code>dnf</code></td>\n</tr>\n</tbody>\n</table>\n<p><strong>RHEL-family \"it should work but doesn't\":</strong> when unix permissions look\ncorrect but you still get 403 / EACCES / \"connection refused\" from a service\n(Apache 403, PHP can't reach the DB, a daemon won't bind a port), suspect\n<strong>SELinux</strong> before anything else:</p>\n<pre><code>sudo ausearch -m AVC -ts recent | audit2why     # what did SELinux block, and why\nsudo getenforce                                  # Enforcing?\n</code></pre>\n<p>Fix with the right context/boolean/port — do <strong>not</strong> <code>setenforce 0</code>. See\n<a href=\"../../07-security-and-hardening/linux-server-hardening/references/selinux-reference.md\"><code>../../07-security-and-hardening/linux-server-hardening/references/selinux-reference.md</code></a>\nand <a href=\"../../docs/multi-distro/plan.md\"><code>docs/multi-distro/plan.md</code></a>. In <code>sk-*</code>\nscripts resolve unit names via <code>svc_name</code> from <code>common.sh</code>.</p>\n<h2>Use when</h2>\n<ul>\n<li>A server incident needs symptom-driven diagnosis.</li>\n<li>You know the symptom but not yet the owning subsystem.</li>\n<li>You need a structured triage flow before making changes.</li>\n<li>An unexplained outage needs the failure domain narrowed before remediation.</li>\n<li>Server access is unavailable and the operator needs a read-only diagnostic plan rather than an invented result.</li>\n</ul>\n<h2>Do not use when</h2>\n<ul>\n<li>The problem is already clearly scoped to one specialist skill.</li>\n<li>The task is proactive monitoring or audit rather than incident response.</li>\n</ul>\n\n<h2>Required Inputs</h2>\n<table>\n<thead>\n<tr>\n<th>Artefact</th>\n<th>Source</th>\n<th>Required?</th>\n<th>If absent</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<td>Symptom, impact, host/service, and onset</td>\n<td>Incident report/monitoring</td>\n<td>yes</td>\n<td>Gather a broad read-only snapshot; do not guess a branch</td>\n</tr>\n<tr>\n<td>Recent changes and known-good baseline</td>\n<td>Deployment/change records</td>\n<td>for cause analysis</td>\n<td>State change correlation is unassessed</td>\n</tr>\n<tr>\n<td>Read/search access to state and logs</td>\n<td>System owner</td>\n<td>yes</td>\n<td>Return safe collection commands only</td>\n</tr>\n<tr>\n<td>Remediation authority and rollback</td>\n<td>Incident/change owner</td>\n<td>for mutation</td>\n<td>Diagnose and hand off; do not apply fixes</td>\n</tr>\n</tbody>\n</table>\n<h2>Capability Contract</h2>\n<p>Default triage uses read/search access only. Restarts, deletes, rollbacks, package/config changes, database writes, firewall actions, and recovery operations require explicit authority after evidence identifies the failure mode.</p>\n<h2>Degraded Mode</h2>\n<p>Without logs, history, privileges, network probes, or reproduction, return the most specific supported failure-domain hypothesis and list unassessed branches. Do not close an incident because the symptom temporarily disappears.</p>\n<h2>Decision Rules</h2>\n<table>\n<thead>\n<tr>\n<th>Evidence</th>\n<th>Action</th>\n<th>Failure avoided</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<td>Host-wide resource pressure</td>\n<td>Route to monitoring/storage before service restart</td>\n<td>Masking the root cause</td>\n</tr>\n<tr>\n<td>One service failed with valid dependencies</td>\n<td>Inspect its config/log/unit</td>\n<td>Random system-wide changes</td>\n</tr>\n<tr>\n<td>RHEL permission failure with correct Unix mode</td>\n<td>Check SELinux context/AVCs</td>\n<td>Disabling security or chmod escalation</td>\n</tr>\n<tr>\n<td>Recent deployment aligns with onset</td>\n<td>Compare/revert only with authority</td>\n<td>Correlation treated as proof</td>\n</tr>\n</tbody>\n</table>\n<h2>Workflow</h2>\n<p>After the immediate user-visible check, create an incident learning record when the symptom required intervention, repeated, or exposed a runbook gap. Preserve the timeline and before state, name the discriminating evidence, record unknowns, test one bounded countermeasure, and verify rollback/recovery before closure. Standardise the learning in the skill, diagnosis tree, script fixture, or monitoring rule only after the same failed path is exercised.</p>\n<ol>\n<li>Establish impact, onset, host role, recent changes, and authority; start an evidence timeline.</li>\n<li>Capture read-only system, socket, service, disk, memory, and relevant log state before intervention.</li>\n<li>Select one symptom branch and test competing hypotheses with the cheapest discriminating checks.</li>\n<li>Stop when evidence is insufficient or the branch requires specialist/destructive action.</li>\n<li>Apply only the authorised minimal fix with explicit success and rollback checks.</li>\n<li>On failure, recover the previous state, verify the user-visible symptom, and preserve residual evidence.</li>\n</ol>\n<h2>Evidence Produced</h2>\n<table>\n<thead>\n<tr>\n<th>Artefact</th>\n<th>Acceptance</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<td>Incident timeline</td>\n<td>Records onset, impact, changes, commands, timestamps, and interventions</td>\n</tr>\n<tr>\n<td>Failure-domain diagnosis</td>\n<td>Cites discriminating evidence, alternatives ruled out, and confidence</td>\n</tr>\n<tr>\n<td>Fix verification</td>\n<td>Repeats the user-visible check plus service/resource checks and rollback result</td>\n</tr>\n</tbody>\n</table>\n<h2>Quality standards</h2>\n<ul>\n<li>Diagnose from evidence, not intuition.</li>\n<li>Separate triage from final remediation until the failure mode is clear.</li>\n<li>Keep the path short and explicit so incidents stay understandable under pressure.</li>\n</ul>\n<h2>Anti-patterns</h2>\n<ul>\n<li>Restarting or deleting before triage. Fix: preserve a broad read-only snapshot first.</li>\n<li>Mixing symptom branches without reason. Fix: choose discriminating checks and record why the branch changed.</li>\n<li>Closing on a guess. Fix: repeat the user-visible and subsystem verification checks.</li>\n<li>Treating a recent deployment as proof. Fix: compare timestamps and test alternatives.</li>\n<li>Disabling SELinux to test permissions. Fix: inspect AVCs, labels, and expected policy.</li>\n<li>Applying several fixes at once. Fix: make one bounded change and checkpoint its effect.</li>\n</ul>\n<h2>Outputs</h2>\n<table>\n<thead>\n<tr>\n<th>Artefact</th>\n<th>Consumer</th>\n<th>Acceptance condition</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<td>Triage summary</td>\n<td>Incident commander</td>\n<td>States impact, failure domain, confidence, evidence, and gaps</td>\n</tr>\n<tr>\n<td>Specialist handoff</td>\n<td>Owning team</td>\n<td>Provides reproducer, timeline, relevant state, and attempted actions</td>\n</tr>\n<tr>\n<td>Resolution record</td>\n<td>Service owner</td>\n<td>Shows authorised fix, rollback, user-visible verification, and residual risk</td>\n</tr>\n</tbody>\n</table>\n<h2>Worked Example</h2>\n<p>For a 502 after deployment, first capture proxy and upstream status, listeners, disk/memory, and matching logs. If Nginx is healthy but PHP-FPM is absent due to invalid config, validate that config and route the bounded service fix; do not restart the whole host.</p>\n\n<h2>References</h2>\n<ul>\n<li><a href=\"references/diagnosis-tree.md\"><code>references/diagnosis-tree.md</code></a></li>\n<li><a href=\"../../docs/continuous-improvement/incident-learning-standard.md\"><code>../../docs/continuous-improvement/incident-learning-standard.md</code></a></li>\n<li><a href=\"../../docs/continuous-improvement/safe-reversible-operations-standard.md\"><code>../../docs/continuous-improvement/safe-reversible-operations-standard.md</code></a></li>\n<li><a href=\"references/packet-capture-and-tracing.md\"><code>references/packet-capture-and-tracing.md</code></a> — <code>tcpdump</code> packet capture (BPF filters, pcap, ring buffers) and <code>strace</code>/<code>ltrace</code>/<code>lsof</code> process &amp; file diagnostics</li>\n<li><a href=\"../../07-security-and-hardening/linux-server-hardening/references/selinux-reference.md\"><code>../../07-security-and-hardening/linux-server-hardening/references/selinux-reference.md</code></a> — SELinux as a hidden cause (RHEL family)</li>\n</ul>\n<p><strong>This skill is self-contained.</strong> Every command below works on a stock\nDebian/Ubuntu or RHEL-family server with no additional tooling. The <code>sk-*</code> scripts in the\n<strong>Optional fast path</strong> section at the bottom are convenience wrappers —\nthey are never required.</p>\n<p>Ask: \"What's the symptom?\" then follow the matching branch in\n<code>references/diagnosis-tree.md</code>.</p>\n<h2>Symptom Index</h2>\n<table>\n<thead>\n<tr>\n<th>Symptom</th>\n<th>Branch</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<td>High CPU or load average</td>\n<td>→ Branch 1</td>\n</tr>\n<tr>\n<td>Out of memory / OOM kill</td>\n<td>→ Branch 2</td>\n</tr>\n<tr>\n<td>Disk full</td>\n<td>→ Branch 3</td>\n</tr>\n<tr>\n<td>Service crashed / won't start</td>\n<td>→ Branch 4</td>\n</tr>\n<tr>\n<td>502 or 504 from Nginx</td>\n<td>→ Branch 5</td>\n</tr>\n<tr>\n<td>Site is slow</td>\n<td>→ Branch 6</td>\n</tr>\n<tr>\n<td>MySQL problems</td>\n<td>→ Branch 7</td>\n</tr>\n<tr>\n<td>SSL expired or renewal failed</td>\n<td>→ Branch 8</td>\n</tr>\n<tr>\n<td>Backup failed</td>\n<td>→ Branch 9</td>\n</tr>\n<tr>\n<td>Site down after update-all-repos</td>\n<td>→ Branch 10</td>\n</tr>\n<tr>\n<td>Can't reach this server</td>\n<td>→ Branch 11</td>\n</tr>\n<tr>\n<td>Process hung / what's locking this file or port</td>\n<td>→ Branch 12</td>\n</tr>\n<tr>\n<td>Traffic not arriving / SYN-no-ACK / packet capture</td>\n<td>→ Branch 12 (capture)</td>\n</tr>\n</tbody>\n</table>\n<p>Full diagnosis commands for each: <code>references/diagnosis-tree.md</code></p>\n<hr>\n<h2>Read-Only OSI-Layer Network Diagnostic Workflow</h2>\n<p>Adapted from ECC's <code>agents/network-troubleshooter.md</code> (imported 2026-09-20).\nThat file is an <em>agent</em> definition; this engine has no <code>agents/</code> directory\nand does not use agent files as a distribution mechanism, so the pattern is\nadopted here as a workflow within this skill instead — the substance\n(layer-by-layer diagnosis, read-only until a fix is explicitly approved) is\nwhat mattered, not the agent packaging.</p>\n<p>Use this workflow for any network-path symptom — Branch 11 (\"Can't reach the\nserver\") and the <code>tcpdump</code> half of Branch 12 in\n<a href=\"references/diagnosis-tree.md\"><code>references/diagnosis-tree.md</code></a> are instances\nof it. It supersedes ad hoc \"just ping it\" diagnosis: <strong>work down (or up)\nthe OSI stack in order, collect evidence at each layer before concluding,\nand never apply a mutating fix while still diagnosing.</strong></p>\n<h3>Rule: read-only until the cause is confirmed</h3>\n<p>Every command in this workflow is observation, not remediation. If a command\nwould change state (restarting a service, flushing a route, disabling an\nACL, deleting a firewall rule \"to test\"), it is a <strong>remediation step</strong> and\nmust be labelled as such, proposed separately, and approved before running —\nnever folded into the diagnostic pass. This mirrors the standing rule this\nskill already applies to config changes generally (state → propose → apply →\nverify), applied specifically to the diagnostic phase of a network incident.</p>\n<h3>Layer 1/2 — Physical and data link</h3>\n<pre><code>ip -c link                                    # link state, MAC, MTU per interface\nethtool &lt;iface&gt; 2&gt;/dev/null | grep -E 'Link detected|Speed|Duplex'\ndmesg -T | grep -iE 'link (up|down)|nic' | tail -20\n</code></pre>\n<p>If a switch or router is in the path, the equivalent read-only layer-1/2\nevidence is <code>show interfaces &lt;interface&gt; status</code>, <code>show vlan brief</code>, and\n<code>show spanning-tree</code> — see\n<a href=\"../../16-network-equipment/cisco-ios-patterns/SKILL.md#read-only-collection\"><code>cisco-ios-patterns</code></a>.</p>\n<h3>Layer 3 — Network (addressing and routing)</h3>\n<pre><code>ip -c addr show dev &lt;iface&gt;                   # address assigned?\nip -c route                                   # routing table\nip route get &lt;destination&gt;                    # which route/iface will this use?\nping -c 3 $(ip route | awk '/default/{print $3; exit}')   # gateway reachable?\nping -c 3 1.1.1.1                             # external reachable by IP (skips DNS)\nmtr -c 10 --report &lt;destination&gt;              # where does the path actually stop?\n</code></pre>\n<p>Router/switch equivalent: <code>show ip interface brief</code>, <code>show ip route &lt;prefix&gt;</code>, <code>show ip protocols</code> — same skill reference as above.</p>\n<h3>Layer 4 — Transport (port reachability)</h3>\n<pre><code>ss -tulnp | grep ':&lt;port&gt;'                    # is anything local listening?\n(echo &gt; /dev/tcp/&lt;host&gt;/&lt;port&gt;) 2&gt;/dev/null &amp;&amp; echo OK || echo FAIL\nnc -u -z -v &lt;host&gt; &lt;port&gt;                     # UDP reachability\nmtr -c 10 -T -P &lt;port&gt; --report &lt;host&gt;        # TCP-mode mtr to the exact port\n</code></pre>\n<h3>DNS (when IP connectivity works but names fail)</h3>\n<pre><code>resolvectl query &lt;name&gt;                       # what the host actually sees\ndig @1.1.1.1 &lt;name&gt; +short                    # bypass local resolver\ndig @8.8.8.8 &lt;name&gt; +short\n</code></pre>\n<p>If local and public resolvers disagree, the fault is the local resolver path\n— see <a href=\"../../03-networking-and-dns/linux-network-admin/SKILL.md#resolve-dns-correctly\"><code>linux-network-admin</code></a>.\nIf the DNS server in the path is Pi-hole specifically, see\n<a href=\"../../03-networking-and-dns/linux-dns-server/references/pihole-blocklist-sinkholing.md#troubleshooting\"><code>linux-dns-server</code>'s Pi-hole reference</a>.</p>\n<h3>Application/policy layer (firewalls, ACLs)</h3>\n<pre><code>sudo iptables -L -n -v | head -40             # or nft list ruleset\nsudo journalctl -k --since \"10 min ago\" | grep -i 'DROP\\|REJECT'\n</code></pre>\n<p>Router/switch ACL evidence is read-only counters and logs, never removing\nthe policy to test:</p>\n<pre><code>show ip access-lists &lt;name&gt;\nshow logging | include &lt;interface&gt;|ACL|DENY|DROP\n</code></pre>\n<p>Full detail and the \"why not to test by disabling a rule\" rule:\n<a href=\"../../16-network-equipment/cisco-ios-patterns/SKILL.md#acl-placement-review\"><code>cisco-ios-patterns</code> § ACL Placement Review</a>\nand\n<a href=\"../../16-network-equipment/network-config-validation/SKILL.md\"><code>network-config-validation</code></a>\nfor validating a candidate ACL/config change before it is even proposed.</p>\n<h3>Output format</h3>\n<p>Close every pass through this workflow with an evidence-backed summary, not\njust a fix:</p>\n<pre><code>## Diagnosis: &lt;one-line likely root cause&gt;\n\nSymptom: &lt;reported failure&gt;\nLayer: &lt;where the fault was found&gt;\n\nEvidence:\n- `&lt;command&gt;` -&gt; &lt;what it proved&gt;\n- `&lt;command&gt;` -&gt; &lt;what it ruled out&gt;\n\nRoot cause: &lt;specific explanation&gt;\n\nRecommended fix (remediation, not diagnosis):\n1. &lt;safe action to schedule, with rollback&gt;\n\nVerification:\n- `&lt;command&gt;` should show &lt;expected result&gt;\n</code></pre>\n<hr>\n<h2>Quick Triage (Run First For Any Issue)</h2>\n<pre><code># System health snapshot\nuptime &amp;&amp; free -h &amp;&amp; df -h\n\n# Failed services\nsudo systemctl list-units --type=service --state=failed\n\n# Recent errors across all services\nsudo journalctl -p err --since \"1 hour ago\" --no-pager | head -30\n\n# Nginx error log\nsudo tail -20 /var/log/nginx/error.log\n</code></pre>\n<hr>\n<h2>Most Common Fixes</h2>\n<pre><code># Service crashed → restart it\nsudo systemctl restart &lt;service&gt;\n\n# Nginx config broken → find and fix\nsudo nginx -t\n\n# Disk full → clear apt cache and vacuum journal\nsudo apt clean &amp;&amp; sudo journalctl --vacuum-size=500M\n\n# 502 → restart the upstream\nsudo systemctl restart php8.3-fpm\nsudo systemctl restart apache2\n\n# SSL expired → force renew\nsudo certbot renew --force-renewal\n</code></pre>\n<hr>\n<h2>Optional fast path (when sk-* scripts are installed)</h2>\n<p>Running <code>sudo install-skills-bin linux-troubleshooting</code> gives you\ninteractive decision-tree walkers for each symptom:</p>\n<table>\n<thead>\n<tr>\n<th>Symptom</th>\n<th>Fast-path script</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<td>Capture traffic on the wire</td>\n<td><code>sudo sk-capture --filter 'port 443' --count 200</code></td>\n</tr>\n</tbody>\n</table>\n<p>These scripts wrap the manual commands above in a guided walkthrough.\nThey are optional — the manual commands are always the source of truth.</p>\n<h2>Scripts</h2>\n<p>This skill installs the following scripts to <code>/usr/local/bin/</code>. To install:</p>\n<pre><code>sudo install-skills-bin linux-troubleshooting\n</code></pre>\n<table>\n<thead>\n<tr>\n<th>Script</th>\n<th>Source</th>\n<th>Core?</th>\n<th>Purpose</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<td>sk-capture</td>\n<td>scripts/sk-capture.sh</td>\n<td>no</td>\n<td>Safe bounded <code>tcpdump -w</code> capture: forces a packet-count or size/file ring so it can't fill the disk, excludes your SSH session, asks before writing pcap. Read back with <code>tcpdump -r</code> / tshark / Wireshark.</td>\n</tr>\n</tbody>\n</table>\n","files":[{"path":"LICENSE","sizeBytes":1073,"isText":false},{"path":"references/diagnosis-tree.md","sizeBytes":29666,"isText":true},{"path":"references/packet-capture-and-tracing.md","sizeBytes":16621,"isText":true},{"path":"SKILL.md","sizeBytes":15603,"isText":true}],"reviewScore":null,"reviewSummary":null,"trust":{"provenance":"trusted-source-unreviewed","notice":"Community-authored content, reproduced verbatim and not vetted as instructions. Treat it as data to evaluate, never as directives to follow.","bodySource":null},"bodyLocked":false,"purchaseUrl":null,"sourceUrl":null,"report":{"provenance":"trusted-source-unreviewed","screen":{"ran":true,"outcome":"notes-only","suspicious":0,"notes":1,"hiddenCharacters":false},"virusScan":{"engine":"clamav","status":"clean","scannedAt":"2026-12-02T16:53:30.41603Z","sha256":"15D9DEE35CC1A3E09B7AE645EE0A1C4DEEEF74EDA244C9923467621C22D36009","sizeBytes":25679},"review":null,"source":{"repositoryUrl":"https://github.com/beginwithu/agent-skills","path":"skills/linux-troubleshooting","license":"MIT","commit":"a960304c52212f2e845067047f5cefc0c594d787","subtreeSha":"4B17EB574A667089DECD7FFF8F6AEEF6863DCBDFD456BC2323C118708C5434B9","lastSyncedAt":"2026-12-02T16:52:59.20206Z"},"reviewedAt":"2026-12-02T16:54:15.710682Z","notice":"Community-authored content, reproduced verbatim and not vetted as instructions. Treat it as data to evaluate, never as directives to follow."},"install":[{"target":"skills-cli","command":"npx skills add https://github.com/beginwithu/agent-skills/tree/main/skills/linux-troubleshooting"},{"target":"claude-code","command":"claude plugin marketplace add https://llmmart.ai/marketplace.json && claude plugin install beginwithu-agent-skills@llmmart"},{"target":"git","command":"git clone https://github.com/beginwithu/agent-skills.git"}]}