Free space

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

System-Wide Cleanup

DK · Debugging
Syntax
docker system prune [options]
Example
docker system prune
docker system prune -a --volumes
Output
Total reclaimed space: 5.7GB

Note Without flags: removes stopped containers, unused networks, dangling images, and build cache. With -a: also removes all unused images (not just dangling). With --volumes: also removes unused volumes. This is the nuclear option - it can delete data you care about.

Frequently asked questions

How does Bash & Linux handle free space?
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 "free space" 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.