Hello
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.
regards
A tip, with the updatedb command this database is updated.
I was just going to ask how that database is updated.
Great 😀… another little thing that I learn hehehehehe.
Hey, a detail ... wouldn't you like to blog directly? I know the problems with the connection and such, precisely for that reason it could be configured to publish by email or something like that 😉
Very good. In my case, the database is not in that directory or with that name, but with a "locate locate" everything is fixed: / var / lib / locatedb
HAHAHA locate locate … Fuck great haha 😀
he tells me
bash: locate: command not found
treats as root, although it shouldn't be.
You may have to install it.
Try with / usr / bin / locate asd Let's see what it tells you 🙂… if it doesn't work for you, check that you have the mlocate package installed, which is strange… because I have used Ubuntu, Debian and Arch and this command is installed by default in all of them.
after reinstalling
[david @ arch ~] $ usr / bin / locate asd
bash: usr / bin / locate: The file or directory does not exist
[david @ arch ~] $ locate locate
locate: could not perform stat () `/var/lib/mlocate/mlocate.db ': The file or directory does not exist
Excellent command, I did not know him, and if the speed is impressive! and a
man locate
already explain the rest to me, thank you very muchYou're welcome, a pleasure 😀
Hmm… better than find? a speed test should be done oO
In my case I could do the same searches, but like this:
$ find / home / user -iname "* .odt"
$ find / home / user -iname "* handle *"
If I wanted to find certain files and know their size:
$ find -iname "* .iso" -exec du -h {} \;
Although, in fact, even with ls I search within the current directory, that is, if I know where the file may be located:
omega @ mega-laptop ~ / Images $ ls * .png
Oops, excuse me, I was denied more than necessary 😐
Nah don't worry, if you want I'll fix it 🙂
Find does the search the moment you execute it, while locate has already done the search and generated a list some time ago ... and when you execute it, what it does is look for what you set as a parameter in a file of few MBs or KBs 😀
Ah, thanks for the 😉 comparison. Hehe, a little late in answering but work has me busy 🙂
Saying it like this reminds me of the windows "index server" when speeding up searches.
This reminds me of the KDE semantic desktop searches (Nepomuk specifically) 😀
Interesting, I'm more of the gnome type so I didn't know about kde: O
somebody help me..i tried to update and i get updatedb: cannot open temp file for `/var/lib/mlocate/mlocate.db '
On the other hand I have used the locate locate (I loved it) and if I locate the file above ...
What would they do in my place? please in a language for beginners ... and I hope this keeps updating