0
0
Linux CLIscripting~20 mins

fdisk and lsblk in Linux CLI - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Disk Mastery Badge
Get all challenges correct to earn this badge!
Test your skills under time pressure!
💻 Command Output
intermediate
2:00remaining
What is the output of this lsblk command?
You run the command lsblk -o NAME,SIZE,TYPE,MOUNTPOINT on a system with one disk sda of 100G and two partitions sda1 (50G, mounted on /) and sda2 (50G, not mounted). What is the output?
Linux CLI
lsblk -o NAME,SIZE,TYPE,MOUNTPOINT
A
NAME   SIZE TYPE MOUNTPOINT
sda    100G part 
sda1    50G disk /
sda2    50G part 
B
NAME   SIZE TYPE MOUNTPOINT
sda    100G disk /
sda1    50G part 
sda2    50G part 
C
NAME   SIZE TYPE MOUNTPOINT
sda    50G disk 
sda1    50G part /
sda2    50G part 
D
NAME   SIZE TYPE MOUNTPOINT
sda    100G disk 
sda1    50G part /
sda2    50G part 
Attempts:
2 left
💡 Hint
Remember that the disk is the whole device and partitions are parts of it. Only partitions can be mounted.
💻 Command Output
intermediate
2:00remaining
What error does this fdisk command produce?
You run fdisk /dev/sdx on a system where /dev/sdx does not exist. What error message appears?
Linux CLI
fdisk /dev/sdx
Afdisk: permission denied
Bfdisk: invalid partition table
Cfdisk: cannot open /dev/sdx: No such file or directory
Dfdisk: device is busy
Attempts:
2 left
💡 Hint
Check if the device file exists before running fdisk.
📝 Syntax
advanced
2:00remaining
Which fdisk command sequence creates a new primary partition?
You want to create a new primary partition on /dev/sdb using fdisk interactively. Which sequence of commands inside fdisk is correct?
Linux CLI
fdisk /dev/sdb
# Then enter commands interactively
Ap (print), n (new partition), e (extended), 1 (partition number), w (write)
Bn (new partition), p (primary), 1 (partition number), default start, default end, w (write)
Cd (delete), n (new partition), l (logical), 1 (partition number), w (write)
Dn (new partition), l (logical), 1 (partition number), default start, default end, q (quit)
Attempts:
2 left
💡 Hint
Primary partitions are created with 'p' after 'n'.
🚀 Application
advanced
2:00remaining
How to list only disks (not partitions) with lsblk?
You want to list only the disks (not their partitions) on your system using lsblk. Which command achieves this?
Alsblk -d
Blsblk -p
Clsblk -a
Dlsblk -l
Attempts:
2 left
💡 Hint
The option '-d' shows only disks, no children.
🧠 Conceptual
expert
2:00remaining
What is the effect of running 'fdisk -l' without root privileges?
You run fdisk -l as a normal user without sudo. What happens?
Linux CLI
fdisk -l
AIt shows 'Permission denied' error and no output.
BIt prompts for root password to continue.
CIt lists only partitions on removable devices.
DIt lists all partitions and disks without error.
Attempts:
2 left
💡 Hint
fdisk needs root to read disk info.