How to Check Disk Space in Linux in two commands

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. Prerequisites
  2. Method #1: Use the df Command to Check the Disk Space in Linux
    1. Display Disk Usage in Megabyte and Gigabyte
    2. Show a Particular File System
    3. Display Disk Information by File System
  3. Method #2: Use the du Command to Assess Disk Space Usage
    1. Display Disk Size in 1000s Rather Than 1024s
  4. Conclusion
  5. 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

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

Display Disk Information by File System

The -h flag formats the output in a human-friendly list of drives with the ext4 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.

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


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 What command should I use to inspect disk space in Linux from the command line?

You can utilize the df command in Linux to determine disk space. Simply open a terminal and type df by pressing the Enter key. This will show the disk usage details for every file system on your Linux machine.

Q How can I free up disk usage in Linux?

To liberate disk space in Linux, pinpoint 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 with the -h flag in Linux to see the free disk space.

Q What’s the procedure to view unused disk space in Linux?

In Linux, you can determine the unused disk space by employing the df command and the -a option. This command will reveal the available space for every file system, even fully occupied.

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 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 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 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 can disk space utilization be presented in a user-friendly format?

By employing the df command coupled with the -h option, you can exhibit disk space in an easily comprehensible format, representing sizes in terms like MB or GB, as opposed to the standard 1K blocks.

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.