Linux - “find” practical examples

Case 1: find the files modified within 24 hour
shell> find / -mtime 0
# 0 = the current time, so 24 hours from now.
# find / -mtime 3, so the files modifed 3 days ago (3*24 ~ 4*24 hours)

Case 2: find the files under /etc, if the files are newer than the file - /etc/passwd
shell> find /etc -newer /etc/passwd

Case 3: find the files under /home, owned by userabc
shell> find /home -user userabc

Case 4: find the files, nit owned by anybody
shell> find / -nouser

Case 5: find the file, named “passwd”
shell> find / -name passwd

Case the files with attribute “f”
shell> find /home -type f

Case 7: find the files with attribute SGID/SUID/SBIT
shell> find / -perm +7000
# 7000 = —s–s–t

Case 8: find the files with attribute SGID/SUID/SBIT, then display in “ls -l”
shell> find / -perm +7000 -exec ls -l {} \;
# {} = [the find results]
# \; = [the end of “-exec”]

Case 9: find the files larger than 1MB
shell> find / -size +1000k

Comments