How to Use the Linux Find File Command

Quickly search files on the Linux desktop

You know you saved that file on your desktop. But where? If you're on the Linux platform, you have a number of tools at your disposal. These tools are incredibly powerful and easy to use, both those on the command line or in the graphical user interface (GUI). Here's how to locate files on your computer using the find command and the GNOME Desktop Environment.

Examples in this article use System76 Pop!_OS, with GNOME 3.32-1. The version used for the find command isn't important (the command has been around for a long time). The version of GNOME you use could cause slight variations in the process (especially if you use an older version of the desktop).

Use the find Command

The find command is powerful, and its usage can be complicated. However, the basic usage of the find command is simple. This is especially true when you know the name of the file for which you're looking. Let's say you have a file named lifewire somewhere in your ~/home directory (only you can't remember where you put it). If you have several subdirectories, locating that file can be a challenge.

With the find command, it's easy. Here's how you manage this task:

  1. Open a terminal window.

  2. Change to your home directory with the command cd ~/.

  3. Locate the file with the command find . -name lifewire.

    The basic find command.
  4. Open the file in question.

Here's the format of the above command:

  • find: The actual command.
  • . -: Instructs find to look in the current directory and all subdirectories.
  • -name: Instructs find that what follows is the name of the file to be located.
  • lifewire: The name of the file you're searching for.

The find command immediately dives into the current directory and searches all subdirectories for any file matching (in the case of this example) lifewire. If it locates anything, the find command lists the directory housing the file in question.

If the find command attempts to dive into a directory you don't have permission for, it reports that with a Permission denied warning.

If you're not sure of the full name of the file, the find command allows the use of wildcards.

In computing terms, a wildcard is a character that can be substituted for other characters. For example, if the file you're looking for begins with the word life, but you don't remember the rest of the name, use the * wildcard (like - life*). Wildcards can also be used in the middle of a string of characters. If you can't remember if the file is lifewire, lifetire, or lifedire, use the * wildcard (for example, - life*ire).

So, to find the lifewire file, when you're not sure how you spelled it, issue the command find . -name life*ire. The results of the command are similar to those when using the full file name.

Using a wildcard with find.

That same wildcard could be used if you're looking for a specific file type, for example, to search for all .jpg images. You could issue the command find . -name *.jpg to find what you're looking for.

Search From the Desktop

When searching from the GNOME desktop, there are two ways to find what you're looking for. The two methods are:

  • From the GNOME Dash
  • From the file manager

The more reliable of the two methods is to use the file manager. Although searching from the GNOME Dash works, there are occasions when it fails to find files. The Nautilus file manager, on the other hand, never fails. Here's how to search for a file using that method:

  1. Open the Nautilus file manager.

  2. Navigate to the top-level directory relative to what you are searching for. For example, if you know the file is in a subdirectory located in your home directory, navigate to Home

    The Nautilus file manager in the home directory.
  3. Click the search icon.

    The search icon in Nautilus.
  4. Type the name of the file you want to find.

    Searching for a filename in Nautilus.
  5. Once the results appear, double-click the file in question to open it.

Searching from the GNOME Dash does work (and generally works well). This method comes up a bit short if you search for a file created from the command line. All other files, however, are usually found without a problem.

To search for a file from within the GNOME Dash, follow these steps:

  1. Click Activities to open GNOME Dash.

  2. Type the name of the file you want to find.

    Finding a file within GNOME Dash.
  3. When the file appears below the search bar, click it to open.

That's all there is to search for a file from both the command line and the GNOME Desktop. Never worry that you won't be able to locate those files on the Linux desktop, as files are only a quick search away.