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,538FansLike
365FollowersFollow
16SubscribersSubscribe

LATEST ARTICLES

How to install CouchPotato on Ubuntu

Downloading movies and copying them over to your home server can get frustrating, especially if you are doing it daily! What if you have an option to download videos automatically, quickly, and above all with excellent quality. CouchPotato allows you to download movies easily once they are available and released automatically.

Top 20 Rsync Examples in Linux

The Rsync (remote sync) command is a Linux/Unix utility used to synchronize and copy files and directories either locally or remotely. Most Linux geeks use Rsync to mirror, backup or migrate data across folders, across disks and networks. One notable feature with the Rsync command is that it uses the "delta transfer algorithm."

Setting up NFS Server on Ubuntu Server

We have put together a detailed step-by-step tutorial that will guide you on how to install and set up NFS Server on Ubuntu so you too can start sharing data with other client systems. It is divided into sections, the first part discussing how to set up the host server and the second part showing you how to set up the client-side. For this tutorial, we will be using Ubuntu 20.04 LTS.

Crontab in Linux Explained With Examples

Crontab is the Linux equivalent of the Window's Task Scheduler. It can help you set up a task to run automatically at a regular...

The 10 Best Linux Server Distros For Home And Businesses

By the year 2020, it is estimated that there are close to 600 Linux distributions in the market. It includes both servers and Desktop versions; therefore, if you are looking for lightweight Linux distribution for your old PC or a reliable desktop version for employees in your organization, you may be overwhelmed with the number of choices for finding one for your use.

How to list the installed Packages on Ubuntu

It is only natural to start installing more and more software on your Ubuntu PC once you start using it. Similarly, it is also natural to lose track of the different packages that you have installed on your system. Eventually, you may be overwhelmed with the number of packages in your system and with the ones you hardly used.

MUST READ

Linux is growing faster than ever. As per the latest report, there is a drop in the Windows 10 market share for the first time, and Linux's market share has improved to 2.87% this month. Most of the features in the list were rolled out in the Pop OS 20.04. Let's a detailed look into the new features, how to upgrade, and a ride through video.
Elementary OS 5.1 Hera has received a point release with a handful of new features and bug fixes, and we will be reviewing the significant changes in this article. For those new to elementary OS, this Ubuntu-based Linux distribution uses their inhouse built Pantheon desktop environment and AppCenter.

Manjaro ‘Gellivara’ XFCE Edition (17.0.5) in 10 Screenshots

Want to take a quick virtual tour Manjaro XFCE edition instead of downloading GBs worth of ISO image and then making a Live USB of it? We will make it easy for you. Here are a series of screenshots of the important aspects of Manjaro Linux in XFCE edition. This is a light-weight edition, and aims to be fast and low on system resources. You will be amazed on how it is still visually appealing and user friendly.

13 ways to use the copy command in Linux (with examples)

Being a Linux user, copying files and directories is one of the everyday tasks that you have to carry out. It can be copying a file to make a backup or copy it to another partition, directory, or external storage drive.

How to dual-boot Ubuntu and Fedora on your PC

Every Linux distribution has its capabilities and preferences as per the user requirements. That brings forth the need to run different distros on one laptop. For example, a CyberSecurity enthusiast might prefer to use Ubuntu for development and Kali Linux for penetration testing.

5 Best Notepad++ Alternatives for Linux

Notepad++ has been the de facto standard for source code editors for nearly 16 years, almost since its creation in 2003.  For Windows users, that is.  For years, Linux users had no source code editor that compared to Notepad++ with all its bells and whistles, such as code folding, scripting, markup languages, syntax highlighting, auto-completion for programming (limited).