How to Locate, search, find file via Linux terminal (Ubuntu)

I have been using Linux especially Ultimate Ubuntu (really cool Ubuntu distribution) for a while and I think I will share this basic tutorial series on Linux shell commands.

One of the crucial functions that we need on every system is how to search and find. To Locate file in Linux my favourite command is “Locate” which can be run via terminal (some sort of command prompt in Linux). Open your terminal (in Ubuntu it will be Applications → Accessories → Terminal) and type in the following commands.

sudo updatedb

Updatedb creates or updates a database used by locate. If the
database already exists, its data is reused to avoid rereading directories that have not changed. Locate will find files which match your pattern and display the list (for example: locate, locate *.mp3, locate lib*, etc.).

You should not execute “updatedb” everytime you need to find file, but if you have just installed, or added new files to your system then you will need “updatedb” to includes these files on your search.

To get more information, read the manual of Locate and Updatedb by executing “man COMMAND_NAME”. For examples:

man updatedb
man locate

(use arrows to scroll and type ‘q’ to exit)

2 Replies to “How to Locate, search, find file via Linux terminal (Ubuntu)”

Leave a Reply

Your email address will not be published. Required fields are marked *