Linux system errors
Not a Directory
Reviewed for reference consistency: August 11, 2026
a path walks through a component that is an ordinary file
What 20 Means
The 20 error on the Linux system errors indicates not a directory — a path walks through a component that is an ordinary file. This typically occurs due to a path expression treating a regular file as a directory (file.txt/subpath).
Exit code 20 corresponds to ENOTDIR, 'Not a directory'. Path resolution walks a path one component at a time, and every component except the last must be a directory to descend through. When the walk reaches an ordinary file standing where a directory should be, the kernel stops and reports errno 20.
How to fix 20
General informational guidance, not professional advice. Commands can affect your system or data — back up first and proceed at your own risk. FixerCode is an independent reference, not affiliated with any vendor mentioned.
Walk the path component by component
namei resolves each element of the path in turn, printing its type, so the component that is a file instead of a directory is visible immediately.
namei -l /full/path/under/suspectIdentify the suspect component's type
file reports whether the questionable path element is a regular file, directory, or link.
file /path/to/suspect_component
Technical Background
Path resolution walks a path one component at a time; ENOTDIR is the walk hitting a wall. Every intermediate component must be a directory the kernel can descend into. The offending component is a real, existing file — which is what separates errno 20 from a simple missing path. The file is there; the descent is impossible.
The everyday form is a typo with structure: notes.txt/summary reads like a path and parses like a path, and only the filesystem knows that notes.txt cannot contain anything. The systematic form is generated paths, where a base path and subpath are joined by code that never checks what the base actually is.
Symlink indirection hides the failure until it moves. A link pointing into a directory works for months; when the target is replaced by a plain file, every path through the link starts failing with errno 20 while looking exactly as valid as before.
Common Causes
- A path expression treating a regular file as a directory (file.txt/subpath)
- A generated or templated path whose join logic assumed a directory where a file exists
- A symlink retargeted to a plain file, breaking paths that assumed a directory behind it
Typical Scenarios
- A command like cat notes.txt/summary, where the operator assumed notes.txt was a directory
- A build script appending subpaths to a configurable root that a deployment set to a file path
- A symlink pointing into a moved or replaced directory that is now a single file
What to Know
Component-by-component path walking pinpoints the failing step: it prints every element of the path and its type, so the file standing where a directory should be is named directly.
Frequently Asked Questions
Common questions about Linux 20 error
The failure belongs to the component before the one named in some messages: resolution died when it tried to descend through the file. Path-walking tools that print each component make the failing step obvious.
ENOENT (exit 2) means a component does not exist. ENOTDIR (exit 20) means a component exists — but it is a file, so the path cannot continue through it. Both block the walk at a different wall.
Yes, and generated paths are the usual carrier: a template joining a configurable base with subpaths produces a syntactically clean path that fails the moment the base is a file rather than a directory.
Related Error Codes
Invalid Argument — a syscall received a malformed or self-contradictory parameter
Shell Misuse — improper use of shell built-ins or syntax
File Exists — a create-with-exclusivity request collided with a name that is already there
Is a Directory — a file-level write or open was aimed at a directory
Related Errors From Other Categories
Similar error codes documented across different platforms and systems
You have unresolved file conflicts preventing Git from completing the current operation.
You tried to add a remote named 'origin', but one with that name already exists.
Git does not know which remote branch should receive your pushed commits.
You checked out a specific commit, detaching your working directory from the branch history.