Linux Command Summary --find command

find brief order

Linux Linux system Find command is one of the most important and most frequently used commands. Find command to search for and find files and directories based on the file list with the parameters that match the specified criteria. Find can be used in a variety of conditions, you can find files by permission possible conditions, users, groups, file type, date, size and so on.

Find common usage in Linux

·find   path   -option   [   -print ]   [ -exec   -ok   command ]   {} \;

find the parameters of the command;

pathname: directory path to find the command you are looking for. For example. To indicate the current directory, / root system is represented.
-print: the output file will match the find command to standard output.
-exec: find command to execute shell commands given by the parameter file match. Form of these commands to 'command' {} \ ;, and attention {} \; space between.
-ok: -exec action and the same, but in a more secure mode to execute shell commands given by the parameter before executing each command will prompt allows users to determine whether to execute.

# -print the searched file to standard output
# -exec command {} \; - found in the command file execution operation, and {} \; space between
the same and # -ok -exec, but before the operation to the user query

-name filename # find a file called filename
-perm # by executing authority to find
-user username # by file owner to find
-group groupname # in groups to find
-mtime -n + n # by file to change the time to find the file , -n refers to within n days, + n n refers days ago
-atime -n + n # by file access times to check GIN: 0px ">

Before -ctime -n + n # by file creation time to find the file, -n refers to within n days, + n refers to n days

-nogroup # investigation file without a valid genus group is a group that is not present in the file / etc / groups in

-nouser # investigation file without a valid owner, i.e. the owner of the file does not exist in the / etc / passwd in
-newer f1! f2 to find the file, -n means within n days, n refers to the n + ago 
-ctime -n + n # by file creation time to find the file, -n refers to within n days, + n n refers days ago 
-nogroup # check file without a valid belong to the group, that is a group of files in / etc / groups do not exist in
-nouser # check without a valid owner of the file, that is the main document does not exist in / etc / passwd in
-newer f1! f2 # check for changes longer than f1 f2 than the new but the old files
-type b / d / c / p / l / f # search block device, directory, character devices, pipes, symbolic links, normal file
-size n [c] # search block length n [n bytes or] file
-depth # make finding before entering subdirectory Find first complete catalog
-fstype # check for changes longer than f1 f2 than the new but the old files
-type b / d / c / p / l / f # Charles is a block device, directory, character equipment, pipes, symbolic links, general file
-size n [c] Check block length n # [n bytes or] file
-depth # make finding before entering subdirectory complete catalog look-ahead
-fstype # check files that are located a certain type of file system, the file system type is usually in the / etc / fstab found
not check files across when -mount # file system mount points
-follow # If you have a symbolic link file, trace file link within the meaning of
-cpio%; # check files that are located a certain type of file system, the file system type is usually in the / etc / fstab found
do not cross when -mount # check file system mount points
-follow # If you have a symbolic link file, you trace file link within the meaning of
-cpio # matching files using cpio command, they will be backed up to a tape device in
-prune # ignore a directory
-amin # find the file in the system last-minute visit N
-mmin # N minutes to find the last modified file in the system


Through this article, we share our daily experiences and how to use Linux Find command in the form of examples. In this article, we'll show you an example of the Find command Linux 35 most commonly used. We refer to this section is divided into five parts, from basic to use the find command in advance.

  • Part I: Find the name of the file to find the basic search command
  • Part II: find files based on their permissions
  • Part III: Search for files based on the owner and group
  • Part IV: find files and directories based on the date and time
  • Part V: according to the size of the find files and directories
Basic Find command to find the name of the file to find - the first part

1. Use the name of the current directory to find the file

Find the name of all files test.c in the current working directory.

 

2. Find the file in your home directory

Find all files in the / home directory named test.


(The above two front find no permissions)

3. Find the file name and neglect cases

Find the names of all the files for the test and contains both uppercase and lowercase letters in the / home directory.

 

4. Use the directory name lookup

Look for a test of all directories in the / directory.

 

5. Use PHP file name lookup

Find all PHP file named test.PHP in the current working directory.

 

6. Find all PHP files in the directory

Find all php files in the directory.

 

The second part - to find files based on their permissions

7. Find the file permissions 777

Find all the permissions to 777 files

 

8. Find a file does not have 777 permissions

Find all files without permission 777.

 

9. Find SGID file has 644 permissions

Find all SGID permissions set to 644-bit files.

 

10. Locate the sticky bit file has 551 permissions

Find all Sticky Bit set permissions for the file 551.

 

11. Find SUID file

Find all SUID set files.

 

12. Find SGID file

Find all SGID settings file

 

13. Find a read-only file

Find all read-only files.

 

14. Find the executable file

Find all executable files.

 

15. The rights and found 777 to 644 Chmod file

Find all 777 permission to file and use the chmod command to set the permissions to 644

 

16. Locate the directory has 777 permissions and Chmod to 755

Find all 777 permission to the directory and use the chmod command to set the permissions to 755.

 

17. Find and delete individual files

Find a file called test.c and delete them

 

18. Find and delete multiple files

Find and delete multiple files, such as .mp3 or .txt, then use.

 

19. Find all the empty file

Find all the empty files in a particular path.

 

20. Find all empty directories

All the empty directories under a specific path archive.

 

21. All documents hidden files

To find all the hidden files, use the following command.

 

Part III - based owner and group search files

22.查找基于用户的单个文件

在所有者root的/ root目录下查找名为test.c的所有或单个文件。

 

23.查找基于用户的所有文件

查找~目录下属于用户neil的所有文件。

 

24.查找基于组的所有文件

查找/ home目录下属于Group Developer的所有文件。

 

25.查找用户的特定文件

查找~目录下的用户neil的所有.txt文件

 

第四部分 - 根据日期和时间查找文件和目录

26.查找最近50天修改的文件

查找50天后修改的所有文件。

 

27.查找最近50天访问的文件

查找50天后访问的所有文件。

 

28.查找最后50-100天修改的文件

查找所有被修改超过50天以及少于100天的文件。

 

29.在过去1小时内查找更改的文件

查找最近1小时内更改的所有文件

 

30.在最近1小时内查找修改的文件

查找最近1小时内修改的所有文件。

 

31.查找最近1小时内访问的文件

查找最近1小时内访问的所有文件。

 

第五部分 - 根据大小查找文件和目录

32.找到50MB的文件

要找到所有50MB的文件,请使用。

 

33.查找大小在50MB到100MB之间

找到大于50MB且小于100MB的所有文件。

 

34.查找并删除100MB的文件

查找所有100MB文件并使用一个命令删除它们。

 

35.查找特定文件并删除

查找超过10MB的所有.mp3文件,并使用一个命令删除它们

来自于

 
马哥教育Python课程总监,独爱Python。

Guess you like

Origin www.cnblogs.com/hanjiali/p/11685148.html