In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-01 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
Editor to share with you how to use the locate command in Linux, I believe most people do not know much about it, so share this article for your reference, I hope you can learn a lot after reading this article, let's go to know it!
Linux common command locate command allows users to quickly search for specified files in the file system
Locate is a better file lookup tool than find.
It is added that the method is to first establish a database that includes all the file names and paths in the system, and then when looking for it, you only need to query the database without actually going deep into the file system. In the general distribution, the establishment of the database is automatically executed in crontab.
Locate command can quickly find the file when searching the database, the database is updated by updatedb program, updatedb is built periodically by cron daemon, locate command searches the database faster than the entire hard disk data to search for information, but the worse thing is that the file found by locate may not be found if it was recently established or renamed, in the default value, updatedb will run once a day, you can modify the crontab to update the set value. (etc/crontab)
Locate is designated to be used to search for files that meet the criteria. It will store files and directory names in the database to find files or catalogs that meet the criteria of the template style. Special characters (such as "" or "?" can be used. If the template is specified as kcpaner, locate will find all files or directories that start with a string of kcpa and end with ner. If the name is kcpartner, if the directory name is kcpa_ner, it will list all files in the directory, including subdirectories.
Locate instruction and find search file function is similar, but locate is through the update program to build an index database of all files and directory information in the hard disk, in the implementation of loacte directly to find the index, the query speed will be faster, the index database is generally managed by the operating system, but you can also directly issue update to force the system to modify the index database immediately.
Syntax locate [Select parameters] [style] option-b,-- basename # matches only the basic name of the path name-c,-- count # outputs only the number of found-d,-- database DBPATH # uses the database specified by DBPATH Instead of the default database / var/lib/mlocate/mlocate.db-e,-- existing # prints only the entries of the current existing file-1 # if it is 1. Then start safe mode. In safe mode, users do not see files that cannot be seen by permissions. This starts to slow down because locate must go to the actual file system to obtain file permission data. -0,-- null # has a separate entry for NUL on the output-S,-- statistics # does not search for entries, prints statistics about each database-Q # quiet mode, and does not display any error messages. -P,-- nofollow,-H # check the existence of the file without following the symbolic link-l,-- limit,-n LIMIT # to limit the output (or count) to LIMIT entries-n # to display at most n outputs. -m,-- mmap # is ignored, for backward compatibility-- r,-- regexp REGEXP # uses the basic regular expression-- regex # uses the extended regular expression-Q,-- quiet # quiet mode, no error message-s,-- stdio # is ignored Specifies the name of the data inventory for backward compatibility with-o #. -h,-- help # displays help-I,-- ignore-case # ignores case-V,-- version # displays version information instance instance 1: find all files related to pwd
Root ~ # locate pwd / bin/pwd / etc/.pwd.lock / sbin/unix_chkpwd / usr/bin/pwdx / usr/include/pwd.h / usr/lib/python2.7/dist-packages/twisted/python/fakepwd.py / usr/lib/python2.7/dist-packages/twisted/python/fakepwd.pyc / usr/lib/python2.7/dist-packages/twisted/python/test/test_fakepwd.py / usr/lib/python2.7/dist-packages/twisted/python/test/test _ fakepwd.pyc / usr/lib/syslinux/pwd.c32 / usr/share/help/C/empathy/irc-join-pwd.page / usr/share/help/ca/empathy/irc-join-pwd.page / usr/share/help/cs/empathy/irc-join-pwd.page / usr/share/help/de/empathy/irc-join-pwd.page / usr/share/help/el/empathy/irc-join-pwd.page instance 2: search for all files that begin with sh in the etc directory
Root ~ # locate / etc/sh / etc/shadow / etc/shadow- / etc/shells instance 3: search all files starting with m in the etc directory
Root ~ # locate / etc/m / etc/magic / etc/magic.mime / etc/mailcap / etc/mailcap.order / etc/manpath.config / etc/mate-settings-daemon is all the contents of this article entitled "how to use locate commands in Linux". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow 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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.