Checking disk space using the command-line with examples

du and df commands are great for fetching disk usage from the Terminal.

There are several ways of checking your Linux system disk space. You could use a third-party app that shows the available disk space or do it by command-line way via the Linux Terminal.

In this guide, we are going to show you the best command-line ways of finding the disk space alongside some tips and tricks.

You can check disk space using du and df commands. Let’s discuss each of these commands with examples.

Method 1: Checking the disk space using du command

The du command in Linux is a short cut for Disk Usage. Using the du command, you can check your directories disk usage.

Syntax:

du [OPTION]... [FILE]...

Example 1. Find out disk usage on a specific directory and display the disk size in a human-readable format.

du -h /home/hendadel

Display Disk Space Usage For All Drivers With the du command
du command usage

Example 2. Check disk usage and sort by top 5 directories that are using most disk space.

du -a /home | sort -n -r | head -n 5

Display Top 5 File Systems Using Most Disk Space
Display Top 5 File Systems

Method 2:  Checking disk usage via the df command

The df is another powerful command you can use for fetching the disk space summary in a variety of ways.

Syntax:

df [OPTIONS]... FILESYSTEM...

Example 1. Display the Linux disk space usage for the file system.

df

Display Disk Space Usage For All the File System
All the File System

Example 2. The df command has several options that you can use to determine your Linux file system disk usage. Use the following command to display the df command help.

df --help

df Command More Information
df Command More Information

Example 3. Display all the information for the disk space usage on all the file systems.

df -a

Display Disk Space Usage For All the File System
Display Disk Space Usage For All the File System

Example 4. Display the disk space usage for the file system in a human-readable format.

df -h

Display Disk Space Usage For the File System In Human Readable Format
In Human Readable Format

Example 5. To fetch the data just for the home file system only, use the following command:

df -hT /home/

Display Disk Space Usage For the home File System
For the home File System

Example 6. Check disk space usage for all drivers and show specific columns.

df -H --output=size,used,avail

Display Disk Space Usage For All Drivers With Specific Arguments
For All Drivers With Specific Arguments

Example 7. Display the disk space usage for the file system in bytes.

df -k

Display Disk Space Usage For the File System in Bytes
File System Size in Bytes

Example 8. The same thing, but in megabytes.

df -m

Display Disk Space Usage For the File System in Mega Bytes
File System size in MegaBytes

Example 9. Display disk space usage for the file system alongside its type.

df -T

Display Disk Space Usage For the File System Alongsides its Type
Display Disk Space Usage For the File System Alongside its Type

I hope you enjoyed this tutorial in figuring out du and df command usage scenarios. To see all the available df command options, you can use man df or man du in your terminal.

Hend Adel
Hi! I'm Hend Adel, a freelancer technical geek with successful experience in Database, Linux and many other IT fields. I help to build solutions to suit business needs and creating streamlined processes. I love Linux and I'm here to share my skills via FOSS Linux! Thanks for reading my article.

LEAVE A REPLY

Please enter your comment!
Please enter your name here

STAY CONNECTED

23,872FansLike
267FollowersFollow
16SubscribersSubscribe

LATEST ARTICLES

How to create a Clonezilla Live USB drive on Linux

There are three Clonezilla types, Clonezilla live, Clonezilla lite server, and Clonezilla SE (server edition). Clonezilla live for single machine backup and restoration. While Clonezilla's lite server is for massive deployment.
If you are looking for an open-source Linux alternative for Acronis True Image, Norton Ghost, Paragon Drive Copy, you have landed in the right place. Meet Clonezilla. Clonezilla is a free and open-source disk partition and disk cloning software that helps you also do system deployment, bare metal backup, and recovery.
BEST LINUX TASK MANAGERS
One of the essential tools in any Linux distribution is a Task Manager. It is a system monitor application that gives you a report of all programs running on your computer and the status of your RAM and CPU usage.
guide to clone hard disk
Disk cloning refers to the process of copying data from one disk to another, thus creating a one-to-one copy of the drive. Technically, this process is possible using the copy-and-paste method.