Skip to content
Related Articles

Related Articles

slocate command in Linux with Examples

View Discussion
Improve Article
Save Article
  • Last Updated : 21 Feb, 2022

slocate command in Linux is used to find the files in your system. This is a secure version of the Linux command locate which is also used for file searching, similar to locate command it creates a database of the file locations for faster searching. But it is much more secure than locate command because it allows users to only see the files that the particular user is authorized with. So if a superuser decides to create files with permission only for the superuser then non-superusers won’t have access to those files while using slocate command. later slocate got replaced with command mlocate which has been a more sophisticated way of using it.

Syntax:

slocate [OPTION]... [FILE]....

Options of slocate command

1. NO Option: Prints files by the name.

Syntax :

slocate [FILE]

Example :

Search for a file named LICENSE

2. -0 Option: Separate the entries on output using the ASCII NUL character instead of writing each entry on a separate line.

Syntax :

slocate -0 [FILE]

Example :

Print search results other than separate

3. -i Option: Ignore case distinctions when matching patterns.

Syntax :

 slocate -i [FILE]

Example :

Search for results in a case insensitive manner

4. -c Option: Instead of writing file names on standard output, write the number of matching entries only.

Syntax :

slocate -c [FILE]

Example :

Count number of search results found

5. -l Option: Exit successfully after finding LIMIT entries.

Syntax :

slocate -l [NUMBER] [FILE]

Example :

Limit search result output to 3

My Personal Notes arrow_drop_up
Recommended Articles
Page :

Start Your Coding Journey Now!