0
0
Linux CLIscripting~20 mins

find by name, type, and size in Linux CLI - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Find Mastery Badge
Get all challenges correct to earn this badge!
Test your skills under time pressure!
💻 Command Output
intermediate
1:30remaining
Find files named 'report.txt' of type regular file
What is the output of this command if the current directory contains exactly one regular file named 'report.txt' and no other files with that name?

find . -name 'report.txt' -type f
Linux CLI
find . -name 'report.txt' -type f
A./report.txt
B
./report.txt/
./report.txt
Creport.txt
DNo output
Attempts:
2 left
💡 Hint
The command finds regular files named exactly 'report.txt' in the current directory and subdirectories.
💻 Command Output
intermediate
1:30remaining
Find directories named 'backup' larger than 1MB
What will this command output if there is one directory named 'backup' with size 2MB and one file named 'backup' with size 3MB?

find . -name 'backup' -type d -size +1M
Linux CLI
find . -name 'backup' -type d -size +1M
A./backup/file.txt
B
./backup
./backup/file.txt
CNo output
D./backup
Attempts:
2 left
💡 Hint
The command looks for directories named 'backup' larger than 1MB, not files.
📝 Syntax
advanced
2:00remaining
Correct find command to locate regular files named '*.log' smaller than 500KB
Which option is the correct find command to locate regular files with names ending in '.log' and size less than 500KB?
Afind . -name '*.log' -type f -size -500k
Bfind . -name '*.log' -type f -size +500k
Cfind . -type f -name '*.log' -size -500k
Dfind . -name '*.log' -type d -size -500k
Attempts:
2 left
💡 Hint
Order of options does not matter, but size sign and type must be correct.
🔧 Debug
advanced
2:00remaining
Why does this find command fail to find files larger than 1MB?
Given this command:

find /data -type f -name '*.csv' -size +1M

It returns no results even though there are CSV files larger than 1MB. What is the most likely reason?
Linux CLI
find /data -type f -name '*.csv' -size +1M
AThe size option counts 512-byte blocks, so '+1M' means files larger than 1*512 bytes
BThe '+1M' means files larger than 1MB, so it should be '-1M' to find larger files
CThe size unit 'M' is case sensitive and should be lowercase 'm'
DThe command is correct; the files are probably smaller than 1MB
Attempts:
2 left
💡 Hint
Check how the find command interprets size units by default.
🚀 Application
expert
2:30remaining
Find all empty directories named 'temp' and delete them safely
Which command will find all empty directories named 'temp' under /var/log and delete them safely, prompting before each deletion?
Afind /var/log -type d -name 'temp' -empty -delete
Bfind /var/log -type d -name 'temp' -empty -exec rm -ri {} +
Cfind /var/log -type d -name 'temp' -empty -exec rm -r {} \;
Dfind /var/log -type d -name 'temp' -empty -exec rm -i {} \;
Attempts:
2 left
💡 Hint
You want to delete directories safely with confirmation and only empty ones named 'temp'.