Identifying Available Disk Space

Learn how to identify available disk space in a directory.

Every file we save takes up additional disk space. Using the ls -lh command will tell us how much space the files in a directory consume, but it doesn’t give us a holistic view of the filesystem. The df and du commands will give us more insight into where our space is going. These commands represent disk space and usage in slightly different ways.

The df command

The df command looks at the filesystem metadata. It’ll show us the filesystem’s size, used space, available space, and where it’s mounted. By default, it shows everything in bytes. If we use the -h flag, we see all of the sizes represented clearly, similarly to how the -h flag worked for the ls command. Let’s execute the df -h command to see the results on our system:

$ df -h

Get hands-on with 1200+ tech skills courses.