Calculate one readable total for all data below /var/log.
Which command is appropriate?
du -sh PATH recursively summarizes directory usage, with -s for one total and -h for readable units.
Detailed explanation
df -h /var/logIncorrect. df reports the capacity of the whole filesystem containing /var/log.
Incorrect. df reports the capacity of the whole filesystem containing /var/log.
du -sh /var/logCorrect. du -sh /var/log prints one readable total for the directory tree.
Correct. du -sh /var/log prints one readable total for the directory tree.
ls -lh /var/logIncorrect. ls -lh shows immediate entries rather than a recursive total.
Incorrect. ls -lh shows immediate entries rather than a recursive total.
free -h /var/logIncorrect. free reports memory usage, not directory usage.
Incorrect. free reports memory usage, not directory usage.
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 files and directories
- -s means summary
- -h means human-readable
Notes
- Environment: GNU coreutils du / 読み取り操作
- 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.