The fastest way to find a file in Linux

The find command is the most direct way to search for a file in Linux. Open your terminal and type find /home -name "filename", replacing "filename" with the name of what you are looking for. The search starts from /home (or whichever directory you specify) and checks every folder inside it. Results appear in the terminal as a list of full paths to matching files.

If you do not remember the exact name, use a wildcard: find /home -name "*budget*" finds any file with "budget" anywhere in its name. The asterisk means "match anything here". This is slower on a large drive because the system checks every file, but it works reliably and requires no setup.

For faster searching on systems you use regularly, the locate command searches a pre-built index instead of scanning the whole drive. Type locate filename and results appear when ready. The catch: the index updates once a day by default, so very new files may not show up yet. Run updatedb to refresh the index manually if you need to find something you just created.

Key Takeaways

  • The find command searches your entire filesystem in real time and works even if you only remember part of the filename using wildcards like *budget*.
  • The locate command is much faster but searches an index that updates once daily, so newly created files may not appear until you run updatedb.
  • Specify the starting directory in find to narrow the search — find /home/username/Documents -name "*.pdf" searches only that folder and its subfolders.
  • Use -type f to search only for files, or -type d to search only for directories, which cuts down irrelevant results.
  • Combine search criteria with -mtime to find files modified in the last N days, useful when you remember roughly when you created something.

Searching by file type or size

When you remember what kind of file you are looking for but not its name, search by extension. Type find /home -name "*.pdf" to find all PDFs, or find /home -name "*.jpg" for image files. This narrows results dramatically if you are searching a large directory.

You can also search by file size. The command find /home -size +100M finds files larger than 100 megabytes — useful if you are looking for a video or large archive you know you saved. Use -size -10M for files smaller than 10 megabytes, or -size 5M for files close to exactly 5 megabytes.

Combine these filters. find /home -name "*.mp4" -size +500M finds video files larger than 500 megabytes. Each additional filter makes the search more specific and returns fewer results.

Searching by when a file was created or changed

If you remember roughly when you created or last edited a file, search by modification date. The command find /home -mtime -7 finds files modified in the last 7 days. Use -mtime -1 for the last 24 hours, or -mtime -30 for the last month.

The number after -mtime represents days. A minus sign means "within the last N days". A plus sign means "more than N days ago". So find /home -mtime +30 finds files you have not touched in over a month — useful for cleaning up old files.

You can combine date searches with other filters. find /home -name "*.txt" -mtime -3 finds text files you edited in the last 3 days. This is often faster than scrolling through folders when you have a rough sense of when you worked on something.

Using grep to search inside files

Sometimes you remember text from inside a file but not the filename. The grep command searches the contents of files. Type grep -r "search term" /home to search every file in /home for that phrase. The -r flag means "recursive" — it searches all subfolders too.

Results show the filename and the line containing your search term. If you are looking for a specific word in a document, this is faster than opening files one by one. Add -i to ignore uppercase and lowercase differences: grep -ri "Budget" /home finds "budget", "Budget", and "BUDGET".

Grep can be slow on large directories because it reads every file. Narrow the search by file type: grep -r "search term" /home --include="*.txt" searches only text files. This cuts the time significantly if you know roughly what kind of file you are looking for.

Graphical search tools as an alternative

If you prefer not to use the terminal, most Linux desktop environments include a file manager with a built-in search. Open your file manager (usually called Files, Nautilus, or Dolphin depending on your system), click the search icon, and type the filename. Results appear as you type, and you can click any result to open it.

Graphical search is slower than command-line tools on very large drives, but it is more intuitive if you are not comfortable with terminal commands. The trade-off is that graphical search usually cannot filter by size or modification date the way command-line tools can.

Speeding up searches on a slow system

If your system is slow or your drive is very large, searches can take several minutes. Start with the most specific search possible. Instead of find / (which searches your entire system), use find /home/username to search only your user folder. Instead of searching by name alone, add a file type: find /home/username -name "*.pdf".

If you search the same directories regularly, set up locate with a custom index. This requires one-time setup but makes future searches nearly when ready. Alternatively, use find with the -maxdepth flag to limit how many folder levels deep the search goes: find /home/username -maxdepth 3 -name "filename" searches only 3 levels of subfolders instead of the entire tree.

Frequently Asked Questions

Why does find take so long on my first search?

The find command scans your entire filesystem in real time, checking every file. On a large drive with many files, this can take several minutes. Narrow your search by specifying a starting directory like /home/username instead of /, or add filters like -name "*.pdf" to reduce the number of files checked.

Can I search for files I deleted?

No. The find and locate commands search only files that still exist on your system. Once a file is deleted, these tools cannot find it. Recovery requires specialized software and depends on whether the disk space has been overwritten.

What is the difference between -mtime and -atime?

-mtime finds files by when they were last modified (edited). -atime finds files by when they were last accessed (opened or read). Most of the time you want -mtime. Use -atime only if you are looking for files you recently opened but did not change.

How do I search for a file with spaces in its name?

Put the filename in quotes: find /home -name "my budget file". Without quotes, the terminal treats each word as a separate command. Wildcards work inside quotes too: find /home -name "*budget*" finds any file with "budget" in its name, whether or not there are spaces around it.

Can I search multiple directories at once?

Yes. Type find /home /var -name "filename" to search both /home and /var. You can list as many starting directories as you need, separated by spaces. Results show files from all of them.