NinjaOps Fixes / Linux
Linux Fixes
33 troubleshooting guides — each with the error, why it happens, and copy-paste commands to fix it.
SSH: 'Permission Denied (publickey)' — The server rejected your key.
Cron Job 'Installed' but Never Runs — Cron failures are boringly consistent: PATH differences, silent script errors, or the crontab you think is installed isn't.
systemd Service Keeps Failing: Reading the Actual Error — Do not guess from status alone — journalctl for the unit has the exact stack trace or exit code.
Disk 'Full' But df Shows Free Space (Inode Exhaustion) — Storage has two limits: bytes and inode counts.
apt: 'Could Not Get Lock /var/lib/dpkg/lock-frontend' — Another apt/dpkg process is mid-run — usually unattended-upgrades doing its job.
SSH Connection Times Out (Hanging Before Auth) — A hang then 'Connection timed out' means packets are being silently dropped — firewall, wrong IP, or nothing listening.
Find Which Process Is Using a Port (Linux) — The fastest reliable answer on a modern Linux is one ss command — here's the exact invocation, plus why netstat output misleads people.
make: "No Rule to Make Target" — Missing Files and Missing Prerequisites — make can't find (or infer) a rule to build a requested target.
"bash: command not found" — PATH, Packages, and the Right Name — The shell searched every PATH directory and didn't find an executable by that name.
systemd: "Start Request Repeated Too Quickly" (and Failed Units) — The unit crashed, systemd backed off, and now start attempts hit the rate limiter — masking the original failure.
"Too many open files" — ulimit, systemd, and Container Limits — Each process has an open-file-descriptor ceiling.
The Linux OOM Killer Is Taking Out Your Services — When memory (plus swap) is exhausted, the kernel kills the highest badness-scored process.
Adding Swap on Linux Without a Reinstall (the 4-Command Version) — A 2–4GB swap file takes four commands and gives your server a memory cushion.
Logrotate Isn't Rotating — Logs Grow Forever — Silent log growth fills disks at 3am.
/var/log/journal Consuming Gigabytes: Cap journald For Real — systemd-journald grows logs until told to stop.
Server Load Is High — Find What's Actually Causing It — High load means runnable tasks are waiting.
"<User> is not in the sudoers file. This incident will be reported." — Your account lacks sudo rights (or lost them).
"Read-only file system" — The Disk or the Kernel Lost Trust — A filesystem going read-only is usually the kernel protecting data after I/O errors — or a deliberately read-only mount.
"Target is Busy" / "Device or Resource Busy" When Unmounting — Something is using the mount: a process with open files, a shell cd'd into it, or a container with a bind mount.
apt: "Unable to locate package" — Sources, Spelling, or Release — apt can't find the package in any configured repository.
systemd "Failed to start: Unit not found" — Name, Path, or [Install] — The unit you referenced doesn't exist as systemd sees it — typo, missing file, or an unreadable path.
Linux "Operation Not Permitted" — Capability or Namespace Limits — Distinct from 'Permission denied': EPERM means the operation itself is disallowed for your process — lacking a capability, restricted by seccomp/AppArmor, or namespaced away in containers.
Bash "Syntax Error Near Unexpected Token" — and the Windows Line-Ending Trap — Bash rejects the script at parse time.
"passwd: Authentication Token Manipulation Error" — PAM couldn't complete the password change: shadow file locked, read-only filesystem, or a module in the chain failing.
"Cannot Allocate Memory" at fork — With Free RAM: pids.max and overcommit — fork() fails EAGAIN when the process hits a limit that isn't RAM: the pids cgroup ceiling (common in containers) or overcommit accounting.
"sudo: No TTY Present and No Askpass Program Specified" — sudo needs a password but has no terminal to ask on — cron, CI, and scripts.
"Segmentation Fault (Core Dumped)" — A Practical Diagnosis Order — Segfaults mean a process touched memory it shouldn't.
"Error While Loading Shared Libraries: Cannot Open Shared Object File" — The binary wants a library the loader can't find: missing package, wrong arch, or a non-standard install dir that needs ldconfig.
"Exec Format Error" — Wrong Architecture or Corrupt Binary — The kernel can't execute the file: it's the wrong arch (ARM vs x86), a glibc/musl mismatch variant, or the file isn't actually a binary.
"No Route to Host" — Networking's Different Beast from Connection Refused — The host is reachable at the IP layer but nothing accepts or passes your connection: a REJECT firewall rule (as opposed to DROP's timeout), a bad route, or a down host in a routed setup.
bash: /bin/bash^M: Bad Interpreter — Windows Line Endings — A script saved with Windows CRLF line endings embeds a literal carriage return in the shebang: the kernel looks for /bin/bash^M, which doesn't exist.
bash: fork: retry: Resource Temporarily Unavailable — The kernel refused to create a new process: nproc limit (RLIMIT_NPROC) or the system's pid_max is exhausted.
systemd: Failed to Start — Unit File Changed on Disk / Not Found — Two variants with one remedy family: a unit genuinely missing, or the manager holding stale state after you edited/installed a unit.