In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-25 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/02 Report--
This article mainly introduces the use of locate instructions, the article is very detailed, has a certain reference value, interested friends must read it!
The locate instruction is used to find files or directories. The locate command is much faster than [find-name] because it does not search specific directories, but searches a database. The syntax is [locate [OPTION]. [PATTERN]...] .
Locate directive:
1. Brief introduction to the command
The locate (locate) command is used to find a file or directory. The locate command is much faster than find-name because instead of searching for specific directories, it searches for a database / var/lib/mlocate/mlocate.db. This database contains all the local file information. The Linux system automatically creates this database and automatically updates it once a day, so when we look for files with whereis and locate, we sometimes find the data that has been deleted, or just created the file, but can not find it, because the database file has not been updated. To avoid this, you can manually update the database using the updatedb command before using locate. The whole locate work is actually made up of four parts:
/ usr/bin/updatedb is mainly used to update the database, which is done automatically by crontab
/ usr/bin/locate query file location
Configuration file for / etc/updatedb.conf updatedb
/ var/lib/mlocate/mlocate.db A file that stores file information
2. Usage
Locate [OPTION]... [PATTERN]...
3. Options
-b,-- basename match only the basename of path names-c,-- count only outputs 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 only print entries for currently existing files-L,-- follow follow trailing symbolic links when checking file existence (default)-h,-- help shows help-I,-- ignore-case ignores case-l,-- limit,-n LIMIT limit output (or counting) to LIMIT entries-m -- mmap ignored, for backward compatibility-P,-- nofollow,-- H don't follow trailing symbolic links when checking file existence-0,-- null separate entries with NUL on output-S,-- statistics don't search for entries, print statistics about eachused database-Q,-- quiet quiet mode No error message will be displayed-r,-- regexp REGEXP uses basic regular expressions-- regex uses extended regular expressions-s,-- stdio ignored, for backward compatibility-V,-- version displays version information-w,-- wholename match whole path name (default)
4. Example
Example 1: search for all files that start with my in the etc directory
[root@cent6 lib] # locate / etc/my/etc/my.cnf
Example 2: the new file cannot be locate, use updatedb
[root@cent6 ~] # touch new.txt [root@cent6 ~] # locate new.txt [root@cent6 ~] # updatedb [root@cent6 ~] # locate new.txt/root/new.txt
Configuration file / etc/updatedb.conf for sample 3:updatedb
[root@cent6 ~] # cat / etc/updatedb.conf PRUNE_BIND_MOUNTS = "yes" PRUNEFS = "9p afs anon_inodefs auto autofs bdev binfmt_misc cgroup cifs coda configfs cpuset debugfs devpts ecryptfs exofs fuse fusectl gfs gfs2 hugetlbfs inotifyfs iso9660 jffs2 lustre mqueue ncpfs nfs nfs4 nfsd pipefs proc ramfs rootfs rpc_pipefs securityfs selinuxfs sfs sockfs sysfs tmpfs ubifs udf usbfs" PRUNENAMES = ".git .hg .svn" PRUNEPATHS = "/ afs / media / net / sfs / tmp / udev / var/cache/ccache / var/spool/cups / var/spool/squid / var/tmp "above is all the content of what the locate instruction is for. Thank you for reading! Hope to share the content to help you, more related 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.