Find command in linux allows you to search for files and folders. You can also search by extension, filename and time.
find command in linux | with pictures
![]() |
Linux command find |
Hello, guys Today I'm going to show you how You can use "find" command in Linux.
What is "find" command?
"find" command is used to search for files in a directory hierarchy.
Find Command
![]() |
Find command |
$find [directoryName] -name [fileName]
For example, I want to find "file1.txt". Which I have created a few days ago. I don't know which folder is it. I just know that it's in the root directory of my operating system.
So I can use "find" command for this so just use "find / -name file1.txt" and press ENTER
It's going to search in all the directories and files in this root directory and then it's going to search where is this file located and prints the output.
Search by File Name
![]() |
search files |
$find [directoryName] -name fileName.*
For example, I just know that this file is called "file1" but I don't know the extension.
In this case, you can use ".*" (Asterisk) as a wildcard.
- This means that whatever comes after "file1." then it will go to search for all those files.
I'm going to write "find /desktop -name file1.*" and press ENTER
Search by extension
![]() |
search extension |
$find directoryName -name *.extension
For example, I just want to search for ".txt" extension the files which have the "txt" extension.
I just give "find /desktop -name *.txt" and press ENTER
Result which has a ".txt" extension is going to be listed.
Search files and folders
![]() |
search files and folders |
$find directoryName -name fileName*
I want to search for the particular files and folder called "file1".
I just want to write "find /desktop -name file1*" and press ENTER
- Whatever files and folders which will start from "file1" are going to be searched and listed in our result.
So in this way you can search for the file and folder in your directory in which you want to search.
Search files by Time
![]() |
Search by time |
$find / -mtime -1
For example, You have created a file and you just know that you have created this file a few days ago.
But you don't know the name of the file and you don't even know the location of the file.
So, In this case, you can use "find / -mtime -1" press ENTER
- "-1" is going to look at the files which are created one day ago to till now.
This can be plus also so you can know that from this time this will be created.
Conclusion
So this is how you can use this "find" command in Linux.
I hope you've enjoyed this tutorial please rate comment and bye for now.
HAVE A NICE DAY💖