Find Command Flashcards
How to search all empty files under /opt?
find /opt -type f -size 0
How to search all files owned by the user "marry" on a Linux system and copy them into
/opt/marry?
mkdir /opt/marry then find / -type f -user marry -exec cp {} /opt/marry \;
Find all files under “/var/log/” that are older than 90 days and delete them.
find /var/log -type f -mtime +90 -exec rm -f {} \;
Search “0” byte files in /tmp directory, use appropriate command to delete these files?
find /tmp -
type f -empty -delete or find /tmp -type f -size 0 -exec rm -f {} \;
How to search files created in last ten days in the current working directory and copy these files
under /tmp directory?
find . -type f -mtime -10 -exec cp {} /tmp \;
How to find all the files that were modified in the last 20 mins under "/var/log/" directory?
find
/var/log -type f -mmin -20
How to find all the files that are older than 1 day under "/tmp," and remove them?
find /tmp -type
f -mtime +1 -delete or -exec rm -f {} \;
Find all the files that are larger than 5 MB in your whole system.
find / -type f -size +5M
Find all the files in /home directory that are larger than 20MB and their owners, so we can notify
the users to manage them accordingly.
find /home -type f -size +20M -exec ls -lh {} \;