0
0
Linux CLIscripting~20 mins

df (disk free space) in Linux CLI - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Disk Space Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
💻 Command Output
intermediate
1:30remaining
Understanding the output of df -h
What is the output of the command df -h on a typical Linux system?
Linux CLI
df -h
AShows disk usage in human-readable format with sizes like 1K, 234M, 2G
BShows only the total disk size without usage details
CShows network usage statistics
DShows a list of running processes and their disk usage
Attempts:
2 left
💡 Hint
The -h option means human-readable sizes.
💻 Command Output
intermediate
1:30remaining
Output of df --total
What does the df --total command add to the usual df output?
Linux CLI
df --total
AShows only the total size of the root filesystem
BDisplays disk usage for network filesystems only
CAdds a summary line showing total disk usage across all filesystems
DShows disk usage sorted by mount point name
Attempts:
2 left
💡 Hint
Look for a line labeled 'total' at the end.
📝 Syntax
advanced
1:30remaining
Correct usage of df to show inode usage
Which command correctly shows inode usage with df?
Adf -i
Bdf --inodes
Cdf -h -i
Ddf --inode-usage
Attempts:
2 left
💡 Hint
The option for inode info is a short flag.
🔧 Debug
advanced
1:30remaining
Why does df /nonexistent fail?
What error does the command df /nonexistent produce and why?
Linux CLI
df /nonexistent
Adf: Invalid argument - because the path is not a mount point
Bdf: Permission denied - because the user lacks rights
Cdf: Device busy - because the path is in use
Ddf: /nonexistent: No such file or directory - because the path does not exist
Attempts:
2 left
💡 Hint
Check if the path exists before running df.
🚀 Application
expert
2:00remaining
Automate disk usage alert with df
You want to write a script that alerts you if any mounted filesystem is more than 90% full. Which command pipeline correctly extracts the usage percentage and filters filesystems over 90%?
Adf -h | grep -v Filesystem | awk '{if ($5 > 90) print $1, $5}'
Bdf -h | awk 'NR>1 {sub(/%/, "", $5); if ($5 > 90) print $1, $5"%"}'
Cdf | awk '{if ($5 > 90) print $1, $5}'
Ddf -h | awk '{if ($5+0 > 90) print $1, $5}'
Attempts:
2 left
💡 Hint
You need to remove the % sign before comparing numbers.