Skip to content

Error codes & fixes: Linux & SSH errors

10 Error codes & fixes commands: Linux & SSH errors. Click a command to see what each part does.

Index
10 items
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

    1. 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 inodes

    What 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 df then prune; journald: journalctl --vacuum-time=7d.

    Diagnose: what each part of the command does

    1. df -h <path>free space on the filesystem holding <path>
    2. df -i <path>free inodes: a disk can be "full" with millions of tiny files
  • 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

    1. ss -tlnpTCP listening sockets with numeric ports and process
    2. | grep :<port>only that port
  • 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

    1. nc -zjust test the connection
    2. -vsay succeeded / timed out
    3. -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

    1. 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 with dig @8.8.8.8 <hostname>.
    • In Kubernetes use <service>.<namespace>.svc.cluster.local.

    Diagnose: what each part of the command does

    1. 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 limit

    What it means

    EMFILE: the process hit its maximum number of open file descriptors.

    Usual causes & fixes

    • Raise it for a service: LimitNOFILE=65536 in the systemd unit, then daemon-reload + restart.
    • A descriptor leak in the app (count them: ls /proc/<pid>/fd | wc -l).

    Diagnose: what each part of the command does

    1. ulimit -nlimit for your current shell
    2. /proc/<pid>/limitsthe limits a running process actually has
  • 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

    1. findmnt -T <path>the mount that contains <path>
    2. -o TARGET,OPTIONSshow where it is mounted and its options (ro / rw)
  • ssh-keygen -R <host>Host key verification failedServer key changed: remove the old oneCaution

    What 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

    1. 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 tries

    What 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

    1. -vverbose: shows which keys are offered and why they are refused

My DevOps Playbook by Angelo John Calleja

New runbook

GitHub not connected

Saving is handled by the site: the GitHub token is stored in Cloudflare, not in your browser. Enter the editor password (the EDITOR_PASSWORD secret) to unlock saving in this browser.

Saving commits to gelogrammer/My_DevOps_Playbook. Create a fine-grained token with access to only this repo andContents: Read and write, then paste it here. It is stored only in this browser.

src/content/docs/…