How to Check Disk Space in Linux in two commands

Try this guide with our instant dedicated server for as low as 40 Euros

Many admins and users often forget about checking the available disk space because servers generally have storage space in terabytes.

However, given the current package sizes and the increasing number of software admins need to install for server management and business operations, running out of server space is a real possibility.

Checking disk space on Linux using the command line is not just an idle operation. It is now a recommended practice before you attempt to install anything new or upgrade existing packages.

In this short but comprehensive guide, we’ll show you how to check disk space on Linux systems. We’ll cover two critical methods of checking available disk space so that you can easily install software without worrying about insufficient disk space.

Table of Contents

  1. Use the Command Line to Check Disk Space in Linux
  2. Conclusion
  3. FAQs

Use the Command Line to Check Disk Space in Linux

Before discovering the two methods of checking disk space, let’s see the prerequisites for these commands:


  • A system running a mainstream Linux distro
  • An account with root or sudo privileges
  • Access to the command line or terminal

Method #1: Use the df Command to Check the Disk Space in Linux

The df command is one of the easiest ways to check disk space usage and available block size. Launch the terminal and enter the following command:

# df

Method #1: Use the df Command to Check the Disk Space in Linux

As you can see, the df command, which stands for disk free, displays how much space each drive uses. Note that, by default, the values are shown in 1-kilobyte blocks.

The df command provides much information about disk utilization and available space.

Here’s a run-through of the information items that you can see in the command’s output:

  • Filesystem: This entry shows the real hard disk drives, logical (partitioned) drives, and temporary or virtual drives.
  • Size: The filesystem’s actual disk size.
  • Used: The storage space each file system has used.
  • Available: The size of the filesystem’s available (free) space.
  • Use%: The percentage of the disk’s space in use.
  • Mounted on: Shows the mount point for each drive (physical and virtual). This entry also includes temporary drives.

The Filesystem entry covers all attached physical and virtual devices, including processes. Here’s a brief description of the entries in this column:

  • /dev/sda: This is the hard drive on your system. If you have multiple drives (physical and virtual), they’ll be labeled sequentially as /sdb, /sdc, /sde.
  • /dev: This virtual directory is an important part of the Linux file system.
  • tmpfs: – These are transient disk filesystems for the operating system’s execution and are used by the various Linux procedures. For instance, the system creates lock files using the tmpfs /run/lock. These files stop several people from making simultaneous changes to the same file.

Let’s discuss some important flags and options you can use with the df command for more detailed and better-formatted information.

Display Disk Usage in Megabyte and Gigabyte

By default, the df command displays available disk space in KB blocks. Given the huge disk volumes, this is an unrealistic scale because we are used to measuring the disk space in MBs and GBs.

You can display disk size space output in a more understandable format by including the -h flag:

# df -h

Display Disk Usage in Megabyte and Gigabyte

Understanding the Format of the Output

Let’s take a closer look at the output, especially the columns. 

  • Filesystem: This is the name of the drive. This column includes virtual or temporary drives, logical (partitioned), and hard drives.
  • Size: The filesystem’s size.
  • Used: Indicates how much space every filesystem is using at the moment.
  • Avail: The amount of free (empty) space on the filesystem.
  • Use%: Displays the disk usage percentage.
  • Mounted on: The file system type is located in this directory. Another name for this location is a mount point.

Note that the physical hard disk has been included in the list of filesystems.

understanding of output

Show a Particular File System

If you wish to inspect a single disk out of a multi-disk storage component, you can use the -h flag and file system of the target drive. This will show the output in a human-readable format.

# df -h /dev/sda

Show a Particular File System

If you wish to view the usage details about the root partition, use the backslash as a shortcut:

# df -h /

root partition

Display Disk Information by File System

You can list disk information for a specific file system if you have multiple file systems on your server. For this, use the following command:

# df -ht ext4

The -h flag formats the output in a human-friendly list of drives with the ext4 file system.

Display Disk Information by File System

Method #2: Use the du Command to Assess Disk Space Usage

The du command shows the use of the disk.

This utility shows disk space consumption by the size of directories, providing a more detailed overview of your disk consumption.

When used without any flag or option, the command shows how much space is being consumed by your current directory.

# du

Method #2: Use the du Command to Assess Disk Space Usage

Like the df command, you can format the output of du to be human-readable with the -h flag:

# du -h

df command, you can format the output of du

As you can see, the command lists the current directory’s contents and the occupied space. You can add the -s flag to the command to further simplify the output:

# du -hs

You can add the -s flag to the command to further simply the output:

You can add the path of a directory to the command to show the details of that directory. For instance, you can use the following command to get the details of the /etc command:

# du -hs /etc

For instance, you can use the following command to get the details of the /etc command:

You might see a permission denied error for some directories. This indicates that the current user lacks the rights to access the directory. We recommend using the sudo command to sidestep any permission-related issues.

Use the following claims to specify the directory or file:

du -hs /etc/kernel-img.conf

Display Disk Size in 1000s Rather Than 1024s

Manufacturers of hard drives market their products in kilobyte-based sizes, where 1000 bytes = 1 kilobyte. This scale is used for all disk sizes.

On the other hand, the operating systems use a mathematical system where 1024 bytes = 1 kilobyte. As a result, a 1000 GB hard disk only provides about 930 GB of useful capacity.

You can use the du command with the -H flag to show disk space consumption in units of 1000s instead of 1024s units:

# du -H

du -H


Finding the available disk space is an essential step before installing or upgrading a software package on your server. We discussed two ways of finding out available disk space. The good thing about these methods is that you can use several flags to modify the output complexity and details.

If you’re looking for a robust server for your Ubuntu projects, RedSwitches offers the best-dedicated server pricing and delivers instant dedicated servers, usually on the same day the order gets approved. Whether you need a dedicated server, a traffic-friendly 10Gbps dedicated server, or a powerful bare metal server, we are your trusted hosting partner.


Q. How can I monitor disk usage in Linux?

Linux provides several tools for monitoring disk usage, including df (disk free) and du (disk usage) commands. These utilities display information about disk space usage at the filesystem level and directory level, respectively.

Q. How can I free up disk usage in Linux?

To liberate disk space in Linux, begin by pinpointing the files or directories consuming the most storage. The du command can help you evaluate the space usage of particular directories. Once you have identified the directories or files that use a lot of disk space, you can delete, move, or compress them to free up disk space.

Q. What’s a simple method to view available disk space in Linux?

Utilize the df command accompanied by the -h flag in Linux to see the free disk space.

Q. Can I check the disk space on a remote Linux server?

You can check the disk space on a remote Linux server using the df command. Simply SSH into the remote server and run the df command as you would on a local machine.

Q. Can you explain inodes and their connection to storage space?

Inodes in Unix-style file systems serve as data structures holding details about files and folders, encompassing attributes like permissions, ownership, and file size. Every file or directory utilizes one inode. The aggregate count of inodes in a file system dictates its potential capacity, indicating the maximum number of files it can accommodate.

Q. What’s the method to determine storage devices utilization for a particular directory in Linux?

In Linux, you can examine the storage consumption of a distinct directory by using the du command and the directory’s path. As an illustration, to view the storage devices used by the /home directory, execute du /home.

Q. Is it possible to determine the storage utilization of an individual file in Linux?

Absolutely; in Linux, you can gauge the storage devices usage of a particular file with the du command, accompanied by the file’s path. Nonetheless, the du command’s primary function is to assess directories’ storage consumption

Q. How do the df and du commands in Linux differ when examining disk space?

The df command showcases the disk space utilized and remaining on entire file systems while du zeroes in on the space occupied by individual files or directories. Essentially, df offers a bird’s-eye view of storage at the file system level, whereas du lets you delve into the specifics of directories or files.

Q. How do I use a Disk Usage Analyzer in Linux?

Most Linux distributions come with built-in Disk Usage Analyzers, such as du (disk usage) command-line utility or graphical tools like Baobab (Disk Usage Analyzer) for GNOME desktop environment and KDirStat for KDE. To use these tools, simply launch them from the application menu or run the command in the terminal and specify the directory you want to analyze.

Try this guide with our instant dedicated server for as low as 40 Euros