Bird
Raised Fist0
Linux CLIscripting~20 mins

mount and umount in Linux CLI - Practice Problems & Coding Challenges

Choose your learning style10 modes available
Challenge - 5 Problems
🎖️
Mount Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
💻 Command Output
intermediate
2:00remaining
What is the output of the mount command after mounting a USB drive?
You run the command sudo mount /dev/sdb1 /mnt/usb to mount a USB drive. Then you run mount | grep /mnt/usb. What output do you expect?
Linux CLI
sudo mount /dev/sdb1 /mnt/usb
mount | grep /mnt/usb
ANo output
B/mnt/usb on /dev/sdb1 type vfat (rw,nosuid,nodev,noexec,relatime,uhelper=udisks2)
Cmount: /mnt/usb: special device /dev/sdb1 does not exist
D/dev/sdb1 on /mnt/usb type vfat (rw,nosuid,nodev,noexec,relatime,uhelper=udisks2)
Attempts:
2 left
💡 Hint
Remember the output format of the mount command shows device first, then mount point.
💻 Command Output
intermediate
2:00remaining
What error occurs when unmounting a busy mount point?
You try to unmount a mounted directory with sudo umount /mnt/usb but the directory is in use by a process. What error message will you see?
Linux CLI
sudo umount /mnt/usb
Aumount: /mnt/usb: target is busy.
Bumount: /mnt/usb: no such file or directory.
Cumount: /mnt/usb: device not mounted.
Dumount: /mnt/usb: permission denied.
Attempts:
2 left
💡 Hint
Think about what happens if a directory is open or used by a program when you try to unmount it.
📝 Syntax
advanced
2:00remaining
Which command correctly mounts a device with read-only option?
You want to mount /dev/sdc1 to /media/backup with read-only access. Which command is correct?
Asudo mount -o ro /dev/sdc1 /media/backup
Bsudo mount -ro /dev/sdc1 /media/backup
Csudo mount /media/backup /dev/sdc1 -o ro
Dsudo mount /dev/sdc1 /media/backup -o ro
Attempts:
2 left
💡 Hint
The options must come immediately after mount command and before device and mount point.
🚀 Application
advanced
3:00remaining
How to safely unmount all USB drives mounted under /media?
You want to unmount all USB drives currently mounted under /media. Which command sequence will do this safely?
Asudo umount /media/*
Bmount | grep '/media' | awk '{print $3}' | xargs -r sudo umount
Csudo umount $(mount | grep '/media' | cut -d' ' -f1)
Dmount | grep '/media' | cut -d' ' -f3 | sudo umount
Attempts:
2 left
💡 Hint
Think about extracting mount points and passing them safely to umount.
🧠 Conceptual
expert
2:00remaining
What happens if you mount a device on a non-empty directory?
You mount /dev/sdd1 on /mnt/data, but /mnt/data already contains files. What is the effect on those files?
AThe mount command will fail with an error about non-empty directory.
BThe existing files are merged with the mounted device's files.
CThe existing files become hidden and inaccessible until the device is unmounted.
DThe existing files are deleted automatically to allow mounting.
Attempts:
2 left
💡 Hint
Think about how mounting overlays the mount point directory.

Practice

(1/5)
1. What does the mount command do in Linux?
easy
A. It formats a storage device for use.
B. It connects a device or filesystem to a directory so you can access its files.
C. It disconnects a device from the system safely.
D. It lists all files in a directory.

Solution

  1. Step 1: Understand the purpose of mount

    The mount command attaches a device or filesystem to a directory, making its files accessible.
  2. Step 2: Differentiate from umount and other commands

    Umount disconnects devices, formatting prepares devices, and listing files is done by ls, not mount.
  3. Final Answer:

    It connects a device or filesystem to a directory so you can access its files. -> Option B
  4. Quick Check:

    Mount = Connect device to directory [OK]
Hint: Mount = connect device to folder, umount = disconnect [OK]
Common Mistakes:
  • Confusing mount with umount
  • Thinking mount formats devices
  • Assuming mount lists files
2. Which of the following is the correct syntax to mount a device /dev/sdb1 to directory /mnt/usb?
easy
A. mount -u /dev/sdb1 /mnt/usb
B. mount /mnt/usb /dev/sdb1
C. umount /dev/sdb1 /mnt/usb
D. mount /dev/sdb1 /mnt/usb

Solution

  1. Step 1: Recall mount command syntax

    The correct syntax is mount [device] [mount_point], so device first, then directory.
  2. Step 2: Check options for correctness

    mount /dev/sdb1 /mnt/usb matches the syntax: mount /dev/sdb1 /mnt/usb. Others reverse order or use wrong command.
  3. Final Answer:

    mount /dev/sdb1 /mnt/usb -> Option D
  4. Quick Check:

    mount device directory = correct syntax [OK]
Hint: Device first, then directory in mount command [OK]
Common Mistakes:
  • Swapping device and directory order
  • Using umount instead of mount
  • Adding wrong options like -u
3. What will be the output of the command sequence below if /dev/sdb1 is already mounted on /mnt/usb?
mount /dev/sdb1 /mnt/usb
mount | grep /mnt/usb
medium
A. /dev/sdb1 on /mnt/usb type ext4 (rw,relatime)
B. mount: /mnt/usb is busy
C. mount: /dev/sdb1 is already mounted
D. No output

Solution

  1. Step 1: Understand mounting an already mounted device

    Running mount on an already mounted device usually remounts or shows no error, depending on system, but the second command lists mounts.
  2. Step 2: Analyze the grep output

    The command mount | grep /mnt/usb shows the current mount info for that directory, typically like /dev/sdb1 on /mnt/usb type ext4 (rw,relatime).
  3. Final Answer:

    /dev/sdb1 on /mnt/usb type ext4 (rw,relatime) -> Option A
  4. Quick Check:

    mount | grep shows mount info [OK]
Hint: mount | grep shows current mounts [OK]
Common Mistakes:
  • Expecting error when mounting already mounted device
  • Confusing mount error messages
  • Ignoring output of grep command
4. You try to unmount a device with umount /mnt/usb but get the error: umount: /mnt/usb: target is busy. What is the best way to fix this?
medium
A. Close any open files or terminals using /mnt/usb, then try umount again.
B. Force unmount with umount -f /mnt/usb immediately.
C. Reboot the system to clear the busy state.
D. Delete the /mnt/usb directory and try umount again.

Solution

  1. Step 1: Understand 'target is busy' error

    This error means some process is using files or directories inside /mnt/usb, blocking unmount.
  2. Step 2: Proper fix is to close those processes

    Close open files, terminals, or programs accessing /mnt/usb, then run umount again safely.
  3. Final Answer:

    Close any open files or terminals using /mnt/usb, then try umount again. -> Option A
  4. Quick Check:

    Busy means in-use; close files before umount [OK]
Hint: Close files using mount point before umount [OK]
Common Mistakes:
  • Forcing unmount without checking usage
  • Deleting mount directory instead of unmounting
  • Rebooting unnecessarily
5. You want to write a script that mounts a USB device /dev/sdb1 to /mnt/usb, copies a file data.txt to it, then safely unmounts it. Which sequence of commands is correct?
hard
A. umount /mnt/usb && mount /dev/sdb1 /mnt/usb && cp data.txt /mnt/usb/
B. cp data.txt /mnt/usb/ && mount /dev/sdb1 /mnt/usb && umount /mnt/usb
C. mount /dev/sdb1 /mnt/usb && cp data.txt /mnt/usb/ && umount /mnt/usb
D. mount /mnt/usb /dev/sdb1 && cp data.txt /mnt/usb/ && umount /mnt/usb

Solution

  1. Step 1: Mount device before copying files

    You must mount the device first to access its filesystem, so mount command comes first.
  2. Step 2: Copy file then unmount safely

    After copying, unmount to safely disconnect device. The sequence is mount, copy, then umount.
  3. Final Answer:

    mount /dev/sdb1 /mnt/usb && cp data.txt /mnt/usb/ && umount /mnt/usb -> Option C
  4. Quick Check:

    Mount -> copy -> umount sequence [OK]
Hint: Mount first, copy files, then unmount [OK]
Common Mistakes:
  • Copying files before mounting
  • Unmounting before copying
  • Swapping device and directory in mount
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