Search

Linux locate command

Find paths using a prebuilt filename database; results may need updating.

Availability: Common Linux commands; shell built-ins and external implementations may differ by distribution.中文

Syntax

locate [OPTION]... PATTERN...

Examples

Search the locate database for paths containing ssh_config.

locate ssh_config

Search basenames case-insensitively.

locate -i -b 'readme*'

Parameters, options and clauses

Option / clauseDescription
-i, --ignore-caseMatch without case sensitivity.
-b, --basenameMatch only the final path component.
-c, --countPrint the number of matches instead of names.
-r, --regexp REGEXPInterpret the pattern as a regular expression.
-e, --existingPrint only entries that currently exist.
-0, --nullSeparate output paths with NUL characters.
Safety note

Review a command and its target before running it. Commands that alter files, services, accounts, disks, permissions or databases may be difficult to reverse. Test in a safe environment and keep backups.

Official reference ↗Back to directory