![]() ![]() The where is command can only be used to search for binary (- b), source (- s), and description (- m). So when using locate, execute the updatedb command first 3. Also, when deleting a file whose information is already in the database, updatedb can still search for the information of the file by using locate, even though the file no longer exists Note: every time a new file is updated or deleted, the file information saved in the database before updatedb will not change, that is, after a new file is added, the specified file cannot be searched by locate before updatedb. scripts]# echo "I love linux" scripts]# locate locatetest #Before updating the scripts]# find -name scripts]# updatedb #After updating the scripts]# locate scripts]# rm -f locatetest #After deleting scripts]# find -name scripts]# locate scripts]# locate scripts]# So you can't search for the latest updated file by using the locate command, unless you manually use the updatedb command before using the locate command to find the file New database. Updatedb is periodically established by cron daemon. The database is updated by updatedb program. This database is automatically created by linux system. The secondary database contains all the information of the local file. Because it does not search for specific directories, it searches for the specified files in a database (/ var/lib/locatedb). The locate command is actually another way to write "find name", but the search method is different from find, which is much faster than find. nouser looks for a file without a valid owner, that is, the owner of the file does not exist in / etc/passwd 2. nogroup: find the file without a valid group, that is, the group to which the file belongs does not exist in / etc/group Type: find a type of file (b: block device file d: directory file c: character device file p: pipeline file l: link file f: normal file) ![]() mtime -n n: find the file according to the file modification time, - N means the file modification time is within n days from now, n means the file modification time is within n days from now ![]() The default action is - print, that is, no results are filtered, that is, all files are output. Note: when the find command does not add any parameters, it means that the search path is the current directory and its subdirectories. Because parentheses are not recognized directly on the command line, escape characters \, with spaces before and after. įind / \( -path /usr/bin -o -path /etc \) -prune -o -name "passwd" -print #To find a file named passwd under the current directory and its subdirectories (except the / usr/bin directory and its subdirectories / etc directory and its subdirectories). usr -prune -o -name "passwd" -print #To find a file named passwd under the current directory and its subdirectories (except the / usr directory and its scripts]# cp /etc/passwd. etc -prune -o -name "passwd" #Distinguish between with - print parameter and without - print /]# find. etc -prune -o -name "passwd" -print #To find a file named passwd in the current directory and its subdirectories (except the / etc directory and its /]# find. Let's see the function of - prune /]# find -name "passwd" # To find a file named passwd in the current directory and its /]# find. prune: do not find in the currently specified directoryįor example, it is known that there is a file named passwd in the directory / etc, / etc/pam.d and / user/bin. Pathname: pathname is the search directory and its subdirectories. The general format of the find command is: find, that is, find pathname -options Find is the most commonly used and powerful find command, which can find any type of file. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |