How to Find a file in FreeBSD

Solution 1:

find / -name example.filename

Solution 2:

locate filename

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.


Solution 3:

If you've got locate (aka slocate) installed, then

locate example.filename

locate runs a cron job every night that reindexes all the files on your machine. It's not always up to date for that reason.


Solution 4:

Sometimes you want to find files at a specific directory level. In this case it can be convenient to use shell wildcards:

ls /data/*/example.filename

Obviously this only works if you have a rigid directory structure.