Search Files Recursively in Linux

Last updated on Dec 29, 2019 in Linux

There are many ways to find files from a Linux file system, but one useful method is to use find command with grep. This tutorial will explain this in more detail.

In this example, we want to find a file myfile.pdf. We know that it is located under home folder /home/theuser. In terminal, type following command:

$ find /home/theuser | grep myfile.pdf

The ouput is the found file with full path. The find basically lists all files recursively under the given folder and grep filters that result for the search term.

Note! If you are not sure where the file could be found (like the home folder in this case), you could enter find / | grep myfile.pdf, but this would go through every single file and directory in your system, which is not very efficient or elegant. In this case you might try locate command: Search Files Recursively With Locate in Linux