I'm trying to locate all copies of
example.filename on my FreeBSD server. What's the best / easiest / most efficient way to do this?
Much faster than
find, if you're running the locate service, and it only finds files that existed at the time
updatedb last ran (usualy the night befor under the control of a cron job).
You can run
updatedb by hand, but that is even slower than the
find cletus suggests, and requires root. I sometimes update the database by hand after installing a bunch of new stuff.
As others mentioned,
locate is the fast way to find a file. This command uses an pre-compiled index of the file and folder names. This database of names is searched, rather than crawling through your file system.
To be case-insensitive, add
locate -i eXAmPle.FileName
The database used by
locate must be up-to-date. After doing an install or download that may contain your desired file, you must update the
locate database will eventually be updated automatically by your FreeBSD system. There is a weekly set of chores that includes this task. These chores are listed in the
The easiest safest way to force the early updating of the
locate database is to force the weekly set of chores to be done now.
sudo periodic weekly
Or, you could even force all the regular chores to be done. You might want to do this immediately after setting up a new FreeBSD system.
sudo periodic daily weekly monthly
If using other avenues to update the
locate database, you may get a message about being unsafe, revealing the names of all your system’s files to any user on the FreeBSD system. Using the
periodic route avoids this problem.