No such file or directory
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/cwherebis missing). - The file is on a filesystem that isn’t mounted.
How to Fix It
1. Verify the current directory
pwd
ls -lapwd 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 filenamefind 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/symlinkA 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-link6. Create missing directories in the path
mkdir -p /a/b/c
touch /a/b/c/file.txtThe -p flag creates all parent directories that don’t exist.
7. Check if the filesystem is mounted
mount | grep /mnt
ls /mntIf the expected mount point is empty, mount the filesystem with mount /dev/sdX /mnt.
Built by the developers of DodaTech
Doda Browser, DodaZIP & Durga Antivirus Pro