Error codes & fixes: Linux & SSH errors
10 Error codes & fixes commands: Linux & SSH errors. Click a command to see what each part does.
Linux & SSH errors10
namei -l <path>Permission deniedWhich part of the path blocks me?What it means
The user lacks the permission needed: r to read, w to write, x to run a file or to enter a folder.
Usual causes & fixes
- Missing x on a parent folder blocks everything below it.
- File belongs to another user:
sudo chown <user>:<group> <path>or add the user to the group. - Script not executable:
chmod +x <file>. - SELinux/AppArmor can deny even when modes look fine:
ls -Z,sudo ausearch -m avc -ts recent.
Diagnose: what each part of the command does
namei -lowner, group and permissions of every folder on the way to <path>
df -h <path>; df -i <path>No space left on deviceOut of disk space or inodesWhat it means
ENOSPC: the filesystem has no free blocks or no free inodes left.
Usual causes & fixes
- Find big folders:
sudo du -xh --max-depth=1 <path> | sort -rh | head. - Deleted files still open:
sudo lsof -nP +L1(restart the process). - Docker:
docker system dfthen prune; journald:journalctl --vacuum-time=7d.
Diagnose: what each part of the command does
df -h <path>free space on the filesystem holding <path>df -i <path>free inodes: a disk can be "full" with millions of tiny files
- Find big folders:
sudo ss -tlnp | grep :<port>Connection refusedIs anything listening on that port?What it means
The host answered but nothing accepts connections on that port (or a firewall actively rejects).
Usual causes & fixes
- Service not running:
systemctl status <service>. - Listening only on 127.0.0.1, not 0.0.0.0 / the external IP.
- Wrong port in the client config.
Diagnose: what each part of the command does
ss -tlnpTCP listening sockets with numeric ports and process| grep :<port>only that port
- Service not running:
nc -zv -w 5 <host> <port>Connection timed outCan I reach the port at all?What it means
No answer at all: packets are dropped on the way.
Usual causes & fixes
- Firewall, security group or network ACL blocks the port.
- Wrong IP / host is down / routing problem (
traceroute <host>).
Diagnose: what each part of the command does
nc -zjust test the connection-vsay succeeded / timed out-w 5give up after 5 seconds
sudo lsof -i :<port>Address already in useWho holds the port?What it means
EADDRINUSE: another process is already bound to that port.
Usual causes & fixes
- Stop the other process or pick another port.
- Old instance still running (e.g. a previous container:
docker ps --filter publish=<port>).
Diagnose: what each part of the command does
lsof -i :<port>process that has that port open
getent hosts <hostname>Could not resolve hostDNS: does the name resolve?What it means
"Name or service not known" / "Temporary failure in name resolution": the hostname could not be turned into an IP.
Usual causes & fixes
- Typo, or a private name that only resolves inside a VPN/VPC.
- Broken resolver: check
cat /etc/resolv.conf, test withdig @8.8.8.8 <hostname>. - In Kubernetes use
<service>.<namespace>.svc.cluster.local.
Diagnose: what each part of the command does
getent hostsresolve the name the way the system does (/etc/hosts + DNS)
ulimit -n; grep "open files" /proc/<pid>/limitsToo many open filesCheck the open-files limitWhat it means
EMFILE: the process hit its maximum number of open file descriptors.
Usual causes & fixes
- Raise it for a service:
LimitNOFILE=65536in the systemd unit, thendaemon-reload+ restart. - A descriptor leak in the app (count them:
ls /proc/<pid>/fd | wc -l).
Diagnose: what each part of the command does
ulimit -nlimit for your current shell/proc/<pid>/limitsthe limits a running process actually has
- Raise it for a service:
findmnt -o TARGET,OPTIONS -T <path>Read-only file systemWhy is the disk read-only?What it means
The filesystem is mounted read-only, often remounted by the kernel after disk errors.
Usual causes & fixes
- Check kernel errors:
dmesg -T | grep -i -E "error|remount". - Containers: the image filesystem is read-only by design; write to a volume or /tmp.
Diagnose: what each part of the command does
findmnt -T <path>the mount that contains <path>-o TARGET,OPTIONSshow where it is mounted and its options (ro / rw)
- Check kernel errors:
ssh-keygen -R <host>Host key verification failedServer key changed: remove the old oneCautionWhat it means
The server's SSH host key differs from the one you saved: a rebuilt server, or a man-in-the-middle.
Usual causes & fixes
- Verify the new fingerprint out of band before reconnecting.
- Expected after recreating a VM with the same IP/name.
Diagnose: what each part of the command does
ssh-keygen -R <host>delete the saved key for <host> from ~/.ssh/known_hosts
ssh -v <user>@<host>Permission denied (publickey)SSH key rejected: see what ssh triesWhat it means
The server did not accept any of your keys.
Usual causes & fixes
- Wrong user (ubuntu vs ec2-user vs root) or wrong key:
ssh -i <key-file> <user>@<host>. - Permissions too open:
chmod 700 ~/.ssh && chmod 600 ~/.ssh/authorized_keys ~/.ssh/id_ed25519(sshd StrictModes refuses group/world-writable files). - Public key not in the server's
~/.ssh/authorized_keys:ssh-copy-id <user>@<host>.
Diagnose: what each part of the command does
-vverbose: shows which keys are offered and why they are refused
- Wrong user (ubuntu vs ec2-user vs root) or wrong key:
Nothing matches.
My DevOps Playbook by Angelo John Calleja