Innovate | Connect | Transform
ContactService statusUSD $

GICT knowledge base

How can I check disk space in Linux?

Published

Linux and Commands

The df command is a standard command-line utility in Linux and Unix operating systems that displays information about the file system disk space usage. It provides important details about the available disk space, file system type, and the total size, used space, and available space for all mounted file systems. This information can be useful in managing storage resources, troubleshooting disk space issues, and understanding how much space is being used by different file systems and directories.

The syntax for the df command is simple:

$ df [OPTIONS] [FILESYSTEM]

Where OPTIONS are the various flags that can be used to customize the output of the command, and FILESYSTEM is the specific file system you want to view information about. If no file system is specified, the df command will display information about all mounted file systems.

Basic usage of the df command

The df command is commonly used to quickly check the disk space usage on a Linux or Unix system. To use it, open a terminal window and simply type df. This will display information about all mounted file systems on your system.

The output of the df command shows the following columns:

  • Filesystem: the name of the file system
  • 1K-blocks: the total number of 1KB blocks on the file system
  • Used: the number of 1KB blocks used by the file system
  • Available: the number of 1KB blocks available on the file system
  • Use (%): the percentage of the file system that is currently being used
  • Mounted on: the mount point of the file system

Here is the example output of a simple df command.

Filesystem 1K-blocks Used Available Use% Mounted on
/dev/sda1 10321208 4053904 5732696 42% /
/dev/sdb1 10485760 4096 10481664 1% /data

Note that the sizes displayed in the output are in 1KB blocks. To view the sizes in human-readable format (i.e., megabytes, gigabytes, etc.), you can use the -h option with the df command. You can also use other options available in the df command to modify the output. Here are some options to modify the output of the df command.

  1. -h or --human-readable: Displays the sizes in a human-readable format (i.e., using units like MB, GB, etc.) instead of displaying the sizes in 1K-blocks.
  2. -T or --print-type: Displays the file system type in the output. This can be helpful to quickly identify which file system a specific mount point is associated with.
  3. -t or --type: Displays information only for the specified file system type(s). This is useful if you want to focus on a specific type of file system (e.g., ext4, nfs, tmpfs, etc.) or exclude a particular type of file system from the output.
  4. -i or --inodes: Displays information about the number of free and used inodes on the file system. Inodes are data structures used by the file system to store information about files and directories, and knowing how many inodes are available can be helpful for preventing issues related to running out of inodes.
  5. -k or --block-size: Specifies the block size to use in the output (in bytes). This option can be used to customize the output to match the block size used by a particular file system.
  6. -x or --exclude-type: Excludes the specified file system type(s) from the output. This can be useful if you want to exclude file systems that are not relevant to your current task.

Using these options, you can customize the output of the df command to display the information that is most relevant to your needs. By default, the df command displays information about all mounted file systems, but with these options, you can narrow down the output to specific file system types, display sizes in a more readable format, or exclude file systems that are not relevant to your current task.

Related guides

Account services are unavailable until the production backend is configured.