How To Find a File in Linux


Linux is a famous OS due to its features, like its robust file management system. It lets you perform various operations such as creating, editing, moving, and renaming those files. However, these features pose no advantage if you cannot locate your desired files.

This is quite a common issue, and many users often forget a file’s location. So, this quick tutorial has all the easy methods to find a file in Linux with no hassles. In this section, we have included multiple commands such as find and locate. So let’s take a look at them one by one:

The Find Command

The find powerful command to search files based on various criteria. For example, let’s search for the Password.txt file located in the Documents directory: 

cd ~/Documents
find Password.txt


In case you don’t know the directory of the file, then you can run the below command: 


The above command produces accurate results only if you enter the file name in proper cases. Otherwise, you can run a case-insensitive search by using the -i option:


Moreover, you can guide the system to search only for files or only for directories by using the -f or -d options, respectively.

For files:

find -type f -iname password.txt


For directories:

find -type d -iname password.txt


The locate Command

The locate is more efficient than find as it scans your system periodically and indexes it in advance. So, whenever you use the locate command, it quickly refers to the index and returns the file location. Locate is not a pre-installed command, so please run the below command to install it: 

sudo apt install mlocate -y


Now, let’s find the Password.txt using the locate command:


Similarly, you can use the -i option to make the command case insensitive: 


The File Manager

If you are a Linux beginner, we recommend you to use the File Manager to find a file. For example let’s find the Password.txt file so please open the File Manager. Here, either you can press CTRL + F or click on the search icon to open the search bar:


Now, you can search for the Password.txt in the search bar: 


A Quick Wrap-up

It sometimes becomes difficult for Linux users to find a specific file due to the complex file storage. Hence, we have explained three simple methods for finding a file with no hassles. First, one explains the find and locate commands and their functionality. Lastly, we have included the easiest method for Linux beginners to find files right from the File Manager.

This website uses cookies to improve your experience. We'll assume you're ok with this, but you can opt-out if you wish. Accept Read More