How do you locate the full path of a file on Linux?
⚡
Quick Answer
Use find / -name filename to search the whole filesystem by name, or the faster locate filename if the mlocate database is present. which/whereis find executables on PATH.
Detailed Answer
find is exact and always current but scans the disk (slow on large trees), so scope it to a directory when you can (find /etc -name ...). locate queries a prebuilt index (near-instant, but may be stale until updatedb runs). For binaries on your PATH, which nginx is quickest.
Code Example
find / -name filename 2>/dev/null locate filename
💡
Interview Tip
Contrast find (accurate, slow, live) with locate (fast, indexed, possibly stale) — knowing when to use each is the signal.
linuxfindfilesystem