Disk usage

2 snippets across 2 stacks - Bash & Linux, Docker

SHBash & Linux

Disk Space Usage

SH · System Info
Syntax
df [options] [filesystem]
Example
df -h
df -h /
df -hT
Output
Filesystem     Type  Size  Used Avail Use% Mounted on
/dev/sda1      ext4   50G   32G   16G  67% /
/dev/sdb1      xfs   200G  145G   55G  73% /data

Note -h for human-readable sizes. -T shows filesystem type. -i shows inode usage (you can run out of inodes even with free space if you have millions of tiny files). Check df regularly on servers to prevent disk-full outages.

DKDocker

Disk Usage Breakdown

DK · Debugging
Syntax
docker system df [-v]
Example
docker system df
docker system df -v
Output
TYPE            TOTAL     ACTIVE    SIZE      RECLAIMABLE
Images          15        5         4.2GB     2.8GB (66%)
Containers      8         3         125MB     95MB (76%)
Volumes         6         3         1.1GB     400MB (36%)
Build Cache     -         -         850MB     850MB

Note Quick overview of what is consuming disk. Add -v for a per-item breakdown. The RECLAIMABLE column shows how much you can free with prune commands.

Frequently asked questions

How does Bash & Linux handle disk usage?
This task is covered in 2 stacks on this page: Bash & Linux, Docker. The "Disk Space Usage" snippet in Bash & Linux uses `df [options] [filesystem]`.
Which command does the Bash & Linux example use?
The "Disk Space Usage" snippet uses `df [options] [filesystem]`, from the System Info section of the Bash & Linux cheat sheet.
Which stacks cover "disk usage" on this page?
Bash & Linux, Docker. Together they hold 2 copy-ready snippets for this task.
Is there anything to watch out for?
Yes. For "Disk Space Usage": -h for human-readable sizes. -T shows filesystem type. -i shows inode usage (you can run out of inodes even with free space if you have millions of tiny files). Check df regularly on servers to prevent disk-full outages.