Skip to main content

Permission Issues

locate is designed to be secure. It won't show you files you don't have permission to access.

How it Works

The updatedb process runs as root and indexes everything it can see. However, when you run locate as a non-root user, it filters the results.

Issue: File Exists but Locate Doesn't Show It

Even after updatedb, a file might be missing from your results if:

  1. Parent Directory Permissions: If you don't have +x (execute) permission on a parent directory, locate (depending on the version) might hide everything inside it.
  2. Explicit Exclusions: The directory might be excluded in /etc/updatedb.conf (e.g., /tmp, /var/spool).

Troubleshooting

Check if root can see it:

sudo locate myfile.txt

If root sees it but you don't, it's a permission issue.

Check /etc/updatedb.conf: Look at PRUNEPATHS and PRUNENAMES to see if your path is being skipped by the indexer.

grep PRUNE /etc/updatedb.conf

SUID and slocate

Older versions (slocate) used a special setuid bit to manage permissions. Modern mlocate and plocate use a more efficient and secure group-based access model (locate group). Ensure your locate binary has the correct permissions:

ls -l $(which locate)
# Should show something like -rwx--s--x 1 root mlocate