Find command __linux under Linux

Source: Internet
Author: User

Description:

Linux operating system to learn its foundation is familiar with the use of various basic operation commands, although many commands, but for beginners, the master of the common commands are few. For example: File operation commands (File,mkdir,grep,diff,find,cat,ls, etc.), system security commands (Passwd,who,su,chomd,chown,umask, etc.), System management commands (Kill,top,free, At, etc., network operation commands (IFCONFIG,IP,PING,FTP, etc.), there are some other commonly used commands (Man,tar,unzip,gunzip, etc.), mainly these sections, which belong to the file Operation command under the Find, which has a powerful indexing function, Linux is the "star", it is worth analyzing and analyzing.


★ Here is the CentOS6.5 version, first in the working directory to create a subdirectory named "Cmd1 and Cmd2", and in the directory to create several subfolders, easy to complete when the walkthrough to remove the freed resources.




※ Unlike other commonly used file Index command which/whereis/locate, find is powerful in its diversity of indexing methods, which are not matched by other index commands.


1.find (find-print): Prints the directory list and file name under the current directory.





2.find-name[file name]: matches the index based on the file name or regular expression, where name can be replaced with Iname (iname the file name for the index ignores case). Note: The suffix of a file in Linux, such as:. C,.txt, is a file name that differs from Windows to represent file types.

※ You can see that there is a direct print to the current directory, if not, nothing will be displayed, the description was not found.





3.find-name-a/-o/-not[file name]:-a expression and relationship,-o representation or relationship,-not represents the other file (the-not idea comes from the Demogan law)






4.find-path: Index The path name of the file as a parameter.





5.find-atime/ctime/mtime-[parameter]: A file that has not been accessed/accessed in the index parameter time, and the parameter is negative for access, which indicates that it is not accessed. Atime represents the most recent visit, Mtime said the most recent modification, ctime the most recent property modification, time of the day, can also be replaced by minutes and seconds.

★ Index files that have been accessed within 5 days of the current directory






6.find-type-[parameter]: Indexed according to file type. F,d,l,b,c,p,s correspond to ordinary files, directory files, link files, block device files, character device files, pipe files, socket files, respectively.







7.find-size [parameters]: Indexed according to file size. For example: 2M means equal to 2M size, -2m is less than 2m,+2m indicates greater than 2M size.






8.find-perm [parameters]: Indexed According to the permissions of the file. For example: 222 to find the current directory permissions only write files,-222 for all categories of users must meet write permissions, +222 for as long as the own,group,other have to satisfy the write permission.






9.find-nouser-a-nogroup: Find files that are neither owner nor group. ★ This kind of file is usually the intrusion system virus file (wild file), for the maintenance of system security is particularly important. Find/-nouser-a-nogroup is usually found under the root directory.






10.find-maxdepth/mindepth [parameters]: Based on the depth index under the current directory.

For example: Find.-maxdepth 1-type F: Index a normal file with a depth of 1 under the current directory, which can be combined with the above command, and 2 is a normal file with a downward index of 2 (depth 2).


※cmd3 is a cmd2 subdirectory, CMD4 is a subdirectory of cmd3.





11.find-newer [filename]: Finds the file created after this file.

※ You can see that you have found the Test.2 file that was created after Test.1.






12. When the find operation is performed, subsequent execution commands can be followed up.

commonly used are-ls: To print the display after the lookup,-ok [commend]: find to ask whether to execute the file,-exec [commend]: Skip the query and directly execute the found file.



Learning Tips:

          familiar with the basic operating commands used in Linux, in the subsequent system programming, follow-up projects, or system maintenance, these commands are handy, may be a little unfamiliar, However, a lot of practice is often used, plus the use of tap keys, this is not a thing. ..

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.