0
0
Linux CLIscripting~10 mins

mount and umount in Linux CLI - Step-by-Step Execution

Choose your learning style9 modes available
Concept Flow - mount and umount
Start
mount command
Check device and mount point
Mount device to mount point
Device accessible at mount point
umount command
Unmount device
Mount point freed
End
The flow shows mounting a device to a folder to access it, then unmounting to free the folder.
Execution Sample
Linux CLI
sudo mount /dev/sdb1 /mnt/usb
ls /mnt/usb
sudo umount /mnt/usb
Mounts a USB device, lists its contents, then unmounts it.
Execution Table
StepCommandActionResultOutput
1sudo mount /dev/sdb1 /mnt/usbMount device /dev/sdb1 to /mnt/usbSuccess if device and folder exist
2ls /mnt/usbList files in mounted device folderShows files/folders on USBfile1.txt file2.jpg folderA
3sudo umount /mnt/usbUnmount device from /mnt/usbMount point freed, device no longer accessible
💡 Unmount frees the mount point, device no longer accessible there
Variable Tracker
VariableStartAfter mountAfter lsAfter umount
/mnt/usb (mount point)empty foldermounted device accessiblefiles listedempty folder
Key Moments - 3 Insights
Why do we need to use 'sudo' with mount and umount?
Mounting and unmounting devices require admin rights to access hardware and system folders, as shown in execution_table steps 1 and 3.
What happens if you try to list files before mounting?
The folder would be empty or show local files, not the device contents. Execution_table step 2 shows listing after mount to see device files.
Can you unmount using the device name instead of the mount point?
Yes, but it's safer to use the mount point path as in step 3 to avoid mistakes. Both ways work but mount point is clearer.
Visual Quiz - 3 Questions
Test your understanding
Look at the execution table, what is the output of 'ls /mnt/usb' after mounting?
ANo such file or directory
Bempty folder
Cfile1.txt file2.jpg folderA
DPermission denied
💡 Hint
Check the Output column in row 2 of the execution_table.
At which step does the mount point become accessible with device files?
AStep 3
BStep 1
CStep 2
DBefore Step 1
💡 Hint
Look at the Result column in step 1 of execution_table.
If you skip 'sudo' in the mount command, what likely happens?
APermission denied error
BMount succeeds anyway
CDevice unmounts automatically
DFiles list shows empty folder
💡 Hint
Refer to key_moments about needing admin rights for mount (step 1).
Concept Snapshot
mount device_path mount_point
- Attaches device to folder to access files
- Requires admin rights (sudo)
- umount mount_point
- Detaches device, frees folder
- Use ls on mount_point to see files
Full Transcript
This lesson shows how to use mount and umount commands in Linux. First, you use 'sudo mount /dev/sdb1 /mnt/usb' to attach the device to the folder /mnt/usb. Then, you can list files inside that folder with 'ls /mnt/usb'. Finally, you unmount the device with 'sudo umount /mnt/usb' to free the folder. Mounting needs admin rights, so sudo is required. After unmounting, the folder is empty again. This process lets you access external devices safely.