df command – Check disk space utilization in Linux

df command – df stands for disk free – when used presents with details of disk space used and available in Linux system. By default, file system shows size in bytes of all partition including ones which are inaccessible. The df command is very flexible, you can customize output of filesystem size, include or exclude specific filesystem type.

Syntax

df [options] [device]

Use of df command in Linux with examples

Check filesystem disk space

The most basic use of df command is to check filesystem disk space. This can be done simply using df command on terminal.

Syntax

df

The output displays details for file system device names, disk blocks, total disk space used, available disk space, percentage of usage and mount points on a file system.

Check filesystem disk usage in more usable format (Human readable)

By default, df shows disk usage size in bytes. 1024 bytes will combine to form 1 Kilobyte, 1024 kilobytes combine to form 1 Megabyte and so on. It becomes difficult to understand sizes when displayed in bytes. Most modern system display disk utilization in Kb’s, Mb’s and Gb’s. When df command is used with switch -h displays size human readable format.

Syntax

df -h

Display disk usage in different size formats

As already mentioned df command is very flexible in terms of usage. df command allows user to display size in bytes, Kilobyte, Megabyte and Gigabyte.

Display disk usage in Kilobytes

Using -k switch with df command displays size with basic block size of 1024 bytes.

Syntax

df -k

Display disk usage in Megabytes

Using -m switch with df command displays size with basic block size of 1024 kilobytes.

Syntax

df -m

Display disk usage in Gigabytes

Using -h switch with df command displays size with basic block size of 1024 Megabytes.

Syntax

df -h

Display filesystem type

Default output of df command does not display filesystem type, to display filesystem type use -T switch.

Syntax

df -T

Include certain filesystem type

To display only certain type of file system use switch -t with df command along with filesystem

Syntax

df -t [filesystem type]

Example

df -t ext3

Exclude certain filesystem type

To exclude only certain type of file system use switch -x with df command along with filesystem

Syntax

df -x [filesystem type]

Example

df -x ext3

This command will show all filesystem other than ext3.

Display size of a mount point

Using -h switch with a mount point in df command displays disk space utilization of mount point.

Syntax

df -h /home

This command will display space utilization for home.

Display local file system only

By default, when df command is executed it shows space utilization for all mounted file systems including NFS, Samba shares. To display only local filesystem you will have to use –local or -l switch.

Syntax

df --local