Skip to content
No such file or directory

No such file or directory

DodaTech 2 min read

The No such file or directory error in Linux means the file or path you referenced does not exist at that location. This guide covers the most common causes and how to resolve each one.

What It Means

Linux returns ENOENT (Error NO ENTry) when a file path doesn’t resolve to anything. The file may be missing, the path may be incomplete, a directory in the path may not exist, or a symlink may point to a nonexistent target.

Why It Happens

  • You typed the path incorrectly — a missing slash, wrong case, or typo.
  • The file was deleted or moved by another process.
  • A symbolic link points to a target that no longer exists.
  • An intermediate directory in the path doesn’t exist (e.g., /a/b/c where b is missing).
  • The file is on a filesystem that isn’t mounted.

How to Fix It

1. Verify the current directory

pwd
ls -la

pwd shows where you are. ls -la lists all files including hidden ones. Confirm the file is actually there.

2. Check the full path with tab completion

# Start typing and press Tab
ls /var/log/sys<tab>

Tab completion reveals valid paths and prevents typos.

3. Search for the file

find / -name "filename" 2>/dev/null
locate filename

find searches from root (use with caution). locate is faster but relies on a database updated by updatedb.

4. Check for broken symlinks

ls -la /path/to/symlink
file /path/to/symlink

A broken symlink shows a blinking red target in most terminals. The file command will say “broken symbolic link”.

5. Repair a broken symlink

# Remove the old symlink
rm broken-link

# Create a new one pointing to the correct target
ln -s /real/path/to/target new-link

6. Create missing directories in the path

mkdir -p /a/b/c
touch /a/b/c/file.txt

The -p flag creates all parent directories that don’t exist.

7. Check if the filesystem is mounted

mount | grep /mnt
ls /mnt

If the expected mount point is empty, mount the filesystem with mount /dev/sdX /mnt.

Why does ls show the file but cat says No such file?
The file may have been deleted between the ls and cat command, or it’s a broken symlink. Use ls -la — symlinks show an arrow -> pointing to the target.
What does 'Text file busy' mean? Is it the same error?
“Text file busy” is different — it means a process is currently executing that file. Wait for the process to finish or kill it. “No such file” means the path doesn’t exist at all.

Built by the developers of DodaTech

Doda Browser, DodaZIP & Durga Antivirus Pro