Linux Tutorials
About Lesson

Locate Command :

The locate command is used to find files by their filename. The locate command is lightning fast because there is a background process that runs on your system that continuously finds new files and stores them in a database.

 

Using bash you can easily locate a file with the locate command. For example say you are looking for the file mykey.pem:

locate mykey.pem

Sometimes files have strange names for example you might have a file like random7897_mykey_0fidw.pem. Let’s say you’re looking for this file but you only remember the mykey and pem parts. You could combine the locate command with grep using a pipe like this:

locate pem | grep mykey

Which would bring up all results which contain both of these pieces.

Note that not all systems have the locate utility installed, and many that do have not enabled it. locate is fast and efficient because it periodically scans your system and caches the names and locations for every file on it, but if that data collection is not enabled then it cannot tell you anything. You can use updatedb to manually initiate the filesystem scan in order to update the cached info about files on your filesystem.

Should you not have a working locate, you can fall back on the find utility:

find / -name mykey.pem -print

Is roughly equivalent to locate mykey.pem but has to scan your filesystem(s) each time you run it for the file in question, rather than using cached data. This is obviously slower and less efficient, but more real-time. The find utility can do much more than find files, but a full description of its capabilities is beyond the scope of this example.

Let’s Join our Hacking Team

We Are Indian We Are Great

Hope this article helpful for you. Thank You

Indian Cyber Army | Make IT Secure

Enjoy…Stay Happy…Stay Secure…

Hope this article helpful for you. Thank You


If You Appreciate What We Do Here On Hackonology, You Should Consider:

Hackonology is the fastest growing and most trusted community site where you can find lots of courses, articles about Technology/Hacking/Cracking. Millions of people visit Hackonology! to search or browse the thousands of published articles available FREELY to all.

Let's be a part of Hacker's Community! Join our Hacking Team

We Are Indian We Are Great