How to Find a File by Name in Linux: A Step-by-Step Guide

Searching for a file by name in Linux can be a straightforward task if you know the right commands. The find command is one of the most commonly used commands for this purpose. In just a few steps, you can locate any file within the Linux file system. Let’s get into how you can do this.

Step by Step Tutorial: Finding a File by Name in Linux

Before diving into the steps, it’s essential to understand that the following steps will use the Linux command-line interface (CLI), usually accessed through a terminal. The find command searches for files in a directory hierarchy. You can specify various criteria to narrow down your search, but in this case, we’ll focus on finding a file by its name.

Step 1: Open the Terminal

The first step is to open the terminal on your Linux system.

Once you’ve opened the terminal, you’re ready to start using commands to find your file. You’ll be typing these commands directly into the command line interface.

Step 2: Use the Find Command

Type the find command followed by the path to the directory you want to search in and the name of the file you’re looking for.

For example, the command find / -name 'filename.txt' will search for a file named ‘filename.txt’ starting from the root directory. Remember to replace ‘filename.txt’ with the actual name of the file you’re searching for.

Step 3: Review the Results

After executing the find command, the terminal will list the paths to any files that match the name you specified.

If the file exists, you’ll see its full path displayed in the terminal. If there are multiple files with the same name, each will be listed on a separate line.

After completing these steps, you should have located the file you were looking for. If the file does not appear in the results, it may not exist, or you may need to modify your search criteria.

Tips for Finding a File by Name in Linux

  • Tip 1: Use wildcard characters, such as “*”, when you only remember part of the file name.
  • Tip 2: To ignore case sensitivity, use the -iname option instead of -name.
  • Tip 3: If you want to limit the search to a specific type of file, use the -type option followed by ‘f’ for files.
  • Tip 4: Use the -maxdepth option to limit the depth of the directory tree that find searches.
  • Tip 5: For a faster search, narrow down the search path if you know the file is in a specific directory or subdirectory.

Frequently Asked Questions

What if the file I’m looking for is hidden?

Files that start with a dot (.) are considered hidden in Linux. Use the -name option with the dot included in the file name, like ‘.filename.txt’, to find hidden files.

Can I search for files with a particular extension?

Yes, use a wildcard for the file name and specify the extension. For example, find / -name '*.txt' will find all .txt files.

How can I find a file by name but only in the current directory?

Use the period (.) as the path to represent the current directory. For example, find . -name 'filename.txt'.

What if I get too many permission denied errors when searching?

Run the find command with sudo to search as a superuser, which will allow you to access all directories.

Can I search for multiple file names at once?

Yes, you can use the -o option between multiple -name options. For example, find / -name 'filename.txt' -o -name 'anotherfile.pdf'.


  1. Open the Terminal
  2. Use the Find Command
  3. Review the Results


So there you have it – a simple guide on how to find a file by name in Linux using the find command. Whether you’re new to Linux or an experienced user, this command is an essential part of your toolkit. It’s incredibly powerful, versatile, and can save you a lot of time when you’re trying to locate a specific file among a sea of data.

As you become more comfortable with the find command, you’ll discover that it has many more options and features that can help you refine your searches even further. For those who want to deep dive into its capabilities, the man page for find (man find in the terminal) is an excellent resource.

Remember, the key to becoming proficient in Linux is experimentation and practice. So don’t be afraid to try out different commands and options. And if you ever find yourself stuck or unsure, the Linux community is incredibly supportive and always willing to help out.

The ability to find a file by name in Linux is just the tip of the iceberg when it comes to navigating Linux’s powerful command-line environment. With a bit of practice, you’ll be zipping around the file system like a pro in no time. Happy searching!