Find Command Flashcards

1
Q

How to search all empty files under /opt?

A

find /opt -type f -size 0

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

How to search all files owned by the user "marry" on a Linux system and copy them into
/opt/marry?

A

mkdir /opt/marry then find / -type f -user marry -exec cp {} /opt/marry \;

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Find all files under “/var/log/” that are older than 90 days and delete them.

A

find /var/log -type f -mtime +90 -exec rm -f {} \;

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Search “0” byte files in /tmp directory, use appropriate command to delete these files?

A

find /tmp -
type f -empty -delete or find /tmp -type f -size 0 -exec rm -f {} \;

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

How to search files created in last ten days in the current working directory and copy these files
under /tmp directory?

A

find . -type f -mtime -10 -exec cp {} /tmp \;

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

How to find all the files that were modified in the last 20 mins under "/var/log/" directory?

A

find
/var/log -type f -mmin -20

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

How to find all the files that are older than 1 day under "/tmp," and remove them?

A

find /tmp -type
f -mtime +1 -delete or -exec rm -f {} \;

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Find all the files that are larger than 5 MB in your whole system.

A

find / -type f -size +5M

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

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.

A

find /home -type f -size +20M -exec ls -lh {} \;

How well did you know this?
1
Not at all
2
3
4
5
Perfectly