← 返回命令列表

Linux command

slocate 命令

文件

复制后可按需替换文件名、目录或参数。

常用示例

Find file

slocate [filename]

Case insensitive

slocate -i [filename]

Update database

slocate -u

Show statistics

slocate -S

Limit results

slocate -n [10] [filename]

Regex search

slocate -r "[pattern]"

说明

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.

参数

-i
Case insensitive.
-u
Update database.
-S
Statistics.
-n _NUM_
Limit results.
-r _REGEX_
Regex pattern.
-e _DIR_
Exclude directory.

FAQ

What is the slocate command used for?

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.

How do I run a basic slocate example?

Run `slocate [filename]` in a terminal, then adjust file names, paths, flags, or remote targets for your system.

What does -i do in slocate?

Case insensitive.