Linux

Check Disk Space in Linux: df and du Commands

Introduction

Administrators of systems and other individuals have everyday tasks that include maintaining an eye on disk utilization data. A range of built-in utilities in Linux assists in providing the required data.

A key responsibility of a Linux server is keeping track of disk space. Applications that act as package managers, for instance, alert you to the amount of disk space needed for installation. You must know how much accessible space your system possesses for all of this data to be useful.

Find out how to Check disk space in Linux using the df command and view your file system’s disk space use with the du command throughout this article.

Check Linux Disk Space Using the df Command

Check Linux Disk Space Using df Command

Just access a terminal window along type the following commands to check disk space in Linux:

df

You can see how much space each disk is using by using the df command, which indicates the disk is free. Values are shown by df by a standard in 1-kilobyte blocks.

Megabyte and Gigabyte Display Usage

By including the -h alternative, disk consumption can be shown in an easily accessible format:

df -h

Here, the size is shown in kilobytes (K), megabytes (M), or gigabytes (G).

Getting to Know the Output Format

Several columns get listed by the df command:

Filesystem SizeUsed AvailableUse% installed on
udev 210M0210M 0% /dev
tmpfs 49M 1004K 48M 3% /run
/dev/sda2 7.9G4.3G3.2G58%/

There could be additional output entries. It should be clear from the columns what they mean.

  • The filesystem -Each specific drive is known by its designation. This data comprises logical (partitioned), virtual, as well as temporary drives in addition to physical hard disks.
  • The size – how big the filesystem is.
  • Used – the volume of storage each filesystem is using.
  • Availability – The size of the filesystem’s available (free) space.
  • Use% – displays the percentage of the disk that is being used.
  • Installed on -The file system can be found in this location. Occasionally, this gets referred to as a mount point.

Both virtual and physical hard disks are included in the following set of filesystems:

  • /dev/sda2 – Your actual hard drive is located here. It might get labeled as /sda1, or/sda0, and you could hold more than one. The device can be found in /dev.
  • udev – It serves as a virtual directory that houses the /dev directory. This can be considered a component of the system that runs on Linux.
  • tmpfs – There could be multiple of them. As temporary filesystems for the operating system, they are utilized by /run along with other Linux processes. To make lock files, for instance, use tmpfs /run/lock. These files guard against ongoing changes to the same file by several users.

Displaying a Particular File System

You could show a particular file system with the df command:

df -h /dev/sda2

Another option is to incorporate a backslash:

df -h /

This shows how much disk space on Linux is being used on your main hard drive. When you wish to verify a specific drive, enter the mount point (located in the Installed on column).

A complete filesystem is the only one that the df command addresses. Df can examine every part of the drive regardless of whether you just provide a specific directory.

Systems for Displaying Files by Type

Execute the following command to organize every single file system by type:

df -ht ext4

Using an understandable human approach, it presents drives that have the ext4 file system.

As opposed to 1024 pixels, use 1000

Alternative to using 1024 units, you could display disk consumption in units of 1000:

du -H

This might shed light on a tricky area of storage technology. 1000 bytes = 1 kilobyte is the unit of measurement used by hard drive manufacturers to advertise their products.

The method in which that space gets divided up by operating systems, still makes 1024 bytes equal to one kilobyte. As a result, a 1000 GB hard drive only has about 930 GB of actual storage space.

Recommended: 50+ Linux Commands with Screenshots

Use the du Command for Linux to Determine Disk Space

The disk space utilization is shown using the du command. You can see a more detailed breakdown of your disk consumption with this program, showing disk utilization for specific directories in Linux. You can use it to see how much room your current directory is taking up:

du

Similar to the df command, du could be made readable by humans by:

du -h

The current directory’s components get listed together with the quantity of disk space each one is taking up in Linux. Using the -s option will make the display simpler:

du -hs

The amount of disk space on Linux used by the current directory is displayed here.

Consider These Choices to Define the Directory or File:

  • du -hs /etc/kernel-img.conf
  • du -hs /etc

Possibly you saw a permission denied alert with this second command. This indicates that the logged-in user does not have the authority to access these directories. To increase your privileges, execute the sudo command by space disk:

sudo du -hs /etc

From CentOS Linux, you may need to execute the su command to transition to the root user to get into protected directories.

Also Read: A Complete Guide to useradd Command in Linux with Examples

Conclusion

Finally, you can utilize the df and du programs if you know how to verify the amount of disk space on your Linux system. Always keep in mind that you can execute between df –help and du –help to view the full list of available options.

Arpit Saini

He is the Chief Technology Officer at Hostbillo Hosting Solution and also follows a passion to break complex tech topics into practical and easy-to-understand articles. He loves to write about Web Hosting, Software, Virtualization, Cloud Computing, and much more.

Related Articles

Leave a Reply

Your email address will not be published. Required fields are marked *