Error Codes Wiki

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

  1. 1Verify each path component exists: ls -la each directory in the path
  2. 2Check for broken symlinks: find /path -xtype l (finds broken symlinks)
  3. 3For library errors: run ldd /path/to/binary to find missing shared libraries
  4. 4Use strace to find which file is missing: strace -e openat command 2>&1 | grep ENOENT
  5. 5For case sensitivity: use find -iname to locate files regardless of case

Tags

linuxenoenterrno-2file-not-foundsymlink

More in Errno

Frequently 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.