Find command Summary and actual combat

Source: Internet
Author: User

Three kinds of time for files:

(1)atime: Access time, refers to the time at which thefile was last read, You can use the touch command to change to the current time;

  2 ctime change time chmod chgrp mv

(3)mtime: Modified time (modify), refers to the time the file content was last modified, Modify the action can make echo Redirect,vi and so on;

Find: Finding directories and files

Find path-command parameters [output FORM]


Parameter description:
path : Tell find where to find what you want,. Indicates the current directory,/represents the root directory
Command Parameters :

-name finds files by file name. 
-perm to find files by file permissions.
-prune uses this option to make the Find command not be found in the currently specified directory, and if the-depth option is used at the same time, the-prune option is ignored by the Find command.
-user finds files according to the owner of the file. The
-group the file according to the group to which the file belongs.
-mtime-n +n The file changes time to find the file,-n means that the file change time is now less than n days, +n indicates that the file change time is now N days ago. The Find command also has the-atime and-ctime options, but they are all similar to the-mtime option
, so we'll just describe the-mtime option here.
-nogroup finds a file that does not have a valid owning group, that is, the group to which the file belongs does not exist in/etc/groups.
-nouser finds a file without a valid owner, that is, the owner of the file does not exist in/etc/passwd.
-newer file1! File2 find changed time than file File1 new but older file than file file2.
-type finds a file of a certain type, such as:
B-block device file.
D-Directory. The
C-character device file.
P-pipe file. The
L-Symbolic link file.
F-Normal file.
S-socket file
-size N[c] finds files with a file length of n, with C indicating the length of the file in bytes.
-depth When looking for a file, first finds the file in the current directory and then finds it in its subdirectories.
-maxdepth Find the maximum number of directory layers, such as 1, that is, find only one level of directory
-fstype find files located in a type of file system, which can usually be found in the configuration file
/etc/fstab. This configuration file contains information about the file system in the system.
-mount does not cross the file system mount point when locating files.
-follow If the find command encounters a symbolic link file, it tracks to the file that the link points to.
-cpio Use the cpio command for matching files to back up these files to the tape device.

Output Form : Many output forms,-print,-printf,-print0,-exec,-ok,-ls

-print output of the found file to standard output

The-exec:find command executes the shell command given by the parameter to the matching file. The corresponding command is in the form of ' command ' {};, note the space between {} and;

-ok: The same as-exec, except that the shell command given by the parameter is executed in a more secure mode, prompting the user to determine whether to execute before executing each command.


See what the system has changed over the last 24 hours:

Find/-mtime 0

650) this.width=650; "src=" Http://s1.51cto.com/wyfs02/M01/80/4E/wKioL1c9mdygiXA6AAAbsnUMqLE101.png "title=" capture. PNG "alt=" Wkiol1c9mdygixa6aaabsnumqle101.png "/>

Find files under/etc, if newer than/etc/passwd list:

650) this.width=650; "src=" Http://s4.51cto.com/wyfs02/M00/80/50/wKiom1c9moCgJ_w-AAAt9G6iw3k825.png "title=" capture. PNG "alt=" Wkiom1c9mocgj_w-aaat9g6iw3k825.png "/>

Find out what changed in this directory in the last 24 hours:

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M01/80/50/wKiom1c9m6GgpchEAAAG-zugItI915.png "title=" capture. PNG "alt=" Wkiom1c9m6ggpcheaaag-zugiti915.png "/>

Search for files belonging to Funs under/home:

Find/home-user funs

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M01/80/4E/wKioL1c9oIDxq2p1AABfYE1WrGc124.png "title=" capture. PNG "alt=" Wkiol1c9oidxq2p1aabfye1wrgc124.png "/>

To find a document named code:

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M00/80/4E/wKioL1c9oc3TB8pRAAA7hr7HTaw806.png "title=" capture. PNG "alt=" Wkiol1c9oc3tb8praaa7hr7htaw806.png "/>

Find files with the file type socket type in the/var directory:

650) this.width=650; "src=" Http://s1.51cto.com/wyfs02/M01/80/50/wKiom1c9ocbBPpgfAABGSieht_4615.png "title=" capture. PNG "alt=" Wkiom1c9ocbbppgfaabgsieht_4615.png "/>

Search documents for files that contain sgid or suid or Sbit attributes:

650) this.width=650; "src=" Http://s5.51cto.com/wyfs02/M00/80/4E/wKioL1c9o5LStpZvAAAUwczoIXo140.png "title=" capture. PNG "alt=" Wkiol1c9o5lstpzvaaauwczoixo140.png "/>

List the last command with LS:

650) this.width=650; "src=" Http://s1.51cto.com/wyfs02/M01/80/50/wKiom1c9o1uTbttUAABzaT1Jkuo970.png "title=" capture. PNG "alt=" Wkiom1c9o1utbttuaabzat1jkuo970.png "/>

Find files larger than 1000k in/etc:

650) this.width=650; "src=" Http://s5.51cto.com/wyfs02/M02/80/4E/wKioL1c9pYjAJlwAAAAa6fqp5hg273.png "title=" capture. PNG "alt=" Wkiol1c9pyjajlwaaaaa6fqp5hg273.png "/>

To find the directory under the current directory:

650) this.width=650; "src=" Http://s1.51cto.com/wyfs02/M00/80/4E/wKioL1c9pmHCHjobAAA_jPccUKk862.png "title=" capture. PNG "alt=" Wkiol1c9pmhchjobaaa_jpccukk862.png "/>

Find /Home down to a files that begin with:

650) this.width=650; "src=" Http://s2.51cto.com/wyfs02/M01/80/5A/wKioL1c-oEjyx5F_AABa7prZWIU439.png "title=" Capture 1. PNG "alt=" Wkiol1c-oejyx5f_aaba7przwiu439.png "/>


will be find/var-name ap* The files found are written to file1 Medium:

650) this.width=650; "src=" Http://s4.51cto.com/wyfs02/M00/80/5A/wKioL1c-oNKCYcgQAAAHEe7l_Kk605.png "title=" Capture 1. PNG "alt=" Wkiol1c-onkcycgqaaahee7l_kk605.png "/>

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M02/80/5C/wKiom1c-n7jCW7JzAAAaXbrlNoE220.png "title=" Capture 1. PNG "alt=" Wkiom1c-n7jcw7jzaaaaxbrlnoe220.png "/>

Find / var down to AP beginning or m files that begin with:

650) this.width=650; "src=" Http://s4.51cto.com/wyfs02/M02/80/5A/wKioL1c-oQLBdNJ3AAA5kEBWAdI537.png "title=" Capture 1. PNG "alt=" Wkiol1c-oqlbdnj3aaa5kebwadi537.png "/>

Find out / var down to AP start and type files for the directory:

650) this.width=650; "src=" Http://s5.51cto.com/wyfs02/M02/80/5A/wKioL1c-oT-Tez_bAAAkysZSSls725.png "title=" Capture 1. PNG "alt=" Wkiol1c-ot-tez_baaakyszssls725.png "/>

Find find/home/funs/learn/test files accessed within the next day of the directory:

650) this.width=650; "src=" Http://s1.51cto.com/wyfs02/M01/80/5C/wKiom1c-oI2BP-aGAAAUKNsuNRQ758.png "title=" Capture 1. PNG "alt=" Wkiom1c-oi2bp-agaaauknsunrq758.png "/>


Find /home/funs/learn under - files that were changed before minutes

650) this.width=650; "src=" Http://s4.51cto.com/wyfs02/M00/80/5A/wKioL1c-objh4jABAAAQqxNPMGQ935.png "title=" Capture 1. PNG "alt=" Wkiol1c-objh4jabaaaqqxnpmgq935.png "/>

Find files that belong to funs in your system :

Find/-group Funs

650) this.width=650; "src=" Http://s1.51cto.com/wyfs02/M02/80/5C/wKiom1c-oPzCWOaOAABlBZKgOQA873.png "title=" Capture 1. PNG "alt=" Wkiom1c-opzcwoaoaablbzkgoqa873.png "/>




This article is from the "Fun" blog, make sure to keep this source http://10725723.blog.51cto.com/10715723/1775469

Find command Summary and actual combat

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.