Chat Zalo Chat Messenger Phone Number Đăng nhập
How to Check Free Disk Space on Ubuntu & Other Linux - It's FOSS

How to Check Free Disk Space on Ubuntu & Other Linux – It’s FOSS

Free Disk Space Linux Df Command Output

How much disk space have I used?

The easiest way to find free disk space in Linux is to use the df command. The df command stands for disk free and obviously shows you the free and available disk space on Linux systems.

df -h

With the -h option, displays disk space in human-readable format (MB and GB).

Here is the output of the df command for

my Dell XPS system that only has Linux installed with encrypted disk:

Df Command Output
Free disk space check with df command on Linux

If the above output is confusing for you, don’t worry. I will explain a few things on how to check the available disk space in Linux. I will also show the GUI method for desktop Linux users.

In general, I will mention three methods

:Using the df command

  • Use alternative commands such as du and dust
  • Using a graphical user interface
  • With

  • the

information it collects, you can make some free space in Ubuntu.

Method 1: Check

free disk space on Linux with df command (and understand its output)

When you use the df command to check disk space, it will display a bunch of ‘file systems’ with their size, used space and free space. Your actual disks should normally appear as one of the following:

/dev/sda/dev/

  • sdb
  • /

  • dev/
  • nvme0n1p

This is not a hard and fast rule, but it gives you an indication to easily recognize the real disk from the crowd

.

Your Linux system may have multiple partitions on your disk for boot, EFI, root, swap, boot, etc. In such cases, these partitions are reflected with a number at the end of the ‘disk name’, such as /dev/sda1, /dev/nvme0n1p2, etc.

You can identify which partition is used for what purpose from its mount point. The root is mounted in /, EFI in /boot/EFI, and so on.

In my case, I have used 41% of the 232 GB of disk space under root. If you have 2-3 large partitions (such as root, home, etc.), you will have to do a calculation here.

df t command
Understanding df command output

tmpfs

  • : Thetmpfs (temporary file system) used to maintain files in virtual memory. You can ignore this virtual file system conveniently.
  • udev: The udev file system is used to store information related to devices (such as USB, network card, CD ROM, etc.) connected to your system. You can also ignore it.
  • /

  • dev/loop: These are loop devices. You will see a lot of them while checking disk space on Ubuntu due to instant applications. Loops are virtual devices that allow regular files to be accessed as block devices. With looping devices, instant applications are entrenched in their own virtual disk. Since they are under root, there is no need to count their used disk space separately.

And, if you want to see disk usage with more details like file system type and blocks, you can use the command:

df -T

Lsblk Command To See Disks Linux

Disk space is missing? Check if you have mounted all disks and partitions

Note that the df command only displays disk space for mounted file systems. If you are using more than one Linux distribution (or operating systems) on the same disk or have multiple disks on your system, you must first mount them to see the free space available on those partitions and disks.

For example, my Intel NUC has two SSDs and 4 or 5 Linux distributions installed on them. Displays additional disks only when you explicitly mount them.

You can use the lsblk command to view all disks and partitions on your system.

Disk Usage Analyzer Tool Linux

Once you have the disk partition name, you can mount it like this:

sudo mount /dev/sdb2 /mnt

I hope this gives you a pretty good idea on how to check hard drive space on Linux. Let’s see how to do it graphically.

Method 2: Using

du, ls, and other commands

While the df command is quite popular and should be sufficient for the use case, there are other alternatives you can try, including:

du -h → Displays disk usage

  • in human-readable format for all directories and subdirectories. du -a →Displays disk usage for all files.
  • du -s Provides the total disk space used by a given file or directory.
  • ls -al →Lists all the contents, along with their size, of a given directory.
  • stat <file/directory> →Displays the size and other statistics of a file/directory or file system.
  • fdisk -l →Displays the disk size along with disk partition information (may require sudo privileges).
  • dust → An interesting alternative to the du command written in Rust, available for Arch Linux in the repositories. For other Linux distributions, you can check out their GitHub releases section.

Method 3:

Graphically check free disk

usage Graphically checking free disk space is much easier in Ubuntu with the Disk Usage Analyzer tool.

Free disk space Ubuntu Desktop
Disk

Usage Analysis Tool You will see all the actual disks and partitions here. You may have to mount some partitions by clicking on them. Displays disk usage for all mounted partitions.

Linux Disk ToolChecking Disk
Usage
Checking

Free Disk Space with

the GNOME Disks

Utility Otherwise, the GNOME Disks utility is also a pretty useful tool.

Free up disk space Check Ubuntu Desktop
GNOME Disks Tool

Launch the tool and select the disk. Select a partition to view the free disk space. If a partition is not mounted, mount it first by clicking the ‘play’ icon.

disk usage analyzer tool
Free up disk space Check in Ubuntu Desktop

I think all major desktop environments have some sort of graphical tool to check disk usage in Linux. You can look for it in the menu of your desktop Linux system.

Conclusion

Of course, there may be more ways and tools to check disk space. I showed you the most common command line and GUI methods for this purpose.

I also explained some things that might bother you to understand disk usage. I hope you like it.

Running out of disk space? How about cleaning it up and getting it back?

Please let me know in the comments section if you have any questions or suggestions.

Contact US