In UNIX 'du' usage, which option displays the number of blocks used by a file (summarized usage)?
-
A-c
-
B-i
-
C-d
-
D-s
-
ENone of the above
Answer
Correct Answer: -s
Explanation
Introduction / Context:The du (disk usage) command reports filesystem usage in blocks or human-readable units. Choosing the correct option lets administrators quickly summarize consumption by a file or directory, which is crucial for quota checks and cleanup tasks on multi-user systems.
Given Data / Assumptions:
- We are referring to standard du behavior (POSIX-like).
- Goal: summarize the number of blocks used (not a recursive detailed list).
- Options presented mimic common du switches.
Concept / Approach:
du -s prints a summary for each argument—effectively the total blocks used by that file or directory, instead of listing every subentry. Other switches: -c adds a grand total line, -i (on some platforms) reports inode usage, and -d limits depth (GNU extension), but none replace the summary role of -s.
Step-by-Step Solution:
Identify the need: single summary of blocks used.Map requirement to du option: -s (summary).Note alternatives provide different behaviors (totals, inodes, depth).Choose -s.Verification / Alternative check:
Example: du -s /var/log outputs a single number and path, representing total blocks used by /var/log, confirming the summary behavior.
Why Other Options Are Wrong:
- -c: adds cumulative total but still lists entries unless combined with -s.
- -i: inode counts, not blocks.
- -d: depth limit; not a summary by itself.
- None of the above: incorrect because -s is correct.
Common Pitfalls:
- Confusing du with ls -s, which shows per-file block sizes.
- Forgetting human-readable option (-h) for MB/GB formatting when needed.
Final Answer:
-s.