One of the commands that I use a lot is precisely this: locate
Every desktop environment has a file browser, in KDE we KFind, there are alternatives for other environments such as CatFish, etc. But generally I am very busy and many times it is more comfortable for me to use the same terminal that I have open, and through this make a search for something, than to have to open another application (search engine, etc.) and put the search parameter, and then search ...
That's why I use a lot locate, a command that shows us in literally a matter of seconds all the results that match our search.
The main advantage that locate It offers any option over another, it is instantaneous, it shows what we are looking for literally at the moment. how is this possible? simple ... it happens that in our system we have an index of everything (or almost everything) that we have stored in it, and locate what it does is search that index for what we indicate.
Explained in a simpler way. When we search for something as we commonly do, at that moment the system is searched (folder by folder…. File by file) what we said, right? ... well, imagine you have a list of all the folders and files you have on your computer, and just look at that list where X files are. Isn't it simpler to search a text file of a few MBs, than to search TOOOOOOODO your hard disk? 😀
But hey… let's get down to business hehe.
Let's say for example that we want to find all files .ODT we have, we open a terminal and in it we write the following and press [Enter]:
locate -e *.odt
El -e I put it to specify that it looks for files that still exist, since the index with which it works locate Many times it contains information about files that were deleted, and it doesn't make much sense to show us files that no longer exist, right? 🙂
Anyway, now I will search my laptop for everything that contains the name «so»… We put the following:
locate -e asa
You notice the speed right? … Impressive 🙂
As a curious fact, the database (index) used by locate is: /var/lib/mlocate/mlocate.db
And well this is it, try the command and tell me that such haha.