Software⏱️ 3 min read📅 2026-06-15

How to Fix: File does NOT exist but ls shows "No such file or directory" error

File system ext4 issue with ls showing 'No such file or directory' error despite files existing.

Quick Answer: The issue is likely due to a corrupted file system. Try running fsck on the affected partition to repair it.

The 'No such file or directory' error can be frustrating when you're trying to access a file, but the issue is that the file exists on your system, yet ls shows an empty directory. This problem primarily affects Linux users who are using Bash shell version 3.2.57(2)-release.

In this troubleshooting guide, we'll explore the possible causes of this error and provide step-by-step solutions to resolve it.

🔍 Why This Happens

  • One main reason for this error is a file system corruption or misconfiguration. When a file exists on your system but ls shows an empty directory, it may be due to a corrupted file system or a misconfigured inode table. This can occur due to various reasons such as a power failure, disk errors, or incorrect file system configuration.
  • Another possible reason is the use of a file system with a bug that causes it to incorrectly report 'No such file or directory' even when the file exists.

✅ Best Solutions to Fix It

Fixing using fsck

  1. Step 1: Step 1: Run fsck -n on the affected file system to identify and fix any file system errors. This command will scan the file system for errors and report them. You can use the '-n' option to prevent fsck from making any changes to the file system.
  2. Step 2: Step 2: Once you've identified the problematic files, run fsck -f on the affected file system to fix the errors. The '-f' option forces fsck to make any necessary changes to the file system.
  3. Step 3: Step 3: After fixing the file system errors, try accessing the directory again using ls to verify that the 'No such file or directory' error has been resolved.

Fixing using e4if

  1. Step 1: Step 1: Run e4if -n on the affected file system to identify and fix any inode table errors. This command will scan the inode table for errors and report them.
  2. Step 2: Step 2: Once you've identified the problematic inodes, run e4if -f on the affected file system to fix the errors. The '-f' option forces e4if to make any necessary changes to the inode table.

💡 Conclusion

In conclusion, the 'No such file or directory' error can be frustrating when it appears that a file does not exist, but in reality, it may be due to file system corruption or misconfiguration. By running fsck and e4if commands, you should be able to identify and fix any errors with your file system, resolving the issue and allowing you to access the directory again.

Did this fix your problem?

If not, try searching for specific error codes.

🔍 Search Error Database

❓ Frequently Asked Questions