In general, users prefer using the graphical file browser to search for a specific file. However, there exist few powerful commands that can help you find your file in your Linux system. In this tutorial, we are going to show you how to search for a missing file using various ways.
Find Files in Linux
The following methods will be covered in this guide:
- Searching your machine using the command line
- Search your machine using a graphical user interface
Before starting our guide, let’s first create a new file that we will try to search for in this tutorial. To make a new file, use the touch command as follows:
touch findme
Search using the Command-Line
During this method, we are going to use the command line via the Linux terminal. Basically, there are two different commands to search for a file:
- find command
- locate command
Search using “find” command
The “find” command allows you to find files in your system. You can search by a part or full file name. Also, it can be used to search for files modified at a particular time.
For example, to search for files in the current directory that starts with the “fi” letters use the following command:
find . -name fi*
The dot or “.” here means to search in the current directory. Also, in case you need to search in a specific location, you can specify it as follows:
find /home/tuts/ -name fi*
Additionally, if you do not know the file name, but you only know the file extension, then you can effortlessly search with the file extension as follows:
find /home/tuts/ -name *.png
Moreover, if you need to retrieve all the empty files in the current location, use the following command:
find . -type f -empty
Now in case, you need to search for particular files that were modified at a specific time then use the below command:
find /home/tuts/ -name *.png -mtime 2
As you can notice, the “-mtime” tag can be used to specify the files that were changed in the past two days.
Search using the “locate” Command
Using the locate command will help you search for a file. Basically, the locate command is easy to use as following:
locate findme
Search Using the Graphical User Interface
This is the simplest and preferred method that can be used to search for a file on your computer. First, you need to open a file browser. In most of the Linux distros, it’s called “Files” with a folder icon.
Then click on the search button.
Next, in the search bar, write down what you need to search for.
Furthermore, you can click on the drop-down arrow to search with more advanced options, including date, content, etc.
Congratulations, you have just learned how to search for a file in your Linux machine. That’s it for now, and I hope you have enjoyed it.