Linux ENOENT (errno 2) — No Such File or Directory (Deep Dive)
Warningerrno
Overview
Deep dive into Linux ENOENT covering symlink resolution failures, race conditions, missing shared libraries, and debugging missing path components.
Key Details
- ENOENT (errno 2) means a path component does not exist during pathname resolution
- Can occur at any component in the path, not just the final file name
- Broken symbolic links return ENOENT when the target does not exist
- Dynamic linker (ld.so) returns ENOENT for missing shared libraries
- Race conditions: file deleted between existence check and open call (TOCTOU)
Common Causes
- File or directory genuinely does not exist at the specified path
- Broken symbolic link pointing to a non-existent target
- Intermediate directory in the path does not exist
- Missing shared library (*.so) needed by the application
- Case-sensitive file system and wrong case in the path
Steps
- 1Verify each path component exists: ls -la each directory in the path
- 2Check for broken symlinks: find /path -xtype l (finds broken symlinks)
- 3For library errors: run ldd /path/to/binary to find missing shared libraries
- 4Use strace to find which file is missing: strace -e openat command 2>&1 | grep ENOENT
- 5For case sensitivity: use find -iname to locate files regardless of case
Tags
linuxenoenterrno-2file-not-foundsymlink
More in Errno
linux-errno-1-epermLinux errno 1 (EPERM) — Operation Not Permitted
Warninglinux-errno-2-enoentLinux errno 2 (ENOENT) — No Such File or Directory
Warninglinux-errno-5-eioLinux errno 5 (EIO) — Input/Output Error
Errorlinux-errno-11-eagainLinux errno 11 (EAGAIN) — Resource Temporarily Unavailable
Informationallinux-errno-12-enomemLinux errno 12 (ENOMEM) — Out of Memory
Criticallinux-errno-13-eaccesLinux errno 13 (EACCES) — Permission Denied
WarningFrequently Asked Questions
A parent directory in the path may not exist. Or the file is a broken symlink that appears to exist but its target does not.