TrumanWong

locate

Command to find a file or directory

Supplementary instructions

slocate command is a command to find a file or directory. Slocate itself has a database that stores information about files and directories in the system.

grammar

slocate [-u][--help][--version][-d <directory>][find file]

Options

-d<directory> or --database=<directory> specifies the directory where the database is located.
-u Update the slocate database.
--help Display help.
--version Display version information.

Example

Use the command "slocate" to display file path information containing the keyword "fdisk" in the file name. Enter the following command:

$ slocate fdisk #Display the path information of files containing the fdisk keyword in the file name

After executing the above command, the output information of the command execution is as follows:

$ slocate fdisk #Display the path information of files containing the fdisk keyword in the file name
/root/cfdisk #List of searched file paths
/root/fdisk
/root/sfdisk
/usr/include/grub/ieee1275/ofdisk.h
/usr/share/doc/util-Linux/README.cfdisk
/usr/share/doc/util-Linux/README.fdisk.gz
/usr/share/doc/util-Linux/examples/sfdisk.examples.gz