How to Check Disk Space in Linux

May 8, 2024


Knowing how to check disk space in Linux is essential for maintaining system health and stability. It prevents performance issues, application failures, and potential data loss caused by low disk space.

The following text elaborates on different ways to check disk space in Linux.

Tutorial on checking available disk space in Linux


  • A Linux system (this tutorial uses Ubuntu 22.04).
  • Access to the terminal.
  • A user account with sudo or root privileges.

Disk Space Check in Linux: 5 Methods

Performing disk space checks in Linux ensures enough storage is available for system operations and application usage. The following text presents common ways to check disk space in Linux.

Method 1: Check Disk Space via df Command

The df (disk free) command lets you check disk space in Linux and shows the amount of space taken up by different drives. Run the following:

df terminal output

By default, df displays values in 1-kilobyte blocks.

The output has several columns:

  • Filesystem. The structure used to organize data. This includes physical hard drives, logical (partitioned), and virtual or temporary drives.
  • 1K-blocks. The filesystem size displayed as 1 kilobyte blocks.
  • Used. The amount of space used on each filesystem.
  • Available. The amount of unused (free) space on the filesystem.
  • Use%. The percentage of the disk used.
  • Mounted on. The directory where the filesystem is located.

Note: Learn how to preallocate space for a file using the fallocate command.

Display Usage in Megabytes and Gigabytes

To modify the df command and display disk usage in a more human-readable format, add the -h option:

df -h
df -h terminal output

This displays the size in megabytes (M) and gigabytes (G).

Display a Specific Filesystem

The df command can also display a specific filesystem. For example, run the following to show the usage on the primary hard drive:

df -h /
df -h / terminal output

Note: The df command only targets a full filesystem. Even if you specify an individual directory, df reads the space of the whole drive.

Display Filesystems by Type

Filesystem types define how data is organized, stored, and accessed on a storage device. There are many filesystem types, each designed for a specific purpose.

For example, to list filesystems with the ext4 type, use the command:

df -ht ext4
df -ht ext4 terminal output

The command lists drives with the ext4 type in human-readable format. This type is a widely used filesystem with features like journaling and support for large file sizes and partitions.

Method 2: Check Disk Space via the du Command

The du command displays disk usage for individual directories in Linux. Use it to display the amount of space used by the current directory:

du terminal output

Like the df command, du can be human-readable:

du -h
du -h terminal output

It prints the current directory contents and how much space they're using in kilobytes, megabytes, and gigabytes.

Method 3: Check Disk Space via the pydf Command

pydf is a Python-based command that provides a colorful and human-readable output of disk space usage on Linux. It is designed as an alternative to the standard df command. Run the following command to check disk space:

pydf terminal output

Method 4: Check Disk Space via the fdisk -l Command

While fdisk focuses on displaying disk partition details. It includes details about disk sizes and provides general information about disk capacity. Run the following command to check disk space:

sudo fdisk -l
sudo fdisk -l terminal output

Method 5: Check Disk Space via the lsblk Command

The lsblk command lists information about block devices, including disks and their partitions. To test the tool, run the following:

terminal output for lsblk

While lsblk does not provide detailed disk usage info, the output shows a hierarchical view of block devices, including their names, major and minor numbers, sizes, read-only statuses, types, and mount points.

To determine the overall unallocated space on the drive, sum up the sizes of all partitions and then compare the total with the drive's total size.


This article explained how to check disk space in Linux using five different methods.

Next, learn how to use the fsck command to run a filesystem check as preventive maintenance or when there is an issue with your system.

Was this article helpful?
Sara Zivanov
Sara Zivanov is a technical writer at phoenixNAP who is passionate about making high-tech concepts accessible to everyone. Her experience as a content writer and her background in Engineering and Project Management allows her to streamline complex processes and make them user-friendly through her content.
Next you should read
How to Start, Stop, and Restart Services in Linux
March 27, 2024

In most modern Linux operating systems, managing a service is quite simple when it comes to basic commands...
Read more
How to Use the su Command in Linux with Examples
April 16, 2024

Learn how to use the su command with practical examples and explanations. Change users in the terminal window...
Read more
How to Use rsync to Exclude Files and Directories in Data Transfer
March 3, 2020

Rsync is a Linux tool that allows you to transfer files to another location. You can customize the command...
Read more
How to Get the Size of a Directory in Linux
February 8, 2024

Use the command line interface to display directory size and for display disk space. This guide will help you...
Read more