locate command searches an index that the system builds periodically.
How to make sure, any new file you're looking is part of index? Is there any explicit command to index?
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. It only takes a minute to sign up.Sign up to join this community
From the manual (
locate reads one or more databases prepared by updatedb(8) and writes file names matching at least one of the PATTERNs to standard output, one per line.
updatedb writes the database. It is typically already set up to run periodically from cron in many systems. It should not be possible to update the system locate database as a regular user. So, perhaps
sudo updatedb works best in many systems.