Bird
Raised Fist0
Linux CLIscripting~10 mins

Why finding files saves time in Linux CLI - Test Your Understanding

Choose your learning style10 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to find all files named 'notes.txt' in the current directory and its subdirectories.

Linux CLI
find . -name [1]
Drag options to blanks, or click blank then click option'
A"notes.txt"
Bnotes.txt
C*.txt
D"notes"
Attempts:
3 left
💡 Hint
Common Mistakes
Not using quotes causes the shell to expand the pattern incorrectly.
Using a wildcard like '*.txt' finds all text files, not just 'notes.txt'.
2fill in blank
medium

Complete the code to find all files with '.log' extension modified in the last 7 days.

Linux CLI
find /var/log -name [1] -mtime [2]
Drag options to blanks, or click blank then click option'
A"*.log"
B-7
C7
D"log"
Attempts:
3 left
💡 Hint
Common Mistakes
Not quoting '*.log' causes shell to expand before find runs.
Using 'log' instead of '*.log' matches only files named exactly 'log'.
Using '7' instead of '-7' finds files modified exactly 7 days ago.
3fill in blank
hard

Fix the error in the command to find all files larger than 1MB in /home directory.

Linux CLI
find /home -size [1]
Drag options to blanks, or click blank then click option'
A1M
B+1M
C-1M
D1MB
Attempts:
3 left
💡 Hint
Common Mistakes
Using '1M' finds files exactly 1MB, not larger.
Using '1MB' is invalid syntax for find.
4fill in blank
hard

Fill both blanks to find all files owned by user 'alice' and print their names.

Linux CLI
find /home -user [1] -exec [2] {} \;
Drag options to blanks, or click blank then click option'
Aalice
Bls
Cecho
Dcat
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'ls' with -exec prints detailed info, not just names.
Using 'cat' tries to display file contents, which may be large or binary.
5fill in blank
hard

Fill all three blanks to create a dictionary of filenames and their sizes for files larger than 100KB.

Linux CLI
sizes = { [1]: [2] for [3] in $(find . -type f -size +100k) }
Drag options to blanks, or click blank then click option'
Afile
Bos.path.getsize(file)
Dfilename
Attempts:
3 left
💡 Hint
Common Mistakes
Using wrong variable names causes errors.
Not using os.path.getsize() returns wrong values.

Practice

(1/5)
1. Why is using the find command helpful when working with many files?
easy
A. It deletes all files automatically.
B. It compresses files to save disk space.
C. It opens files in a text editor.
D. It quickly locates files based on criteria, saving time.

Solution

  1. Step 1: Understand the purpose of find

    The find command searches for files matching specific criteria like name or size.
  2. Step 2: Recognize time-saving benefit

    By locating files quickly, it avoids manual searching through many folders.
  3. Final Answer:

    It quickly locates files based on criteria, saving time. -> Option D
  4. Quick Check:

    Finding files fast = It quickly locates files based on criteria, saving time. [OK]
Hint: Remember: find locates files fast by criteria [OK]
Common Mistakes:
  • Thinking find deletes files automatically
  • Confusing find with file editors
  • Assuming find compresses files
2. Which of these is the correct syntax to find files named report.txt in the current directory?
easy
A. find -name report.txt .
B. find . -name report.txt
C. find report.txt -name .
D. find . report.txt -name

Solution

  1. Step 1: Recall find command syntax

    The correct syntax is find [path] -name [filename].
  2. Step 2: Match syntax to options

    find . -name report.txt uses find . -name report.txt, which is correct.
  3. Final Answer:

    find . -name report.txt -> Option B
  4. Quick Check:

    Correct syntax = find . -name report.txt [OK]
Hint: Use: find [path] -name [filename] [OK]
Common Mistakes:
  • Placing -name after filename
  • Swapping path and name arguments
  • Omitting the dot for current directory
3. What will be the output of this command?
find /tmp -name '*.log' -size +1M

Assuming there are two files: /tmp/error.log (2MB) and /tmp/debug.log (500KB).
medium
A. /tmp/error.log
B. /tmp/debug.log
C. /tmp/error.log /tmp/debug.log
D. No output

Solution

  1. Step 1: Understand the command filters

    The command finds files in /tmp with names ending in .log and size greater than 1MB.
  2. Step 2: Check file sizes against criteria

    /tmp/error.log is 2MB (matches), /tmp/debug.log is 500KB (too small).
  3. Final Answer:

    /tmp/error.log -> Option A
  4. Quick Check:

    Only large .log files listed = /tmp/error.log [OK]
Hint: Size +1M means files larger than 1MB [OK]
Common Mistakes:
  • Including files smaller than 1MB
  • Ignoring the size filter
  • Assuming all .log files show
4. You run find /home -name '*.txt' -print but get an error: find: missing argument to `-name'. What is the likely cause?
medium
A. You typed -name without a pattern.
B. You used single quotes instead of double quotes.
C. You placed the path after the options.
D. You forgot to quote the pattern '*.txt'.

Solution

  1. Step 1: Analyze the error message

    The error says "missing argument to -name", meaning no pattern was given after -name.
  2. Step 2: Identify the cause

    This happens if -name is used without a following pattern string.
  3. Final Answer:

    You typed -name without a pattern. -> Option A
  4. Quick Check:

    Missing pattern after -name = You typed -name without a pattern. [OK]
Hint: Always provide a pattern after -name [OK]
Common Mistakes:
  • Assuming quotes cause the error
  • Thinking path order matters here
  • Ignoring the missing pattern
5. You want to find all files modified in the last 2 days and larger than 100KB in your Documents folder. Which command will save you the most time?
hard
A. find ~/Documents -mtime +2 -size -100k
B. find ~/Documents -mtime 2 -size 100k
C. find ~/Documents -mtime -2 -size +100k
D. find ~/Documents -mtime 2 -size +100k

Solution

  1. Step 1: Understand the time and size filters

    -mtime -2 means modified within last 2 days; -size +100k means larger than 100KB.
  2. Step 2: Match filters to options

    find ~/Documents -mtime -2 -size +100k correctly uses -mtime -2 and -size +100k.
  3. Final Answer:

    find ~/Documents -mtime -2 -size +100k -> Option C
  4. Quick Check:

    Recent and large files = find ~/Documents -mtime -2 -size +100k [OK]
Hint: Use -mtime -N for last N days, +size for larger files [OK]
Common Mistakes:
  • Using + instead of - for recent files
  • Confusing size units (k vs K)
  • Omitting + or - signs in filters
Recommended

Ready to prove it?

Pass the test and this pattern moves unknown strong while earning +1 Grip toward your certificate.

10 questions~5 mineasy hard