The fastest way to find a file in Linux
The find command is the most direct way to locate a file in Linux. Open a terminal and type find /home -name "filename", replacing "filename" with the actual name of what you are looking for. The command searches through every folder starting from /home (or whichever directory you specify) and returns the full path to any matching file.
If you do not remember the exact name, use a wildcard: find /home -name "*budget*" will return any file with "budget" anywhere in its name. Add -type f to search only files (not folders), or -type d to search only directories. The search can take a few seconds on a large drive, but it will find what you need.
For faster results on your entire system, use locate instead: type locate filename. This command searches a pre-built database rather than scanning the drive in real time, so it returns results almost when ready. The trade-off is that the database updates once a day, so very new files may not appear yet.
Key Takeaways
- The find command searches your drive in real time and works for any file, no matter how new it is.
- The locate command is much faster but only finds files that existed when the database last updated.
- Wildcards like *budget* let you search by part of a filename when you do not remember the exact name.
- Adding -type f or -type d narrows your search to files or folders only.
- Searching from a specific folder like /home is faster than searching the entire system if you know roughly where the file is.
Using find with wildcards and partial names
When you only remember part of a filename, wildcards do the work for you. The asterisk (*) matches any number of characters. Type find /home -name "*2024*" to find all files with "2024" in the name, whether it is at the start, middle, or end. Type find /home -name "report*" to find files that start with "report" followed by anything else.
You can also search by file extension. To find all PDF files in a folder, type find /home -name "*.pdf". This works the same way: the asterisk matches any filename, and the extension stays fixed. Combine this with -type f to make sure you only get files, not folders that happen to have a dot in their name.
If you want to search case-insensitively (so "Budget" and "budget" both match), add the -iname flag instead of -name: find /home -iname "*budget*". This is useful when you are not sure whether the filename uses capital letters.
Searching by file size and modification date
Sometimes you remember when you created a file or roughly how large it is, but not its name. The find command can search by these details too. To find files modified in the last 7 days, type find /home -mtime -7. The minus sign means "less than 7 days ago"; use a plus sign for "more than 7 days ago".
To search by file size, use find /home -size +10M to find files larger than 10 megabytes, or find /home -size -10M for files smaller than 10 megabytes. Replace M with K for kilobytes or G for gigabytes. You can combine these: find /home -mtime -7 -size +5M finds large files you modified recently.
These searches are useful when you know a file is recent or unusually large but cannot remember its name. A spreadsheet you worked on yesterday, a video file you downloaded last week, or a backup archive you created — all become findable without guessing at filenames.
Searching inside file contents with grep
If you remember text that appears inside a file but not the filename itself, use grep to search file contents. Type grep -r "search term" /home to search through every file in /home for that phrase. The -r flag means "recursive," so it looks inside all subfolders too.
By default, grep shows you the filename and the matching line. Add -l to show only the filenames: grep -r -l "search term" /home. This is faster when you have many matches and only want to know which files contain the text. Add -i to ignore case: grep -r -i "search term" /home will match "Search Term", "search term", and "SEARCH TERM" all the same.
Grep searches can be slow on large directories because they read every file. If you are searching a specific folder where you think the file is, narrow the path: grep -r "search term" /home/username/Documents is faster than searching /home.
Using the file manager's built-in search
If you prefer not to use the terminal, most Linux desktop environments include a file manager with a search feature. In GNOME Files (the default on Ubuntu), click the magnifying glass icon or press Ctrl+F to open the search box. Type the filename or part of it, and the manager shows matching files in the current folder and subfolders.
The file manager search is slower than the command line and usually does not search your entire system by default — it searches the folder you are currently viewing and everything inside it. But it is more visual and does not require remembering command syntax. You can see file icons, sizes, and modification dates at a glance.
Some file managers also let you search by file type or modification date through a filter menu. Check your file manager's help or right-click in the search box to see what options are available.
Combining commands to narrow your search
When a single search returns too many results, combine commands to filter them. For example, find /home -name "*.txt" | grep -i report finds all text files, then filters the list to show only those with "report" in the filename. The pipe symbol (|) sends the output of the first command into the second one.
You can also pipe find results into other tools. Type find /home -mtime -7 -type f | wc -l to count how many files you modified in the last week. The wc -l command counts lines, which equals the number of files in this case.
These combinations are powerful but take practice to write correctly. Start with straightforward searches and add filters one at a time. If a command does not work, try it without the pipe first to see what results you get, then add the filter.
Saving search results and creating shortcuts
If you run the same search repeatedly, save the results to a file. Type find /home -name "*.pdf" > my_pdfs.txt to save a list of all PDF files to a text file called my_pdfs.txt. You can open this file in any text editor and refer to it later without running the search again.
For searches you use constantly, create an alias — a shortcut command. Open your terminal configuration file (usually ~/.bashrc) in a text editor and add a line like alias findpdf='find /home -name "*.pdf"'. Save the file, close your terminal, and open a new one. Now you can type findpdf instead of the full command.
Aliases save time if you search for the same file types or in the same folders regularly. They also reduce the chance of typing the command wrong.
Frequently Asked Questions
Why does find take so long to search my entire drive?
The find command scans every folder and file on your system, which can take several seconds or longer on a large drive. If you know roughly where the file is, search a specific folder instead: find /home/username/Documents -name "filename" is much faster than find / -name "filename". Use locate if you need when ready results and the file is not brand new.
How do I search for a file with spaces in the name?
Put the filename in quotes: find /home -name "my budget 2024.xlsx". Without quotes, the command treats each word as a separate argument and fails. Wildcards work inside quotes too: find /home -name "*budget*.xlsx" finds any Excel file with "budget" in the name, even if there are spaces.
Can I search for files I do not have permission to read?
The find command will report "Permission denied" for folders you cannot access, but it keeps searching other folders. If you need to search your entire system including restricted areas, run the command with sudo: sudo find / -name "filename". Be careful with sudo — it gives the command full system access.
What is the difference between find and locate?
locate is faster because it searches a pre-built database instead of scanning the drive. find searches in real time, so it always finds new files. Use locate when you know the file existed for at least a day; use find when the file is very new or you need to search by size or modification date.
How do I search for a file by owner or permissions?
Use find /home -user username to find all files owned by a specific user, or find /home -perm 644 to find files with specific permissions. These searches are useful for system administration but less common for everyday file hunting. Combine them with other flags: find /home -user username -name "*.pdf" finds PDFs owned by a specific person.