How to Check Disk Space in Linux

As a Linux user or administrator, knowing how much space you have left on your drive is vital to ensuring the health of your system. Fortunately, Linux provides plenty of tools, both command line and GUI-based, to find the space you have accessible on your drive and disk utilization.

Note: For this guide, we’re using three separate systems for this article:

  • Ubuntu LTS 22.04 — an Ubuntu-based distro derived from Debian.
  • Rocky Linux 8.5 —  an RHEL- CentOS-based distro.
  • EndeavourOS  an Arch-based distro.

Except for the installation commands apt, yum, and pacman, all other Linux commands used in this article are distro-independent, meaning they will work on any Linux distro.

Check Disk Space from the GUI

All distros and desk environments have a default GUI tool to check your disk space. Let’s look at the default GUI tools for GNOME and KDE environments.

GNOME Desktop Environment

The default GUI Tool to check disk utilization on Linux distros using GNOME as their desktop environment is Disks (gnome-disk).

To launch Disks:

  1. Click the Applications or Activities icon.
  2. Enter disk in the Search box.
  3. Click the Disks icon.

    Search for disks and select the Disk icon.
    Search for disks and select the Disk icon.
  4. Click the system disk in the left-hand column (in this case, 256 GB Disk).

    Display disk usage via Disks (gnome-disk).
    Display disk usage via Disks (gnome-disk).
  5. Click the Linux Filesystem partition (usually the largest partition). The drive’s size and the amount of free space (in both gigabytes and percentage) are shown below the graphical view of the disk’s partitions. You can see in the example that the disk size is 256 GB with 173 GB free. The disk is 32.5% full.

KDE Desktop Environment

The default GUI tool to check disk utilization on Linux distros using KDE as their desktop environment is the Info Center tool.

To launch Info Center:

  1. From the Applications menu, select System and then Info Center.

    From the Activities menu, select elect System and then Info Center.
    From the Applications menu, select elect System and then Info Center.
  2. At the Device Viewer — Info Center window, select Devices from the left-hand column.

    Select devices.
    Select devices.
  3. Next, select Device Viewer from the left-hand menu and expand Hard Disk Drive under Devices.

    Select Device Viewer and Expand Hard Disk Drives.
    Select Device Viewer and Expand Hard Disk Drives.
  4. Select the primary partition (usually sda1) from the expanded Hard Disk Drive list.

    Select the disk (sda1 to display disk space and percentage of disk space free.
    Select the disk (sda1) to display disk space and the percentage of disk space free.
  5. You can see in the example that there is 10.1 GB free out of 15.4 GB, and 34% of the drive is being used.

Disk Usage Analyzer (formerly known as Baobab)

The Disk Usage Analyzer tool, originally named Baobab, is one of the best GUI tools to check disk space utilization. The tool is so popular that it is automatically included in most Linux distros using the GNOME desktop environment.

To launch the Disk Usage Analyzer:

  1. Launch the Applications or Activities menu.
  2. Select the Utilities icon from the list of applications.

    Double-click the Utilities icon.
    Double-click the Utilities icon.
  3. Double-click the Disk Usage Analyzer icon.

    Double-click the Disk Usage Analyzer icon.
    Double-click the Disk Usage Analyzer icon.
  4. At the Devices & Locations window, click the primary hard disk (in this case, mtr-Ubuntu-LTS-22.04)

    Click the primary hard disk.
    Click the primary hard disk.
  5. The Linux filesystems disk usage will be displayed in graphical format, along with file sizes of the directories in the filesystem. Hover your mouse over various sections of the circular graph to see what directory or directories they represent.

    The Disk Usage Analyzer provides a detailed graphical view of the Linux systems disk usage.
    The Disk Usage Analyzer provides a detailed graphical view of the Linux system’s disk usage.

How to install the Disk Usage Analyzer Analyzer Tool

If the Disk Usage Analyzer tool is not included on your Linux distro, installing the tool from the command line is straightforward.

Note that you need superuser (root) privileges to run these commands.

To install Disk Usage Analyzer on Debian- and Ubuntu-based distros, type the following command from the command line:

# apt install baobab
Install the Disk Usage Analyzer on Ubuntu- and Debian-based systems.
Install the Disk Usage Analyzer on Ubuntu- and Debian-based systems.

To install Disk Usage Analyzer on RHEL- and CentOS-based distros, type the following command from the command line:

# yum install baobab
Install the Disk Usage Analyzer tool on RHEL- CentOS-based distros.
Install the Disk Usage Analyzer tool on RHEL- CentOS-based distros.

To install Disk Usage Analyzer on Arch-based distros, type the following command from the command line (note that we first update the system’s repositories with the pacman -Syu command):

# pacman -Syu
# pacman -S baobab
Install the Disk Usage Analyzer tool on Arch-based systems.
Install the Disk Usage Analyzer tool on Arch-based systems.

Other Tools to Check Disk Space

There are other Linux tools users can install to check disk space usage:

  • xdiskusage
  • Duc
  • JDiskReport
  • QDirStat
  • Ncurses Disk Usage (ncdu)

A simple Google search will find the homepages of these tools and detailed instructions on how to install them for your particular Linux distro.

Check Disk Space from the Command Line

All Linux distros provide built-in tools to check disk space usage using the Command-Line. du, df, and fdisk (in coordination with the lsblk command).

Note that all commands featured below must be run with superuser (root) privileges.

du Command Line Tool

The du (disk usage) command provides Linux users with the estimated file usage of the system disk. Of all of the command-line tools for reporting disk space usage, the du command is the quickest and provides the most relevant data for most Linux users.

du Command Purpose, Syntax, and Options

Linux users can check disk usage information of files and directories on a machine with the du command. The syntax of the du command is:

# du [options] [file]

There are several options included with the du command that provide Linux users with relevant information concerning their disk usage. Note the options we will use with the du command in our example:

  • -h – print sizes in a human-readable format.
  • -x – skip directories on different systems.
  • -c  – produce a grand total.

more Command Purpose and Syntax

The more command is a file perusal filter typically used by piping (I), the output of another command. Piping allows you to send the output of one command to another command. The “|” symbol, also known as the vertical bar, is used to pipe the commands.

The syntax of the more command is:

# more [options] file

Real-Life Scenario – du

  1. Launch the terminal.
  2. Navigate to the root (/) directory so that all directories on the Linux filesystem are listed with the du command:
    # cd /
  3. List all file directories and their size piped with the more command:
    # du -h -x -c | more
    Use the du command, piped with the more commanmd, to list directory sizes and the total disk space used.
    Use the du command, piped with the more command, to list directory sizes and the total disk space used.

    Note: you can use the du command without piping to the more command to get to the total disk size much quicker. We piped it in our example for visualization.

  4. Press the space bar until you reach the end of the du command output. The space bar allows you to advance the output one screen at a time.

    Use the du command, piped with the more commanmd, to list directory sizes and the total disk space used.
    Use the du command, piped with the more command, to list directory sizes and the total disk space used.
  5. The total disk space used is displaced at the end of the du command (in this instance, it’s 73 GB).

df Command Line Tool

The df command reports the Linux file system disk space usage.

df Command Purpose, Syntax, and Options

df displays the Linux filesystem disk space usage. The syntax of the df command is:

# df [option] [file]

There are several options included with the df command that provide Linux users with relevant information concerning disk usage of the filesystem. Note the options we will use with the df command in our example:

  • -H – print sizes in powers of 1000 (e.g., 1.1G).
  • –total – omit all entries insignificant to available space, and produce a grand total.

Real-Life Scenario – df

  1. Launch the terminal.
  2. To display Linux filesystem usage in powers of 1000 (e.g., 1.7G) and provide the size of the disk, how much disk space is used, how much disk space is available, and the percentage of disk space used.
    # df -H --total

    Use the df command to list the total disk space on a disk, as well as percentage of the disk used.
    Use the df command to list the total disk space on a disk and the percentage of the disk used.
  3. At the bottom of the output, we can see our drive is 236 GB, disk space used is 79 GB, available disk space is 172 GB, and 32% of the disk is in use.

lsblk and fdisk Command Line Tools

To best utilize the fdisk command to report the filesystem’s disk usage, we must use the lsblk command to get relevant information needed for the fdisk command, specifically the disk name.

lsblk Command Purpose, Syntax, and Options

Use the lsblk command to display all blocks (including disks and partitions) on a Linux filesystem. The syntax of the lsblk command is:

# lsblk [options] [device]

The only option you need to use with the lsblk command is the -l option which outputs the result of the lsblk command in list format.

Real-Life Scenario – lsblk

To list blocks (including disks and partitions) on the system:

  1. Launch the terminal.
  2. List all blocks (including disks and partitions):
    # lsblk -l

    Use the lsblk command to list block devices (including disks) on a Linux system.
    Use the lsblk command to list block devices (including disks) on a Linux system.
  3. The disk name and size are listed near the bottom of the command output. In this instance, the disk name is nvme0n1 and is 238.5 GB.
  4. Take note of the disk name, nvme0n1, as we will need it in the next section for the fdisk command.

Check Disk Space Using the fdisk Command

Warning: using the fdisk command with any options other than those specified below (-l) can damage your hard drive.

fdisk Command Purpose, Syntax, and Options

Use the fdisk command to display all blocks (including disks) on a Linux filesystem. The syntax of the fdisk command is:

# fdisk [options] [device]

The only option you need to use with the fdisk command is the -l option which lists the partition tables of the primary Linux filesystem. Unlike most other options used with the fdisk command, the -l option displays information only and makes no changes to the disk or partitions.

Real-Life Scenario – fdisk

To display the partitions on your Linux filesystem, use the fdisk command and the -l option and target the Linux system disk, using the name revealed, nvme0n1, using the lsblk -l command in the previous section.

To display the partitions on your Linux filesystem using the disk name (nvme0n1) from the output of the lsblk -l command in the previous section:

  1. Launch the terminal.
  2. Display the partitions on the Linux filesystem using the disk name (nvme0n1) derived from the output of the lsblk -l command from the previous section:
    # fdisk -l dev/nvme0n1

    Use the fdisk command to list the total size of a Linux system's disk.
    Use the fdisk command to list the total size of a Linux system’s disk.
  3. The primary Linux filesystem and total size are listed at the bottom of the command output. In this instance, the primary Linux filesystem partition is /dev/nvme0n1p3 and is 238 GB.

Commands Used In This Article

  • cd – change directory.
  • du – estimate file space usage.
  • df – report file system disk usage.
  • lsblk – list block devices.
  • fdisk – display or manipulate the disk partition table.
  • more – file perusal for CRT viewing.
  • apt – Debian- and Ubuntu-based command-line interface for the package management system.
  • install – install applications and packages on Debian- and Ubuntu-based distros.
  • yum – (Yellow Dog Update Modifier) – package manager to install applications and packages on RHEL- and CentOS-based distros.
  • pacman – package manager to install applications on Arch-based systems.

Was this article helpful?

Leave a Comment