How to Search for Files in Ubuntu Terminal

If you are managing an Ubuntu server via the command-line interface, losing track of a specific configuration file or a buried log document is incredibly common. Without a visual file explorer to click through, you cannot simply open a search bar and wait for the system to scan your hard drive visually.

Instead, Linux relies on the find command. This is one of the most powerful and versatile tools in the entire Ubuntu operating system, allowing you to search the entire directory tree for files based on their exact name, extension, size, or modification date.

How to Search for a File by Name

The basic syntax of the find command requires three things: the command itself, the directory you want to start searching from, and the name of the file you are looking for.

  1. Open your terminal or SSH into your Ubuntu server.
  2. Type the following command to search the entire hard drive (starting from the root directory /) for a file named exactly “database.sql”:
find / -name "database.sql"

The terminal will scan the server and print out the absolute path to any matching files it discovers (e.g., /var/www/backups/database.sql).

(Note: Searching the entire root directory / can take a long time and will likely throw dozens of “Permission denied” errors. If you know the file is somewhere in your personal home folder, you can speed up the search dramatically by using the tilde symbol ~ instead of the slash: find ~ -name "database.sql").

How to Perform a Case-Insensitive Search

Linux is strictly case-sensitive. If you search for “Report.pdf” using the standard -name flag, it will completely ignore a file named “report.pdf”.

If you are not entirely sure how the file was capitalized, use the -iname flag (insensitive name) instead:

find ~ -iname "report.pdf"

This command will successfully locate “Report.pdf”, “report.pdf”, and even “REPORT.PDF”.

How to Search for Specific File Extensions

You don’t need to know the exact name of a file to find it. You can use an asterisk (*) as a wildcard to search for every single file that shares a specific extension.

For example, if you want to find every single JPEG photograph located anywhere inside your “Pictures” folder, you would run:

find ~/Pictures -name "*.jpg"

The terminal will output a massive list of every image it found, completely ignoring text documents, videos, and configuration files.

Get the best tech tips delivered straight to your inbox.

Join thousands of readers mastering Apple, Google, Microsoft, and Linux.