참고 자료: https://bit.ly/3DTvDpA
Example 1: Check Find command version
find -version
Example 2: Find all the files Only created in last 40 mins
find /home/example -type f -cmin -40
-cmin n: File’s status was last changed n minutes ago.
-type f: regular file
Example 3: Find all the files Only modified in last 40 mins
find /home/example -type f -mmin -40
-mmin n: File’s data was last modified n minutes ago.
Example 4: Find all the files Only accessed in last 40 mins
find /home/example -type f -amin -40
-amin n: File was last accessed n minutes ago
Example 5: Find all the files and directories created in last 40 mins
find /home/example -cmin -40
Example 6: Find all the files and directories modified in last 40 mins
find /home/example -mmin -40
Example 7: Find all the files and directories accessed in last 40 mins
find /home/example -amin -40
Example 8: Find all the files only created in last 40 mins
find /home/example -type f -cmin -40
Example 9: Find all the files only modified in last 40 mins
find /home/example -type f -mmin -40
Example 10: Find all the files only accessed in last 40 mins
find /home/example -type f -amin -40
Example 11: Find all the created files and directories older than 40 mins
find /home/example -cmin +40
Example 12: Find all the modified files and directories older than 40 mins
find /home/example -mmin +40
Example 13: Find all the accessed files and directories older than 40 mins
find /home/example -amin +40
Example 14: Find all the created files only in last 5 days
find /home/example -type f -mtime -5
-mtime n: File’s data was last modified n*24 hours ago.
Example 15: Find all the modified files only older than 5 days
find /home/example -type f -mtime +5
Example 16: Find all the files and directories modified in last 5 days
find /home/example -mtime -5
Example 17: Find all the modified files and directories older than 5 days
find /home/example -mtime +5
Example 18: Find a file “test.txt” at the maxdepth of level 2
find /home/example/ -maxdepth 2 -name test.txt
-maxdepth levels: Descend at most levels (a non-negative integer) levels of directories below the starting-points
Example 19: Find a file “test.txt” at the mindepth of level 2
find /home/example/ -mindepth 2 -name test.txt
-mindepth levels: Do not apply any tests or actions at levels less than levels(a non-negative integer)
Example 20: Find a file test.txt between mindepth of 2 and maxdepth of 4
find /home/example -mindepth 2 -maxdepth 4 -name test.txt
Example 21: Find all the files created by User “example”
find /home -user example
Example 22: Find all Empty Files
find /home/example -empty
-empty: File is empty and is either a regular file or a directory
Example 23: Find all Executable Files and Directories
find /home/example -executable
-executable: Matches files which are executable and directories which are searchable (in a file name resolution sense) by the current user.
Example 24: Find all Executable Files Only
find /home/example -type f -executable
Example 25: Find all Empty Files Only
find /home/examples -type f -empty
Example 26: Find all the Case Insensitive match pattern
find /home/example -iname File1
-iname pattern: Like -name, but the match is case insensitive
Example 27: Find all the files on ext4 filesystem
find . -fstype ext4
-fstype type: File is on a filesystem of type ext4
Example 28: Find all the files with group name test
find /home/example -group test
-group gname: File belongs to group gname (numeric group ID allowed)
Example 29: Find all the files which does not belong to any known group
find . -nogroup
-nogroup: No group corresponds to file’s numeric group ID.
Example 30: Find all the files which does not belong to any known User
find . -nouser
-nouser: No user corresponds to file’s numeric user ID.
Example 31: Find all the files by their Group ID
find /home/example -group 500
Example 32: Find all the files by their User ID
find /home/example -user 500
-user uname: File is owned by user uname (numeric user ID allowed
Example 33: Find all the files which are either executable by User or by Group
find /home/example -perm /u=x,g=x
-perm -mode: Any of the permission bits mode are set for the file. Symbolic modes are accepted in this form. You must specify u',
g’ or `o’ if you use a symbolic mode.
Example 34: Find all the files which are executable by both User and Group
find /home/example -perm -g+w,u+w
-perm -mode: All of the permission bits mode are set for the file. Symbolic modes are accepted in this form, and this is usually the way in which you would want to use them. You must specify u',
g’ or `o’ if you use a symbolic mode
Example 35: Find all files and directories having execute permission
find /home/example -perm /111
Example 36: Find all the files created between last 5-10 days
find . -ctime -10 -ctime +5
Example 37: Find all the files accessed between last 5-10 days
find . -atime -10 -atime +5
Example 38: Find all the files modified between last 5-10 days
find . -mtime -10 -mtime +5
Example 39: Find all the files which is either readable by User or by Group
find /home/example -perm /u=r,g=r
Example 40: Find all the files which is readable by both User and Group
find /home/example -perm -g+r,u+r
Like this:
Like Loading...