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.
du -sh /var/logCorrect. 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.
free -h /var/logIncorrect. 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 / 読み取り操作
- Prefer help or version output and a disposable device when testing storage commands.
- Formatting, repair, and mount changes can affect data or availability.
Foundation review
Place the operation
Directory usage and filesystem free space are related but measured at different layers.
Check the side effect
Account for permissions, sparse files, and open deleted files when interpreting totals.