LinuxCommandLibrary

slocate

Security-aware file location database

TLDR

Find file

$ slocate [filename]
copy
Case insensitive
$ slocate -i [filename]
copy
Update database
$ slocate -u
copy
Show statistics
$ slocate -S
copy
Limit results
$ slocate -n [10] [filename]
copy
Regex search
$ slocate -r "[pattern]"
copy

SYNOPSIS

slocate [-i] [-r] [-n num] [options] pattern

DESCRIPTION

slocate (Secure Locate) is a permission-aware version of the locate command that searches a pre-built database of file paths. Unlike standard locate, slocate only returns files that the searching user has permission to access, preventing information disclosure about file structures in restricted directories.
The tool maintains a database indexed by file path, providing near-instant search results compared to real-time filesystem traversal with find. The database is typically updated periodically via cron, and supports both glob-style patterns and regular expressions for flexible matching.
slocate has been largely superseded by mlocate, which uses a more efficient database format and is the default on most modern Linux distributions. Both provide the same security-aware behavior of filtering results based on the caller's file permissions.

PARAMETERS

-i

Case insensitive.
-u
Update database.
-S
Statistics.
-n NUM
Limit results.
-r REGEX
Regex pattern.
-e DIR
Exclude directory.

CAVEATS

Database may be stale. Root for update. Superseded by mlocate.

HISTORY

slocate is Secure Locate, a version of locate that only shows files the user has permission to access.

SEE ALSO

locate(1), mlocate(1), find(1), updatedb(1)

> TERMINAL_GEAR

Curated for the Linux community

Copied to clipboard

> TERMINAL_GEAR

Curated for the Linux community