Linux Search For File Use The Terminal




On Linux, do a file search by default using the GUI is not the best way that you can do to find a file.

You may search the files on GNU or Linux operating systems via a Terminal by using some tools that are available. Search the Linux Terminal file through this will be faster than using a GUI tool as it will not take a lot of resources.

There are some tools that you can use for searching files in Linux using the Terminal, other than by using the tool "locate" a search for a file based on your database and be able to work faster, you can also use the command "Find".

In contrast with the command "locate" a bit difficult to be used by lay users, the "find" command can be used easily to search files.

How to search for files from the Terminal on Linux by using the Find Command
Though easier to use, this command also has slower performance than with a perntah "locate". This is because the command is actually looking for direct files and directories on disk storage.

Find suitable to search for a file or a directory but you can't remember its name perfectly.



Because this command can search for files with certain specific criteria such as a user or group from a particular user, the file was modified or accessed before, files with a specific range of a certain size, hidden files, files, files with the executeable read only access, and file with certain other rights.

The best part is you can also freely combine the criteria in one single command by using the command "find" it.

Search For Files In A Particular Directory
First, as a base, you can search for a file by using the Terminal on Linux on a specific area or a specific directory. If you're looking for a file and know where the file may be located, you can use this way.

In this way, the search process files would be faster because it does not need to scan a whole directory with a large size. But the speed of the search process is also dependent on the size of that directory.

Open the terminal on Linux and then entered in the directory where the file is probably using the "cd" command as follows:
cd /name_direktory/

If you want to find in the home directory belongs to you, go to the home directory belongs to you by using the command "cd ~" and if you search the whole file system, use the command "cd /".

For example, if you want to search for an image file in the directory "Downloads" you. You just know that the file has a name with the word "sudoway", but you don't know exactly the name of the file.

First entry into the Directory Downloads you with the command "cd Downloads" and enter the following command in Terminal to search for it:
sudo find . -name *sudoway*

Then it will show up all the files that exist in the directory that has the name "sudoway".

The trailing period ( . ) in the order indicated so that the command "find" just looking at the directory where you are today.

If you want to look it up on the Home Directory, replace the sign with a tilde ( ~ ) and if you want to look it up on a whole directory, replace the sign by using a slash ( / ), do not forget to use the "sudo" If you Search the entire directory.

Search for files which are not known with certainty its name
The parameter "-name" in the above command was previously looking for files with the sensitive case. This means that if you search for a file with the name "sudoway", you will not find the file with the name "SudoWay", because these parameters are sensitive to upper and lower case.

To search for a file that you do not know its name clearly, you can replace the parameter "-name" with the parameter "-iname", as follows:
sudo find . -iname *sudoway*

Search For A File With A Specific Size Range
Furthermore you can look for a file with a specific size, for example you're looking for a image file of the same, the only thing you remember of that file is the size of the file is less than 10 MB. You can search for it by using the following command:
find . -size -10M

If you know that a file that is larger than 4 MB in size, you can use the command "find .-size + 4M ". You can also combine these parameters with the parameters before.

For example, you know that the file is smaller than 10 MB and greater than 4 MB. You can use the following command to search for it:
find . -size -10M -and -size +4M

Looking for A File last accessed or modified
Lastly, you can also do a search of the file that was the last time you access, you can specify a time frame to find a file that was the last time you access on a certain span of time.

For example you you're looking for a file and the only thing you know is you last time you access it about 3 minutes ago. To find it, you can use the following command:
find . -amin -3

If the file you are looking for the last time you access about half an hour ago, you look it up by changing the parameters of became "-amen -30" and if you access his two hours ago you can change these parameters become "-amen -120" and beyond.

Whereas if you access her two days ago, you could use the following command:
find . -time -2

This will show you all files that you access over the last two days at the location of the directory that you are looking for. Please adjust the parameter "2" in the above command with the span of time that you want to search.

For the search process more efficient and up, if you're looking for a file and find out some of the criteria from above, you could do a combination of these criteria to the search process more efficient.

Please use this way if according to you this way is faster and more efficient compared to do a search using the default search in the GUI, or you can do a search from the GUI if you search process by using the GUI much easier.


Next
Previous
Click here for Comments

0 comments: