Find Command in Linux [How to Find File in Linux]

Are you looking for a file in the Linux platform and are not able to find that then the Find command in Linux with examples blog post will help you to Find Files in Linux.

Updated: 05 Mar, 23 by Antoniy Yushkevych 3 Min

List of content you will read in this article:

Being a Linux administrator or beginner, many times we forgot any file which we have download or kept somewhere else in the system but unfortunately, we were not able to find that file. So to increase your productivity and lesser the work efficiency, You can use some basic Linux commands shortcuts to solve your problem. This article will help you to find file in Linux or how to search file in Linux, before moving forward or dive directly into the file command we should have a brief understanding of SSH.

SSH stands for Secure Shell. It is a protocol that connects you to a remote server or system. The established connection between the host and the client is extremely secure and safe due to encryption. 

There are two prominent ways to Search File and Directory in Linux, carry out this task:

  • Find command
  • Grep command

Find command in Linux

Find command eases your process of find file in Linux (CentOS, Debian, Ubuntu)using various arguments. You can search for the desired file through date, time, or even through modified time. 

1. Suppose, you wish to search for a file a.txt, follow the mentioned command:

find . -name testfile.txt

2. Now, if you do not remember the exact file name, try this method:

find . -name testfile*

Here, the system will scan all the files and present you with the file that matches your argument the best. 

3. Moving on, if you want to view a list of all the directories, simply use the following command:

find . -type d

4. Next, to view files modified in the last 3 days, use

find . -mtime -3

Additionally, if you want to search a specific part of a text in a file, use the Grep command.

Grep command

This command searches for the string, “warehouse” in the file config.php that you mentioned.

1. Now, in case you forget the file name, simply follow this command:

grep -r -H “warehouse” *

Here, -r means recursively, -H means that the result is human-readable for your desired string. ‘*’ means that the command scans all the files in your current directory and offers you the result.

2. To search for a specific text in a file, use the below-mentioned command:

Grep “warehouse” config.php

4. Additionally, if you only want a list of all the files that contain your mentioned string and not the entire line, use this command:

Grep -l “warehouse” *

4. Moving on to our last segment, there can be situations when these commands don’t work. Follow these two commands in such cases. 

whereis warehouse
which warehouse

This all about find commands in Linux that will help you how to find file in Linux/How to search files in Linux. In this article, we have listed many find commands for your help and to improve your productivity. We hope that using the commands listed above is sufficient. If still, you face any problems and do you have any kind of suggestion or you know more efficient command then you can comment them via comment box list below.

People are also reading:

Antoniy Yushkevych

Antoniy Yushkevych

Master of word when it comes to technology, internet and privacy. I'm also your usual guy that always aims for the best result and takes a skateboard to work. If you need me, you will find me at the office's Counter-Strike championships on Fridays or at a.yushkevych@monovm.com