Tuesday, 22 September 2020

Exploring the Linux locate command

Linux locate command, LPI Study Materials, LPI Learning, LPI Guides, LPI Certification, LPI Exam Prep

The Linux locate command lets you easily find files in the filesystem. It works by maintaining a system-wide database of "all files which are publicly accessible". The database itself is updated periodically by a background process. Because of this approach it returns results much faster than the find command, which only looks for files when you tell it to. Depending on your system, the locate command may need to be configured initially, or it may be pre-configured to work out of the box.

The Linux locate command is easy to use. If you want to find a file named "foo", just use this locate syntax:

locate foo

The locate command returns all files it knows whose name contains the string "foo", like "foo1", "foobar", etc.

Linux locate command, LPI Study Materials, LPI Learning, LPI Guides, LPI Certification, LPI Exam Prep

You can also use the usual filename wildcard characters, including ? and *. For instance, this locate example command will list every Java file on your system:

locate "*.java"

(Be prepared, that can be a very long list.)

Finally, you can also perform a case-insensitive search using the locate command with the -i argument, like this locate command example:

locate -i "*.java"

Related Posts

0 comments:

Post a Comment