Linux errno 2 (ENOENT) — No Such File or Directory
About Linux errno 2 (ENOENT)
Linux errno 2 (ENOENT) means the specified file or directory does not exist at the given path. This guide covers everything you need to know about this topic, including common causes, step-by-step solutions, and answers to frequently asked questions.
Here are the key things to understand: ENOENT — most common Linux error. Path component does not exist. Can occur with files, directories, sockets, or devices. Shell may show "No such file or directory" message. Understanding these fundamentals will help you diagnose and resolve this issue more effectively.
The most common reasons this occurs include: File path is misspelled or incorrect. File was deleted or moved. Symbolic link points to non-existent target. Missing directory in the path hierarchy. Identifying the root cause is the first step toward finding the right solution.
To resolve this, follow these recommended steps: Verify the path exists: ls -la /path/to/file. Check for typos in the filename or path. Check symlinks: ls -la to see if link target exists. Use find or locate to search for the file. If these steps do not resolve the issue, consider consulting additional resources or a qualified professional.
This article is part of our Linux Error Codes collection on Error Codes Wiki. We provide comprehensive, up-to-date information to help you find solutions quickly.
Quick Answer
Why do I get ENOENT when the file exists?
Check the full path — a parent directory may not exist, or there may be invisible characters.
Overview
Linux errno 2 (ENOENT) means the specified file or directory does not exist at the given path.
Key Details
- ENOENT — most common Linux error
- Path component does not exist
- Can occur with files, directories, sockets, or devices
- Shell may show "No such file or directory" message
Common Causes
- File path is misspelled or incorrect
- File was deleted or moved
- Symbolic link points to non-existent target
- Missing directory in the path hierarchy
Steps
- 1Verify the path exists: ls -la /path/to/file
- 2Check for typos in the filename or path
- 3Check symlinks: ls -la to see if link target exists
- 4Use find or locate to search for the file