The fastest way to find a file in Linux

The find command is the most direct route. Open your terminal and type find /home -name "filename", replacing "filename" with the actual name of what you're looking for. The command searches through every folder starting from /home (or wherever you point it) and lists every match it finds.

If you only remember part of the name, use a wildcard: find /home -name "*budget*" will find budget.txt, my-budget.xlsx, and anything else with "budget" in the name. The asterisk means "match anything here".

The search takes longer the bigger the folder you start from. Searching /home (your user files) is usually fast. Searching / (the entire system) can take minutes. Start narrow — search your home folder first, then expand outward if you don't find it.

Key Takeaways

  • The find command searches through folders and lists every file matching your criteria, and works even if you only remember part of the filename.
  • Use wildcards like find /home -name "*part-of-name*" when you don't know the exact name.
  • The locate command is faster but searches a database that updates once daily, so newly created files may not appear yet.
  • Combine find with -type f to search only files (not folders) and -type d to search only folders.
  • If the file is in your current folder or a subfolder, ls -R lists everything recursively without needing to know the name.

Using locate for faster searches

The locate command is quicker than find because it searches a pre-built database instead of scanning the disk in real time. Type locate filename and it returns results when ready.

The catch: the database updates once per day, usually overnight. If you created or moved a file today, locate won't find it yet. You can force an update by running sudo updatedb, but this takes a minute or two and requires your password.

Use locate when you're searching for something you know has been on your system for at least a day. Use find when the file is new or when locate returns no results.

Searching by file type or size

Sometimes you remember what kind of file it is but not the name. Add -type f to find only files (not folders), or -type d to find only folders. For example, find /home -type f -name "*.pdf" finds every PDF in your home directory.

You can also search by size. The command find /home -type f -size +100M finds files larger than 100 megabytes. Use -size -10M (with a minus sign) to find files smaller than 10 megabytes. This is useful when you remember roughly how big the file was.

Combine multiple conditions: find /home -type f -name "*.jpg" -size +5M finds large image files. Each condition narrows the results further.

Searching by when the file was created or changed

If you remember roughly when you last worked on the file, use the -mtime flag. The command find /home -type f -mtime -7 finds files changed in the last 7 days. Use -mtime +30 to find files not touched in more than 30 days.

For more precision, -mmin searches by minutes instead of days. find /home -type f -mmin -60 finds files changed in the last hour.

Combine this with other searches: find /home -type f -name "*.txt" -mtime -3 finds text files you edited in the last three days. This is often faster than searching by name alone when you have many files with similar names.

Searching inside file contents

If you remember text that was inside the file but not the filename itself, use grep. The command grep -r "search phrase" /home searches through every file in /home looking for that exact phrase and lists which files contain it.

The -r flag means "recursive" — it searches through all subfolders. The search is case-sensitive by default, so "Invoice" and "invoice" are different. Add -i to ignore case: grep -ri "invoice" /home.

Grep can be slow on large folders because it reads every file. If you're searching for a word that appears in many files, the output will be long. Narrow it down by file type if you can: grep -r "password" /home --include="*.txt" searches only text files.

Combining search methods for tricky situations

When a file is hard to track down, layer your conditions. If you remember it's a spreadsheet you edited last week, try find /home -type f -name "*.xlsx" -mtime -7. If that returns too many results, add a size condition: find /home -type f -name "*.xlsx" -mtime -7 -size +1M.

If you're searching the entire system and the command is taking too long, press Ctrl+C to stop it. Then start over with a narrower path — search /home instead of /, or add more specific conditions.

When you find the file, the output shows the full path. You can then open it directly in your text editor or file manager by copying that path.

Frequently Asked Questions

Why does find take so long when I search from the root directory?

Searching from / (the root) means find has to look through system folders, mounted drives, and everything else on your computer. Most of what you need is in /home anyway. Start there, and only search the whole system if you're certain the file isn't in your home directory.

Can I search for a file by its exact size in bytes?

Yes. Use find /home -type f -size 12345c where the number is the byte count and the c means "bytes". You can also use k for kilobytes, M for megabytes, or G for gigabytes. Most of the time, searching by approximate size (like +100M) is more useful.

What if the filename has spaces or special characters?

Put the filename in quotes: find /home -name "my document.txt". Without quotes, the terminal treats the space as a separator and the command breaks. Quotes work with wildcards too: find /home -name "*my document*".

Can I search multiple folders at once?

Yes. List them after find: find /home /tmp -name "filename" searches both your home directory and the temporary files folder. This is useful when you're not sure which location the file ended up in.

How do I save the search results to a file?

Add > results.txt to the end of your command: find /home -name "*.pdf" > results.txt. This writes all matches to a file called results.txt in your current folder instead of printing them to the screen.