Linux Commands

Linux Find File Recursively

Sometimes, you look for a file on your Linux system but cannot locate it. Searching for it manually is an extremely tedious task because of the large number of files on your Linux system. Therefore, in this guide, we will share with you two very quick methods wherein you can quickly locate your desired file with the help of its name.

How To Find a File Recursively in Linux

To find any file recursively in your Linux system, you can pick any of the following two methods:

Method # 1: Using the Find Command

This method will use the pre-installed “find” command in Linux. We will try to look for a file named “file3.txt” within our Home directory using this command in the following manner:

$ find ~/ -name file3.txt

You can replace “~/” with the exact path of the directory if you wish to look for the specified file in a directory other than the Home directory. This command will recursively look for all the occurrences of the specified file within the specified directory. It will display all the relevant results along with their complete paths on the terminal, as shown in the following image:

Method # 2: Using the Tree Command

This is an alternate method to the first one that we discussed. This method makes use of the Tree command in Linux. However, this command is not installed by default on your Linux system. Before starting to use it, you will have to install it first with the following command:

$ sudo apt-get install tree

The following output shown will appear on your terminal after a successful installation of this command on your Linux system:

To use the Tree command for finding all the occurrences of a file recursively, you will have to use it in the following manner:

$ tree –P file3.txt

You can also add the directory path to this command if you wish to look for a file in a directory other than the Home directory. This command will display all the occurrences of this file on the terminal along with the complete directory structure in a friendly tree-like format as shown below:


By using the methods explained in this article, you can look for any of your desired files only if you know their names within seconds. The find command and the tree command were discussed with examples. In this manner, you will no longer need to memorize the paths of each individual file.

Similar Posts