0
0
Linux CLIscripting~5 mins

find by name, type, and size in Linux CLI - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
What does the find command do in Linux?
The find command searches for files and directories in a directory hierarchy based on conditions like name, type, or size.
Click to reveal answer
beginner
How do you use find to search for files by name?
Use find [path] -name "filename". For example, find . -name "report.txt" finds files named 'report.txt' in the current directory and subdirectories.
Click to reveal answer
beginner
What option do you use with find to search by file type?
Use -type followed by a letter: f for files, d for directories. Example: find . -type d finds directories.
Click to reveal answer
beginner
How can you find files larger than 1 megabyte using find?
Use -size +1M. For example, find . -size +1M finds files bigger than 1 megabyte.
Click to reveal answer
intermediate
Write a find command to find all regular files named 'log.txt' larger than 500 kilobytes.
Command: find . -type f -name "log.txt" -size +500k. This finds files named 'log.txt' that are regular files and bigger than 500 KB.
Click to reveal answer
Which find option searches for directories?
A-type d
B-name d
C-size d
D-type f
How do you find files named exactly 'data.csv' in the current directory and subdirectories?
Afind . -name "data.csv"
Bfind . -type f -size data.csv
Cfind . -type d -name "data.csv"
Dfind . -size +data.csv
What does -size +10M mean in a find command?
AFiles exactly 10 megabytes
BFiles larger than 10 megabytes
CFiles smaller than 10 megabytes
DFiles with 10 megabytes of free space
Which command finds all regular files larger than 100 kilobytes?
Afind . -name "100k"
Bfind . -type d -size +100k
Cfind . -size -100k
Dfind . -type f -size +100k
What does the command find /tmp -type f -name "*.log" -size -1M do?
AFinds log files larger than 1 MB in /tmp
BFinds all files in /tmp
CFinds log files smaller than 1 MB in /tmp
DFinds directories named '*.log' in /tmp
Explain how to use the find command to search for files by name, type, and size.
Think about combining options like -name, -type, and -size in one command.
You got /3 concepts.
    Describe a real-life scenario where you would use find with name, type, and size filters.
    Imagine managing files on your computer or server.
    You got /3 concepts.