Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to use the locate command of Linux

2025-01-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/01 Report--

Most people don't understand the knowledge points of this article "how to use the locate command of Linux", so Xiaobian summarizes the following contents for everyone. The contents are detailed, the steps are clear, and they have certain reference value. I hope everyone can gain something after reading this article. Let's take a look at this article "how to use the locate command of Linux".

Linux common command locate command is used to find qualified documents, he will save documents and directory names in the database, find documents or directories that meet the template style conditions.

syntax locate [-d ][--help][--version][template style...] Parameters:

-b, -basename -matches only the base name of the pathname

-c, -count -outputs only the number found

-d, -database DBPATH -Use DBPATH specified database instead of default database/var/lib/mlocate/mlocate.db

-e, -existing -Print only entries for the current existing file

-1 -If yes 1. Start safe mode. In safe mode, users do not see files that are not visible to them. This initially slows down because locate must get permission information for the file in the actual file system.

-0, -null -Separate entry with NUL on output

-S, -statistics -Print statistics about each database without searching for entries

-q -Quiet mode, no error messages are displayed.

-P, -nofollow, -H -Check if file exists Do not follow trailing symbolic links

-l, -limit, -n LIMIT -Limit output (or count) to LIMIT entries

-n -Displays at most n outputs.

-m, -mmap -omitted for backward compatibility

-r, -regexp REGEXP -Use basic regular expressions

- regex -Use extended regular expressions

-q, -quiet -Quiet mode, no error messages are displayed

-s, -stdio -omitted for backward compatibility

-o -Specifies the name of the data store.

-h, -help -Show help

-i, -ignore-case -ignore case

-V, -version -Display version information

Example Find the passwd file and enter the following command:

locate passwd Search all files starting with sh in etc directory:

locate /etc/sh Ignore case Search all files starting with r in the current user directory:

locate -i ~/r Additional note locate is different from find: find is to find the hard disk, locate is only found in the/var/lib/slot database.

locate is faster than find, it is not really looking up, but looking up the database, the general file database is in/var/lib/slocate/slocate.db, so locate is not real-time, but subject to the update of the database, generally maintained by the system itself, you can also manually upgrade the database, the command is:

updatedb By default updatedb is executed once a day.

The above is the content of this article about "how to use the locate command of Linux". I believe everyone has a certain understanding. I hope the content shared by Xiaobian will be helpful to everyone. If you want to know more relevant knowledge, please pay attention to the industry information channel.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report