• Home
  • Linux
  • Ubuntu
  • Debian
  • CentOS
  • Linux Commands
  • About Us
  • Donate
TecNStuff
Menu
  • Home
  • Linux
  • Ubuntu
  • Debian
  • CentOS
  • Linux Commands
  • About Us
  • Donate

Df Command in Linux (Check Disk Space)

Written by Admin, Updated On October 4, 2020
df, disk, terminal
Df Command in Linux (Check Disk Space)

In Linux, the df command is used to get the information about the disk space usage. This guide explains how to use the df command with different formats.

Use of df Command#

Below is the basic syntax for the df command:

df [OPTIONS]... FILESYSTEM...

If you invoke the df command without any arguments, it will show the information about all mounted file systems:

df
Filesystem     1K-blocks    Used Available Use% Mounted on
udev             1007480       0   1007480   0% /dev
tmpfs             204104     620    203484   1% /run
/dev/vda1       25226960 3900508  21310068  16% /
tmpfs            1020508       0   1020508   0% /dev/shm
tmpfs               5120       0      5120   0% /run/lock
tmpfs            1020508       0   1020508   0% /sys/fs/cgroup
/dev/vda15        106858    3668    103190   4% /boot/efi
tmpfs             204100       0    204100   0% /run/user/1000

Following is the description of the each column:

  • Filesystem – It display the name of the filesystem.
  • 1K-blocks – The size of the filesystem in 1K blocks.
  • Used – Displays used space in 1K blocks.
  • Available – The available space in 1K blocks.
  • Use% – Shows the percentage of used space.
  • Mounted on – A directory on which the filesystem is mounted.

To get the information for a specific filesystem, pass the name of it with the df command:

Let’s take an example from above output, if you want to show the details of /dev/vda1 filesystem, you would type:

df /dev/vda1

It will show output as following:

Filesystem     1K-blocks    Used Available Use% Mounted on
/dev/vda1       25226960 3900844  21309732  16% /

Show Disk Space Usage in Human Readable Format#

The df command by default showing the disk space in 1-kilobyte blocks. Also used and available disk space showing in kilobytes.

To show the details in human-readable format means in kilobytes, megabytes, gigabytes, etc., you should pass the option -h with df command:

df -h
Filesystem      Size  Used Avail Use% Mounted on
udev            984M     0  984M   0% /dev
tmpfs           200M  620K  199M   1% /run
/dev/vda1        25G  3.8G   21G  16% /
tmpfs           997M     0  997M   0% /dev/shm
tmpfs           5.0M     0  5.0M   0% /run/lock
tmpfs           997M     0  997M   0% /sys/fs/cgroup
/dev/vda15      105M  3.6M  101M   4% /boot/efi
tmpfs           200M     0  200M   0% /run/user/1000

File System Types#

You can use the -T option with df command to display file system types:

df -T

It will add the one more column named “Type”, which shows the type of the filesystem:

Filesystem     Type     1K-blocks    Used Available Use% Mounted on
udev           devtmpfs   1007480       0   1007480   0% /dev
tmpfs          tmpfs       204104     620    203484   1% /run
/dev/vda1      ext4      25226960 3900576  21310000  16% /
tmpfs          tmpfs      1020508       0   1020508   0% /dev/shm
tmpfs          tmpfs         5120       0      5120   0% /run/lock
tmpfs          tmpfs      1020508       0   1020508   0% /sys/fs/cgroup
/dev/vda15     vfat        106858    3668    103190   4% /boot/efi
tmpfs          tmpfs       204100       0    204100   0% /run/user/1000

You can filter the listing by specifying the type along with -t option:

df -t ext4
Filesystem     1K-blocks    Used Available Use% Mounted on
/dev/vda1       25226960 3900712  21309864  16% /

Display Inode Usage#

In Linux file system, an inode is a data structure which holds the information about a file or directory like its size, owner, device node, socket, pipe, etc.

Use the -i option with df command to get information about the filesystem inodes usage:

df -ih /

The above command shows the infomation about the inodes on the file system mounted to system root directory / in human-readable format.

Filesystem     Inodes IUsed IFree IUse% Mounted on
/dev/vda1        3.1M  144K  3.0M    5% /

When you use -i option, it shows the following columns:

  • Filesystem – It’s shows name of the filesystem.
  • Inodes – Display total number of inodes on the file system.
  • IUsed – The number of used inodes.
  • IFree – Number of free (unused) inodes.
  • IUse% – Percentage of used inodes.
  • Mounted on – the directory on which the filesystem is mounted.

Output format#

You can also customize the output of the df command. Use the --output[=FIELD_LIST] option, to specify the fields which you wants to be show in the output. You should give the field list with comma-separated. Following are the valid field names:

  • source – It’s a source of file system.
  • fstype – It is a type of file system.
  • itotal – Total number of inodes.
  • iused – Number of the used inodes.
  • iavail – The number of the available inodes.
  • ipcent – Shows the percentage of used inodes.
  • size – Displays the total disk space.
  • used – Used disk space.
  • avail – Available disk space.
  • pcent – Percentage of used space.
  • file – The file name if specified on the command line.
  • target – The mount point.

For example, to show the information of all ext4 partition with only filesystem name, size and the percentage of used space, type:

df -h -t ext4 --output=source,size,pcent
Filesystem      Size Use%
/dev/vda1        25G  16%

Conclusion#

In this guide, you learned how to use the df command to get the information about filesystem disk space usage. To learn more about df command options, type man df in your terminal.

If you have any questions, please leave a comment below.

If our content helps you, please consider buying us a coffee

Thank you for your support.

Share On
Share on Facebook
Share on Twitter
Share on Reddit
Share on Tumblr
 Previous Article BackUp and Restore MySQL/MariaDB Database
Next Article   How to Install Slack on CentOS 8

Related Posts

  • How to Install SSH Keys on Ubuntu 22.04

    How to Set up SSH Keys on Ubuntu 22.04

    January 7, 2023
  • How to Install Fail2ban on Ubuntu 22.04

    How to Install and Configure Fail2ban on Ubuntu 22.04

    December 5, 2022
  • How to Enable SSH on Ubuntu 22.04

    How to Enable SSH on Ubuntu 22.04

    December 1, 2022

Leave a Reply Cancel reply

DigitalOcean Referral Badge

Popular Posts

  • How to Install Microsoft Edge Browser on Ubuntu 22.04
    How to Install Microsoft Edge Browser on Ubuntu 22.04 March 14, 2023
  • How to Install Ruby on Ubuntu 22.04 LTS
    How to Install Ruby on Ubuntu 22.04 LTS February 27, 2023
  • How to Install PHP 8.2 on Debian 11
    How to Install PHP 8.2 on Debian 11 Linux February 24, 2023
  • How to Install LEMP Stack on Ubuntu 22.04
    How to Install LEMP Stack on Ubuntu 22.04 March 18, 2023
  • How to Install Set Up Apache Virtual Hosts on Ubuntu 22.04
    How to Set Up Apache Virtual Hosts on Ubuntu 22.04 March 2, 2023
© 2020 TecNStuff All rights reserved. This website is using and storing cookies on your browser. By using this website you agree our Privacy Policy.  Follow us -  Twitter | Facebook