Javatpoint Logo
Javatpoint Logo

Linux df Command

Linux df command is used to display the disk space used in the file system. The 'df' stands for "disk filesystem." It defines the number of blocks used, the number of blocks available, and the directory where the file system is mounted.

Syntax:

Options:

-a, --all: It is used to include pseudo, duplicate, remote file systems.

-B, --block-size=SIZE: It is used to scale sizes by SIZE before printing them, for example, the '-BM' option prints sizes in units of 1,048,576 bytes.

-h, --human-readable: It is used to display sizes in powers of 1024 (e.g., 1023M).

-H, --si: It is used to show sizes in powers of 1000 (e.g., 1.1G)

-i, --inodes: It is used to list inode information instead of block usage

-l, --local: It is used to limit the listing to local file systems.

--no-sync: It is used for not invoking sync before getting usage info (default).

--output[=FIELD_LIST]: This option used if we want to use the output format defined by FIELD_LIST or print all fields if FIELD_LIST is omitted.

-P, --portability: It is used to use the POSIX output format.

--total: It is used to exclude all entries insignificant to available space, and produce a total.

-t, --type=TYPE: It is used to limit the listing to file systems of type TYPE.

-T, --print-type: It is used to display the file system type.

-x, --exclude-type=TYPE: It is used to limit the listing to file systems, not of type TYPE.

--help: It is used to display the help manual having brief information about the supported options.

--version: It is used to display the version information of the df command.

Examples of the df command

Let's see the following examples of the df command:

  • Display the disk space usage
  • Display the disk space usage in a human-readable form
  • Display the file system type
  • Display specific file system types
  • Exclude the particular file system types
  • Display available space and mount point for a folder

Display the Disk Space Usage

To display the disk space usage, execute the df command without any argument. It will show the disk space usage in a tabular form. The df command is useful for discovering the available free space on a system or file system. Execute the below command:

The above command will produce the output as follows:

Linux df

From the above output, we can see the file system, the size of the file system in 1k block, used space, available space, the percentage applied by the file system, and mount point, respectively.

Display the disk space usage in a human-readable form

The '-h' option is used to display the disk space in a human-readable form. It will display the size in powers of 1024 and will append G for GBs, M for MBs, and B for Bytes. Execute the below command:

The above command will produce the output as follows:

Linux df

Display the file system type

The '-T' option is used to display the file system type. It will add a new column having the file system type to output. Execute the below command:

The above command will produce the output as follows:

Linux df

From the above output, we can see the column 'type' has been added with output.

Display specific file system types

The '-t' option is used with the file system type to display the specific file system. It will only display a given file system. We can specify more than one file system with it. Consider the below command:

the above command will only display the 'ext4' types file system. Consider the below output:

Linux df

Exclude the specific file system types

The '-x' option is used with the specific file system type to exclude it from the output. It will display all other file system types except the given types. Consider the below command:

The above command will exclude the 'squashfs' file system from the output. Consider the below output:

Linux df

Display available space and mount point for a folder

To display the available space, file system type, and mount point of a folder, pass the folder name with the df command. Consider the below command:

The above command will display the file system details of the given folder. Consider the below output:

Linux df

From the above output, we can see the used disk space, file system types, and other information of the given folder are displayed. We can make the output more specific by passing the supported options.


Next TopicLinux expr command




Youtube For Videos Join Our Youtube Channel: Join Now

Help Others, Please Share

facebook twitter pinterest

Learn Latest Tutorials


Preparation


Trending Technologies


B.Tech / MCA