0
0
Linux CLIscripting~5 mins

find command basics 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, size, or modification time.
Click to reveal answer
beginner
How do you use find to search for files named notes.txt in the current directory and its subdirectories?
Use find . -name "notes.txt". The dot . means start from the current directory.
Click to reveal answer
beginner
What option do you use with find to search only for directories?
Use -type d to find directories only. For example, find . -type d lists all directories.
Click to reveal answer
intermediate
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
What does the -exec option do in the find command?
It runs a command on each file found. For example, find . -name "*.log" -exec rm {} \; deletes all .log files found.
Click to reveal answer
Which command finds all files named report.txt starting from the current directory?
Afind -name report.txt
Bfind / -type d report.txt
Cfind report.txt -type f
Dfind . -name "report.txt"
What does find /home -type f -size +10M do?
AFinds directories larger than 10MB in /home
BFinds files larger than 10MB in /home
CFinds files smaller than 10MB in /home
DFinds all files in /home
How do you find all directories named backup?
Afind . -type d -name "backup"
Bfind . -type f -name "backup"
Cfind backup -type d
Dfind . -name "backup"
What is the purpose of the curly braces {} in find . -name "*.txt" -exec rm {} \;?
AIt is a placeholder for each found file
BIt represents the current directory
CIt ends the command
DIt is a wildcard for file names
Which option limits find to search only in the current directory, not subdirectories?
A-depth 0
B-mindepth 1
C-maxdepth 1
D-nodir
Explain how to use the find command to locate files by name and then delete them safely.
Think about searching files and running a delete command on each.
You got /5 concepts.
    Describe how to find all directories named 'config' starting from your home directory.
    Focus on directory type and name filtering.
    You got /5 concepts.