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:
- Click the Applications or Activities icon.
- Enter disk in the Search box.
- Click the Disks icon.
- Click the system disk in the left-hand column (in this case, 256 GB Disk).
- 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:
- From the Applications menu, select System and then Info Center.
- At the Device Viewer — Info Center window, select Devices from the left-hand column.
- Next, select Device Viewer from the left-hand menu and expand Hard Disk Drive under Devices.
- Select the primary partition (usually sda1) from the expanded Hard Disk Drive list.
- 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:
- Launch the Applications or Activities menu.
- Select the Utilities icon from the list of applications.
- Double-click the Disk Usage Analyzer icon.
- At the Devices & Locations window, click the primary hard disk (in this case, mtr-Ubuntu-LTS-22.04)
- 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.
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
To install Disk Usage Analyzer on RHEL- and CentOS-based distros, type the following command from the command line:
# yum install baobab
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
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
- Launch the terminal.
- Navigate to the root (/) directory so that all directories on the Linux filesystem are listed with the du command:
# cd /
- List all file directories and their size piped with the more command:
# du -h -x -c | more
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.
- 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.
- 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
- Launch the terminal.
- 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
- 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:
- Launch the terminal.
- List all blocks (including disks and partitions):
# lsblk -l
- 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.
- 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:
- Launch the terminal.
- 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
- 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.