Logo
  • Ubuntu
  • CentOS
  • Debian
  • Fedora
  • RedHat

Df Command in Linux (Check Disk Space) - DesignLinux

Oct 05 2020
designlinux 0 Comments
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.

Related

Tags: df, disk, terminal

Setup Passwordless SSH Login for Multiple Remote Servers Using Script

Prev Post

Wall command in Linux

Next Post
Archives
  • January 2023
  • December 2022
  • November 2022
  • October 2022
  • September 2022
  • July 2022
  • June 2022
  • April 2022
  • March 2022
  • February 2022
  • January 2022
  • December 2021
  • November 2021
  • October 2021
  • September 2021
  • August 2021
  • July 2021
  • June 2021
  • May 2021
  • April 2021
  • March 2021
  • February 2021
  • January 2021
  • December 2020
  • November 2020
  • October 2020
  • September 2020
  • August 2020
  • July 2020
  • June 2020
  • May 2020
Categories
  • AlmaLinux
  • Android
  • Ansible
  • Apache
  • Arch Linux
  • AWS
  • Backups
  • Bash Shell
  • Bodhi Linux
  • CentOS
  • CentOS Stream
  • Chef
  • Cloud Software
  • CMS
  • Commandline Tools
  • Control Panels
  • CouchDB
  • Data Recovery Tools
  • Databases
  • Debian
  • Deepin Linux
  • Desktops
  • Development Tools
  • Docker
  • Download Managers
  • Drupal
  • Editors
  • Elementary OS
  • Encryption Tools
  • Fedora
  • Firewalls
  • FreeBSD
  • FTP
  • GIMP
  • Git
  • Hadoop
  • HAProxy
  • Java
  • Jenkins
  • Joomla
  • Kali Linux
  • KDE
  • Kubernetes
  • KVM
  • Laravel
  • Let's Encrypt
  • LFCA
  • Linux Certifications
  • Linux Commands
  • Linux Desktop
  • Linux Distros
  • Linux IDE
  • Linux Mint
  • Linux Talks
  • Lubuntu
  • LXC
  • Mail Server
  • Manjaro
  • MariaDB
  • MongoDB
  • Monitoring Tools
  • MySQL
  • Network
  • Networking Commands
  • NFS
  • Nginx
  • Nodejs
  • NTP
  • Open Source
  • OpenSUSE
  • Oracle Linux
  • Package Managers
  • Pentoo
  • PHP
  • Podman
  • Postfix Mail Server
  • PostgreSQL
  • Python
  • Questions
  • RedHat
  • Redis Server
  • Rocky Linux
  • Security
  • Shell Scripting
  • SQLite
  • SSH
  • Storage
  • Suse
  • Terminals
  • Text Editors
  • Top Tools
  • Torrent Clients
  • Tutorial
  • Ubuntu
  • Udemy Courses
  • Uncategorized
  • VirtualBox
  • Virtualization
  • VMware
  • VPN
  • VSCode Editor
  • Web Browsers
  • Web Design
  • Web Hosting
  • Web Servers
  • Webmin
  • Windows
  • Windows Subsystem
  • WordPress
  • Zabbix
  • Zentyal
  • Zorin OS
Visits
  • 1
  • 668
  • 610,027

DesignLinux.com © All rights reserved

Go to mobile version