Bird
0
0

You want to safely unmount all USB devices mounted under /media/usb*. Which script snippet correctly unmounts all such mounts?

hard📝 Application Q9 of 15
Linux CLI - Disk and Storage
You want to safely unmount all USB devices mounted under /media/usb*. Which script snippet correctly unmounts all such mounts?
Asudo umount /media/usb*
Bfor m in $(mount | grep '/media/usb' | awk '{print $3}'); do sudo umount "$m"; done
Cmount | grep '/media/usb' | umount
Dfor m in /media/usb*; do sudo umount $m; done
Step-by-Step Solution
Solution:
  1. Step 1: Extract mount points under /media/usb

    Using mount | grep '/media/usb' | awk '{print $3}' lists all mount point directories matching the pattern.
  2. Step 2: Loop and unmount each mount point

    The for loop iterates over each mount point and runs umount safely with sudo.
  3. Final Answer:

    for m in $(mount | grep '/media/usb' | awk '{print $3}'); do sudo umount "$m"; done -> Option B
  4. Quick Check:

    Loop over mount points and umount each [OK]
Quick Trick: Use mount + grep + awk to list mount points for umount loop [OK]
Common Mistakes:
  • Trying to umount with wildcard directly
  • Piping mount output directly to umount
  • Looping over directories without checking mounts

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Linux CLI Quizzes