Linux · 2026-11-25 · 9 min

Linux errno: EACCES, ENOENT, EMFILE and ENOSPC

EACCES, ENOENT, EMFILE and ENOSPC fail at different layers. Learn how to tell them from EPERM, ENFILE and EDQUOT, and which command proves the cause.

By Open Error Codes EditorialReviewed 2026-11-25

Linux reports failure as an errno value: a small integer that the C library maps to a name such as EACCES or ENOENT. The name is the part worth remembering, because the number depends on the architecture. This guide separates the four errors that dominate file and filesystem troubleshooting — EACCES, ENOENT, EMFILE and ENOSPC — from their near neighbours EPERM, ENFILE and EDQUOT, and shows the command that settles each question.

Names are stable, numbers are not

A system call that fails returns -1 and sets errno for the calling thread. Programs usually print strerror(errno) next to the symbolic name. The symbolic name is portable; the integer is not. On x86-64 the common values are EACCES 13, ENOENT 2, EMFILE 24 and ENOSPC 28, but other architectures number the same errors differently. Match on the name in logs and scripts, and treat a bare number as a hint that still needs decoding. Confirm it locally with errno -l | grep EACCES or python3 -c 'import errno; print(errno.EACCES)'.

Namex86-64 numberMeaning in one line
EPERM1The operation itself is not permitted for this process.
ENOENT2A path component or the target does not exist.
EIO5The device or file system could not complete the I/O.
ENOMEM12An allocation could not be satisfied.
EACCES13Permission was denied on the object or a path prefix.
EBUSY16The device or mount point is still in use.
EEXIST17The path already exists.
EINVAL22An argument or flag is not valid here.
ENFILE23The system-wide open-file limit is reached.
EMFILE24The per-process descriptor limit is reached.
ENOSPC28No space or no inode is left on the device.
ETIMEDOUT110A blocking operation or connection timed out.
EDQUOT122A user or group quota is exhausted.

EACCES and EPERM are not the same denial

EACCES (13) comes from a permission check on an object. The process may lack read, write or execute on the file, lack the execute bit on a parent directory, or be denied by an ACL or a Linux Security Module. Root bypasses the classic bits, but a containerised root without CAP_DAC_OVERRIDE does not.

EPERM (1) is about the operation, not the object. The kernel refused a request that requires a capability the process does not hold: changing ownership to another user, setting an immutable flag, mounting a file system, or loading a module. A file can be world-writable and the operation can still return EPERM.

The practical split is the first command you run. For EACCES, walk the path and inspect every component. For EPERM, inspect the process capabilities and the object attributes with capsh --print and lsattr.

ENOENT is about a missing component, not a missing file

ENOENT (2) says the kernel could not resolve the path it was given. The final file may exist while an intermediate directory does not, a symlink may dangle, or the process may resolve a relative path from an unexpected working directory. Namespaces add another layer: the path exists on the host but not inside the container mount namespace.

Executables produce ENOENT for a reason that surprises people. A script whose shebang interpreter is missing returns ENOENT even though the script is present, because the failure comes from resolving the interpreter.

Do not confuse ENOENT with ENOTDIR. ENOTDIR means a path component exists but is a regular file, so the remaining component cannot be a child of it. namei -l makes both visible in one pass.

EMFILE and ENFILE are different ceilings

EMFILE (24) is a per-process limit: the process has opened as many descriptors as its RLIMIT_NOFILE allows. ulimit -n shows the shell limit, and /proc/PID/limits shows the limit that actually applies to the running process. Servers that leak sockets or files hit EMFILE after hours or days, which looks random until the descriptor count is plotted over time.

ENFILE (23) is the system-wide ceiling. Every open file on the host counts against /proc/sys/fs/file-max, and /proc/sys/fs/file-nr reports the current usage. ENFILE is rare on a modern host and usually means many processes are leaking together, or a shared host has noisy neighbours.

Raising a limit is not a fix on its own. Count the descriptors, decide whether the number is legitimate, and only then raise LimitNOFILE for a systemd unit or the shell limit.

ENOSPC and EDQUOT: blocks, inodes and quotas

ENOSPC (28) means the file system could not allocate what the write needed: a data block, an inode, or journal space. The classic mistake is checking only df -h. A file system can have free blocks and no free inodes, which breaks writes that create files while appends keep working. df -i shows inode use, and a directory of small session files is the usual culprit.

Two cases look like a lie in df. The ext family reserves blocks for root, so a volume can show free space while an unprivileged process still gets ENOSPC. And a deleted file that a process still holds open keeps its blocks allocated until the descriptor closes; lsof +L1 lists those files, and restarting the holder is often the fastest way to reclaim the space.

EDQUOT (122) means a quota was exceeded, not that the device is out of space. User and group quotas count blocks and inodes separately, so an account can be blocked from creating files while the volume is half empty. quota -s, repquota -s and the project quota tools show which limit was hit. Some file systems and network mounts report quota exhaustion as ENOSPC instead, so check quotas whenever space looks available.

Trace the failing path before changing permissions

Start from the exact system call. The dynamic loader and the application try several candidate paths before the one that fails, so a trace full of ENOENT lines is normal; the interesting line is the last failing call for the path you care about. Run the failing command under strace with file-related calls only, then read the final error and the path it was given.

# Every component of the path, with the permissions that apply
namei -l /srv/app/data/upload.bin

# Mode, owner, group and inode of the final object
stat -c '%A %a %U:%G %i %n' /srv/app/data/upload.bin

# Follow the process and log path-related system calls
strace -f -e trace=file -o /tmp/trace.txt /usr/local/bin/app

# Descriptor ceiling, current usage and the open handles themselves
ulimit -n
ls /proc/PID/fd | wc -l
lsof -p PID | head -n 20

# Space and inodes, then deleted files that still hold blocks
df -h /srv
df -i /srv
lsof +L1

# Kernel and policy denials around the failure
journalctl -b -p err --no-pager
journalctl -k | grep -i -e avc -e apparmor

Replace PID with the process you are investigating. The two answer different questions: strace names the syscall and its arguments, namei -l names the component and the permission bit. Collect both before editing a mode.

Permission bits, parent directories and security modules

For a file, r allows reading, w writing and x execution. For a directory the bits mean something else: r lists names, w creates and removes entries, and x allows traversing the directory to reach an entry. A file with mode 0644 is still unreachable when a parent directory lacks the execute bit, which is why namei -l prints every component.

An ACL can grant or deny access to a specific user, and SELinux or AppArmor can deny a path that looks correct. An SELinux denial appears as an AVC message in the audit log; AppArmor logs a DENIED line in the kernel log. journalctl -k or ausearch -m AVC -ts recent confirms the policy layer. Fix the label or the profile for the specific path, and never disable the module on a production host to get past a denial.

The four errors side by side

errnoNumberLayer that failedFirst checkUsual fix
EACCES13Permission check on a file or path prefixnamei -l, ACL, LSM logCorrect the owner, mode or label for that path
EPERM1Capability or immutable attributecapsh --print, lsattrGrant the narrow capability or remove the flag
ENOENT2Path resolutionnamei -l, working directory, mount namespaceCreate the component, fix the path or mount it
EMFILE24Per-process descriptor limitulimit -n, /proc/PID/limitsFix the leak, then raise LimitNOFILE
ENFILE23System-wide open-file limit/proc/sys/fs/file-nrFind the leaking processes before raising file-max
ENOSPC28Blocks, inodes or reserved spacedf -h, df -i, lsof +L1Free space or inodes, or grow the volume
EDQUOT122User, group or project quotaquota -s, repquota -sRaise the quota or reduce usage

A decision path

  1. Does the error name a permission? Run namei -l on the full path and read every component, not only the last one.
  2. Is the operation privileged rather than object-specific? Check capabilities and file attributes before touching modes.
  3. Does the path look correct but resolve nowhere? Confirm the working directory, symlinks and the mount namespace inside the container.
  4. Is the process long-running and the failure sudden? Count descriptors and look for a leak before raising any limit.
  5. Does df show free space? Check inodes, reserved blocks, deleted-open files and quotas, in that order.
  6. Does the policy log show a denial? Fix the SELinux label or AppArmor profile for the path instead of disabling enforcement.

Related errno pages

These errors rarely arrive alone. The same commands help with EIO (a device or file system could not complete the I/O), ENOMEM (an allocation or cgroup limit), EBUSY (a mount point still in use), EEXIST (a path that already exists), EINVAL (an unsupported flag or argument) and ETIMEDOUT (a blocking call or connection that gave up). For the dedicated pages, start with EACCES, EPERM, ENOENT, EMFILE and ENOSPC, or browse the Linux product hub.

Sources

Search the code you are seeing

Every page links the official source and the date it was last checked.

Search codes