Calculate the total space used by files and subdirectories under /var/log.
Print one human-readable summary value.
Which command is appropriate?
du -sh PATH recursively summarizes the space occupied by a directory tree. df instead reports capacity for the whole filesystem.
Detailed explanation
du -sh /var/logCorrect. du -sh /var/log prints a human-readable summary for the directory tree.
Correct. du -sh /var/log prints a human-readable summary for the directory tree.
df -h /var/logIncorrect. df reports the filesystem containing the path, not just the directory tree.
Incorrect. df reports the filesystem containing the path, not just the directory tree.
df -i /var/logIncorrect. df -i reports inode usage.
Incorrect. df -i reports inode usage.
fsck /var/logIncorrect. fsck checks filesystem consistency.
Incorrect. fsck checks filesystem consistency.
Try it yourself
An example you can run in a temporary verification environment.
du -sh /var/log 2>/dev/nullExpected result
/var/logの合計使用量とパスKey points
- du aggregates file usage
- -s means summary
- -h uses readable units
Notes
- Environment: GNU coreutils 9.x
- Command output formatting can vary slightly by distribution or tool version.
- Run the example in a temporary directory or process when possible.
Foundation review
Read the scope first
Check whether the command acts on the current shell, a new process, an existing process, or a file.
Verify the observable result
Use the supplied command and compare the output with the expected result.