updatedb Command Generator
Generate updatedb commands to build or update the file name database used by locate
Getting Started with updatedb
## What is updatedb?
`updatedb` builds or refreshes the file-name database that `locate` queries. After it runs, `locate needle` finds any file by name in milliseconds, far faster than `find` scanning the whole filesystem. The database is rebuilt on a schedule (usually daily via cron), but you can run it manually right after large file changes.
## How to Use
1. **Pick options**: usually none — `sudo updatedb` is the common form. Add `--output`, `--prunepaths`, `--prunefs`, `--database-root`, `--require-visibility`, or `-v` as needed. 2. **Target a custom database** (optional): use `--output` to write somewhere other than the default `/var/lib/plocate/plocate.db` or `/var/lib/mlocate/mlocate.db`. 3. **Copy & Run**: Prefix with `sudo` so the scan can read every directory.
Common Options
### `-v` Verbose Print the paths as they are scanned — useful to confirm the database is actually being rebuilt.
### `--output=FILE` Custom database Write the index to a specific path: `updatedb --output=/tmp/mydb.db`. Then query it with `locate -d /tmp/mydb.db pattern`.
### `--prunepaths='DIRS'` Skip directories Exclude paths from the scan so they never appear in `locate` results: `updatedb --prunepaths='/tmp /var/tmp /mnt/backup'`.
### `--prunefs='FSTYPES'` Skip filesystems Skip whole filesystem types like `nfs` or `tmpfs` so network or ephemeral mounts are not indexed: `updatedb --prunefs='nfs tmpfs'`.
### `--database-root=PATH` Scan root Index a subtree as if it were the filesystem root — handy for building a database of a chroot or mounted image.
### `--require-visibility` Permission filtering Store which files the indexing user could see and hide the rest from `locate`. Off by default on plocate (which only indexes world-readable paths); on by default on mlocate.
▶Why doesn't locate find the file I just created?
▶mlocate vs plocate — what's the difference?
▶Why do I need sudo to run updatedb?
If this tool has been helpful to you, consider buying me a coffee.
Buy me a coffee