slocate command in linux

slocate command is Security Enhanced version of GNU locate. This command searches a database listing every file on the system; it is intended as a faster replacement for “find / -name pattern”. This version stores file permissions and ownership, in order to prevent unauthorized access to files.

locate and slocate consult database files about the system (usually compiled and updated by a job run from the scheduler system cron) to find files or commands almost instantly. The location of the actual database files, what is indexed therein, and how often it is checked may vary from system to system. Consult your system’s manpages for details. slocate (secure locate) stores permission information (in addition to filenames and paths) so that it will not list programs to which the user does not have access. On most Linux systems, locate is a symbolic link to slocate; other systems may have separate programs, or may not have slocate at all.

Syntax:

$ slocate [parameter] [search-string]

slocate Command Options

Option Description
-c Read /etc/updatedb.conf when updating the database.
-dfile, –database=file Use file as the database to search.
-edir1[,dir2…] Exclude the given directories from the database.
-ffstype1[,fstype2…] Exclude files on filesystems of the given types (e.g., NFS).
-h, –help Print an option summary and exit.
-i Ignore case when searching.
-l level Security level. If level is 0, no security checks are done, providing faster searches. The default is 1, which turns on security checking.
-n count Do not print more than count results.
-ofile, –output=file Use file as the database to create.
-q Do not print error messages (quiet mode).
-rregex, –regexp=regex Use the Basic Regular Expression regex to search the database.
-u Create the database starting at /.
-U dir Create the database starting at dir.
-v, –verbose Display filenames when creating the database.
-V, –version Print version information and exit.

slocate Command Example

Use the command “slocate” to display the file path information with the keyword “parted” in the file name:

# slocate parted
Related Post