CloudsArk
Commands Linux

du -sh Explained

Understand what du -sh means, how to break it down, and when to use it safely.

du -sh Explained

Introduction

This article explains a common du usage that administrators and learners often need to understand clearly.

What This Command Means

The command performs this specific task with du:

du -sh /var/log

Breaking Down the Command

  • du is the command being run.
  • The options or arguments decide the behavior.
  • The final value is the target, such as a file, process, service, package, host, URL, or directory.

Practical Examples

du -sh /var/log
du -h --max-depth=1 /var
df -h /var

Example output:

1.4G    /var/log

When to Use It

Use du when you need to find which directories or files are consuming space inside a filesystem. It complements df during disk-full troubleshooting.

Common Mistakes

  • Running du across huge trees without limiting depth.
  • Comparing du and df without considering deleted open files.
  • Forgetting -x when you want to stay on one filesystem.

Safer Alternatives

Inspect before changing state when possible:

df -h /var

For wider changes, test on a small target before using the command broadly.

Summary

Understanding du -sh is about knowing what each part does and checking the final state after running it.