2️⃣find command
Syntax - find [options] [path…] [expression]
1. Search file based on their size
find /path/ -size 50M
M for MB
k for KB
G for GB
c for bytes
2. Find a filetype in a given path
find /path/ -type f
f for file
d for directory
l for symbolic link
b for block device
s for socket
3. Ignore upper and lowercase in file name while searching files
find /path/ -iname <file_name>
4. Search files for a given user only
find /path/ -user root
5. Search a file based on their permissions
find /path/ -perm /u=r
find /path/ -perm 777
6. Search all files that start with letter `a`
find /path/ -iname a*
7. Search all files which are modified/created after last.txt file
find /path/ -newer last.txt
8. Search all empty files in a directory
find /path/ -empty
9. Find and delete empty files
find /path/ -empty -delete
10. Search all files whose size are between 1-50MB
find /path/ -size +1M -size -50M
11. Search 15 days old files
find /path/ -mtime 15
Last updated