Linux: Searching for files with locate command

Easy method with locate command

The easiest way is to use locate and find the file you want.


root@bt:/# locate

There are times when you cannot search file with locate program, this is because the path database of the file is not updated. You can invoke the update using updatedb command.

Another example with simple regexp:

locate -r gcc$



This means find the file that ends with gcc, you can further trim the search using grep:

locate -r gcc$ | grep bin

Another example using ignore case option:

Linux commands are case sensitive, sometime you are not sure about the case but you know the name of the file, you can do this.

locate -i reaver | grep bin



Notice the difference

root@bt:/# locate -r ‘/bin/gcc$’

This search is only interested the file that ends at gcc.

root@bt:/# locate -r ‘/bin/gcc’

This search matches any file that contains gcc.

This entry was posted in Linux, System OS and tagged , . Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s