The du command shows the disk space used by files and directories. It helps you see how much space each folder or file takes.
Click to reveal answer
beginner
How do you display the disk usage of a directory in a human-readable format?
Use du -h directory_name. The -h option shows sizes in KB, MB, or GB, making it easier to understand.
Click to reveal answer
intermediate
What does the du -s option do?
The -s option summarizes the total disk usage of the directory without listing each subdirectory separately.
Click to reveal answer
intermediate
How can you find the top 5 largest directories using du?
Run du -h --max-depth=1 | sort -hr | head -5. This lists directories with sizes, sorts them from largest to smallest, and shows the top 5.
Click to reveal answer
beginner
Why might you use du instead of df?
du shows disk usage by directories and files, helping find space hogs. df shows free space on disks overall. Use du to find what uses space inside a disk.
Click to reveal answer
Which du option shows sizes in KB, MB, or GB?
A-a
B-s
C-h
D-c
✗ Incorrect
The -h option makes sizes human-readable by using KB, MB, or GB units.
What does du -s /home/user do?
AShows free disk space on /home/user
BLists all files in /home/user
CShows disk usage of each file in /home/user
DShows total disk usage of /home/user only
✗ Incorrect
-s summarizes total disk usage of the directory without details.
How do you limit du to show only the first level of subdirectories?
A--max-depth=1
B-h
C-a
D-s
✗ Incorrect
--max-depth=1 limits output to the directory and its immediate subdirectories.
Which command helps find the largest directories quickly?
Adu -s
Bdu -h --max-depth=1 | sort -hr | head -5
Cdf -h
Dls -lh
✗ Incorrect
This command lists sizes, sorts them largest first, and shows top 5 directories.
What is the main difference between du and df?
A<code>du</code> shows usage by directory; <code>df</code> shows disk free space
B<code>du</code> shows free space; <code>df</code> shows usage by directory
CBoth show the same information
DNeither shows disk usage
✗ Incorrect
du helps find space used inside directories; df shows overall disk free space.
Explain how to use du to find which directories use the most disk space in your home folder.
Think about showing sizes, limiting depth, sorting, and picking top results.
You got /5 concepts.
Describe the difference between du and df and when you would use each.
One looks inside folders, the other looks at the whole disk.
You got /4 concepts.
Practice
(1/5)
1. What does the du command primarily show in Linux?
easy
A. The disk space used by files and directories
B. The number of files in a directory
C. The current directory path
D. The list of running processes
Solution
Step 1: Understand the purpose of du
The du command stands for disk usage and shows how much space files and directories use.
Step 2: Compare options
Options B, C, and D relate to other commands like ls or ps, not du.
Final Answer:
The disk space used by files and directories -> Option A
Quick Check:
du = disk space used [OK]
Hint: Remember: du = disk usage, shows space used [OK]
Common Mistakes:
Confusing du with ls or ps commands
Thinking du shows file counts
Assuming du shows current directory path
2. Which du command option shows sizes in a human-readable format?
easy
A. -s
B. -c
C. -a
D. -h
Solution
Step 1: Identify the option for human-readable sizes
The -h option makes sizes easier to read by adding units like K, M, G.
Step 2: Understand other options
-s summarizes, -a shows all files, -c adds a total line.
Final Answer:
-h -> Option D
Quick Check:
-h = human-readable sizes [OK]
Hint: Use -h for sizes like KB, MB, GB [OK]
Common Mistakes:
Using -s expecting human-readable sizes
Confusing -a or -c with size formatting
Omitting the -h option for readability
3. What is the output of the command du -sh /var/log if the /var/log directory uses 120M of disk space?
medium
A. 120M
B. 120M /var/log
C. 120MB /var/log
D. 120 /var/log
Solution
Step 1: Understand the command options
-s summarizes total size, -h shows human-readable format.
Step 2: Predict output format
The output shows size with unit, a tab, then directory path: "120M\t/var/log".
Final Answer:
120M /var/log -> Option B
Quick Check:
du -sh output = size + tab + path [OK]
Hint: du -sh shows size and path separated by tab [OK]
Common Mistakes:
Omitting the tab separator
Writing size without unit
Showing size without path
4. You run du -h /home/user but get an error: "du: invalid option -- 'h'". What is the likely cause?
medium
A. The directory /home/user does not exist
B. You need to run the command as root
C. The du command does not support the -h option on this system
D. You must use --human-readable instead of -h
Solution
Step 1: Analyze the error message
The error says -h is invalid, meaning this du version lacks that option.
Step 2: Check other options
Running as root or directory existence wouldn't cause invalid option error; -h is standard, no need for long form.
Final Answer:
The du command does not support the -h option on this system -> Option C
Quick Check:
Invalid option error means unsupported flag [OK]
Hint: Invalid option means your du version lacks that flag [OK]
Common Mistakes:
Assuming permission or path errors cause invalid option
Trying --human-readable instead of checking version
Ignoring error message details
5. You want to find the total disk usage of all subdirectories inside /home/user but only see sizes for individual files. Which command correctly summarizes each subdirectory size in human-readable form?
hard
A. du -sh /home/user/*
B. du -ah /home/user
C. du -h /home/user
D. du -s /home/user
Solution
Step 1: Understand the goal
You want sizes of each subdirectory summarized, not individual files.
Step 2: Analyze options
du -ah shows all files and dirs, du -sh on directory alone summarizes total only, du -s no human-readable. du -sh /home/user/* summarizes each subdirectory separately in human-readable form.
Final Answer:
du -sh /home/user/* -> Option A
Quick Check:
Use du -sh with wildcard for each subdir [OK]
Hint: Use du -sh with * to summarize each subdirectory [OK]
Common Mistakes:
Using -a to include files instead of just dirs
Using -s alone for total only
Not using wildcard to list subdirectories
Recommended
Ready to prove it?
Pass the test and this pattern moves unknownstrongwhile earning +1 Grip toward your certificate.