The Linux find command uses the tutorial

  

whereis command to find executable files, binary files, man documentation, and source code files.

The locate command is to find the target from the index database (/var/lib/mlocate/mlocate.db) generated by the updatedb command. As long as the database record contains the searched characters, the record will be listed, but Regularly run the updatedb command to update the database to ensure the real-time content.

The which command is looked up from the path of the system environment variable. Can be used to find executables and aliases.

The find command has more powerful features. Syntax: find [path] [expression] The default path is the current directory, the default expression is -print.

(N can be +N or -N or N):-amin N-anewer FILE-atime N-cmin N-cnewer FILE-ctime N-empty-false-fstype TYPE-gid N-group NAME -ilname PATTERN-iname PATTERN-inum N-iwholename PATTERN-iregex PATTERN-links N-lname PATTERN-mmin N-mtime N-name PATTERN-newer FILE-nouser-nogroup-path PATTERN-perm [+-]MODE-regex PATTERN -wholename PATTERN-size N[bcwkMG]-true-type [bcdpflsD]-uid N-used N-user NAME-xtype [bcdpfls]-context CONTEXT

1, user and group lookup group ID is N file: find /-gid N

Find the file with the group name NAME: find /-group NAME

Find the file with user ID N: find /-uid N

Find the file named NAME: find /-user NAME

Find files for users that do not exist in the /etc/passwd file: find /-nouser

Find not The files of the group existing in the /etc/group file: find /-nogroup

2, time search to find files accessed within N days: find /-atime N

Find N Changed state file within days: find /-ctime N

Find files modified within N days: find /-m Time N

Find new files that are newer than a FILE in the current directory: find /-newer FILE

Find files that are newer than a FILE access time in the current directory: Find /-anewer FILE

Find files accessed in the last N minutes of the system: find /-amin N

Find files in the system that have changed state in the last N minutes: find /- Cmin N

Find the files modified in the last N minutes of the system: find /-mmin N

3, name and attribute look for the file named PATTERN: find /-name PATTERN

Find a file of size N: find /-size N

Find a file of type: find /-type [bcdpflsD]b - block device file c - character device file d - directory p - Pipe file f - Normal file l - Symbol link file

4. Execute the shell command format after searching: -exec COMMAND ;-exec COMMAND {} + -ok COMMAND ; Add -exec after the find command , plus spaces, plus the command or script to be executed, add a pair of {}, add a space and a \\, and finally a semicolon.

Find a file of size 0 in the /var/log directory and delete: find /var/log -size 0 -exec rm -rf {} \\;



Copyright © Windows knowledge All Rights Reserved