How to Find a File in Linux

Find a File in Linux: The following section covers how to search for files in Linux by using the find command from the command line. The command line Interface or (CLI) in Linux is a text based interface. Sometimes referred to as the terminal, it is where users can interact with the operating system by typing commands. This CLI or terminal provides a flexible and powerful way to control and customize a Linux system.

The find command in Linux can be used to search for files and directories on a file system. It works by recursively traversing the file system and matching files based on various criteria such as name, size, or date modified. Finding a file in Linux from a command line can be both educational and fun and helps you learn to use Linux by performing file searches without relying a graphical user interface.

Find a File in Linux using the Terminal

To find a file in Linux, you can simply use the find command. Here's how to begin a basic file search:

  1. Open a terminal window. From Debian or Ubuntu you can use Ctrl + Alt + T
  2. Type the following find command replacing "filename" with the actual name of the file you're searching for, and then press Enter
    find -name filename

    Note that you can also use a wildcard * in the filename to find file variations:
    search file linux

How the Find command works to Search for a File in Linux

The find command will search for a file in Linux and display the path to the file if it's found. If there are multiple files with the same name, the command will display the path to each one. If you use a forward slash before the filename for example: find / -name filename , the find command will search the entire file system, starting from the root directory. 

Note that searching the entire file system for a file can take a while, especially if you have a large number of files. So when you can, you should start your search by providing a more specific starting directory.

If you want to narrow your search to find a file in a specific directory or directories under a directory, simply replace the forward slash in the command with the path to the directory you want to search.

For example, the following command specifies to narrow a search for YUMI* to the user named lance.

find /home/lance -name YUMI*

Search for a File in Linux

That's how easy it is to use find from the terminal to search for files and find a file in Linux. You can also learn about more find command options from the manual by typing man find from an open terminal.

man find

Now you know how to search for files and find a file in Linux from the terminal.