Where is a specific file located in Ubuntu?

Finding the exact location of a file in Ubuntu can be done quickly using several built-in terminal commands, depending on whether you need a real-time search, a fast database lookup, or a tool to locate system binaries. This article covers the most effective commands for locating files in Ubuntu—including find, locate, which, and whereis—and explains when to use each one for the best results.


The find Command: Real-Time and Powerful

The find command is the most versatile and thorough tool for locating files in Ubuntu. It searches through your actual directory structure in real time, allowing you to filter by name, size, modification date, and file type.

Because find checks the live file system, it can take some time to complete if you search large directories like the root (/) directory.


If you need results instantly, the locate command is the best option. Instead of searching the live file system, it reads a pre-built database (mlocate.db) of all files on your system.

Keeping the Database Updated

Because locate relies on a database, it might not find files that were created very recently. You can manually update the database at any time by running: sudo updatedb


The which and whereis Commands: Finding Executables

If you are looking for the location of a specific application or terminal command rather than a personal document, Ubuntu offers two specialized tools.

The which Command

This command looks through your system’s PATH environment variable and returns the exact executable file that runs when you type a command.

The whereis Command

This command provides a broader search than which. It returns the location of the binary executable, the source code (if available), and the manual page files for the specified command.


Summary of Which Command to Choose

Command Best Used For Speed Search Type
find Complex searches, specific filters, and real-time accuracy. Slower Live File System
locate Finding any file instantly by name. Instant Database
which Finding the exact executable path of a terminal command. Instant PATH Environment
whereis Finding binaries, source files, and manuals for applications. Instant System Directories