By Alvin Alexander. Last updated: June 4, 2016
Wow, I just learned about the Linux locate
command the other day. I'm going to have to quit using find
so much. The locate
command is very quick, assuming it can find what it's looking for in it's cache.
Here's a quick locate example. Assume that you have apache installed on your system, but you can't remember where it is. Just type locate apachectl
to find the apachectl
command, and you'll see locate return some output, very quickly, like this:
your_prompt> locate apachectl /usr/local/web/apache-1.3.24/bin/apachectl /usr/local/web/apache-1.3.24/man/man8/apachectl.8 /usr/local/web/apache-1.3.24/htdocs/manual/programs/apachectl.html /usr/src/apache_1.3.24/src/support/apachectl /usr/src/apache_1.3.24/src/support/apachectl.8 /usr/src/apache_1.3.24/htdocs/manual/programs/apachectl.html
Notice that it matches other files that also contain the word apachectl
, so you may get more than you bargained for. For more info, type locate --help
or man locate
.