FreeBSD: How To Find A File (Or Directory)Written by: Donovan / Last updated: Jan 10, 2023
If you’re looking for a file (or directory) in FreeBSD or OpenBSD, there are 3 commands you should know about:
find can be used to find a file or directory.
You use it like so:
# File find / -type f -name "file name" # Directory find / -type d -name "directory name"
You can change the
/ to any folder you want to start searching in.
whereis command is useful for finding the location of a binary.
Say, for example, you want to find the exact location of the
# Command whereis ls # Result /bin/ls
Before you can use the
locate command, you’ll need to build its database like so:
doas (or sudo) /usr/libexec/locate.updatedb
You can then find a file or directory like so:
This is basically like running
find but it’s a lot faster, since you’ve prebuilt the database. Just beware that running the
locate.updatedb command as root will expose every single file (including in your root folder) on the system to every user.