Linux logo

How to check disk space in Linux OS

You may check the Linux system disk space in different ways. A third party program that shows the available disk space or from command-line way through the Linux Terminal.

Managing disk space on a Linux server is a significant ongoing thing. By way of instance, package manager software notifies you how much disk space will be required for installation. For the information to be meaningful, you ought to be aware of how much space your system has available.

Two of the available commands in Linux are df and du, where du is disk space used and df is disc space free.

Now let’s take a look at both commands.

The du command

Let us first look at the du command that stands for Disk Used.

With this utility, we can assess directories disk utilization.

$ du [option]… [file]

An example command using du

The simplest command for disk used can be:

$ du

This displays the used space of the current directory.

Further Reading:  A little about Vim and how to search in it

You can make du human-readable:

$ du -h

It displays a listing of the contents of the current directory, and how much space they are using.

Using -hs

du --hs

You can simplify the screen with the –s option. This shows how much space the current directory uses.

Getting help – list all available options

The –help will display available options of du command. Run this command:

$ du --help

linux space du

The -s, –summarize option

The -s flag is added to the -h flag on occasion. With their powers combined, they enable us to receive an overview of the directory’s use in a human-readable format.

For example:

$ du -sh
The –time option in du command

It shows the time of the last modification to any file in the directory or subdirectory which you run it against.

$ du -ah --time
The -c, –complete

This choice is much more of a dummy test than it’s useful, but some people really like using a entire measurement output. The -c flag adds a line to the bottom of the output that provides you a grand total of each the disk usage for the file path given.

$ du -ch
The df command

The df command stands for “disk-free” and shows available and used disk space on the Linux system.

Further Reading:  A little about deleting directories in Linux

You can check your disk space simply by opening a terminal window and entering the following:

$ df

The -a shows the file system’s complete disk utilization even if the Available field is 0

$ df -a

Note: By default, the df displays values in 1-kilobyte blocks.

Display Utilization in Megabytes and Gigabytes

You can display disk usage in a more human-readable format by adding the –h option:

$ df -h

This shows the size in kilobytes (K), megabytes (M), and gigabytes (G).

Display information in megabytes

Use the –m option to get information in megabytes. Example command:

$ df –m
The –T option

The -T option shows the disk usage along with every block’s file system type (e.g., xfs, ext2, ext3, btrfs, etc.. )

$ df -T
Display file system inodes

The -i shows used and free inodes. i.e.

$ df -i

Display a Particular File System

The df command may be used to display a specific file system:

$ df –h /dev/tst
Graphical view to check Disk

You can receive this data in a graphical view with the Disks (gnome-disk-utility) from the GNOME desktop. Launch it to find all discs detected by your computer, and click on a partition to find details about it, such as space used and space remaining.

Further Reading:  What is date command in Linux?

Check these GUI tools: