How to View Free Disk Space and Disk Usage From the Linux Terminal

Share
  • April 2, 2019

Fatmawati Achmad Zaenuri/Shutterstock.com

The df and du commands report on disk space usage from within the Bash shell used on Linux, macOS, and many other Unix-like operating systems. These commands let you easily identify what’s using up your system’s storage.

Viewing the Total, Available and Used Disk Space

Bash contains two useful commands related to disk space. To find out the available and used disk space, use df (disk filesystems, sometimes called disk free). To discover what’s taking up the used disk space, use du (disk usage).

Type df and press enter in a Bash terminal window to get started. You’ll see a lot of output similar to the screenshot below. Using  df without any options will display the available and used space for all mounted filesystems. At first glance, it might look impenetrable, but it is quite easy to understand.

df

output from df command

Each line of the display is made up of six columns.

  • Fileystem: The name of this filesystem.
  • 1K-Blocks: The number of 1K blocks that are available on this filesystem.
  • Used: The number of 1K blocks that have been used on this file system.
  • Available: The number of 1K blocks that are unused on this file system.
  • Use%: The amount of space used in this file system given as a percentage.
  • File: The filesystem name, if specified on the command line.
  • Mounted on: The mount point of the filesystem.

You can replace the 1K block counts with more useful output by using the -B (block size) option. To use this option, type df, a space, and then -B and a letter from the list of K, M, G, T, P, E, Z or Y. These letters represent the kilo, mega, giga, tera, peta, exa, zeta, and yotta values from the multiple of 1024 scale.

For example, to see the disk usage figures in megabytes, you would use the following command. Note there is no space between the B and M.

df -BM

output from df command with -BM options

The -h (human readable) option instructs df to use the most applicable unit for the size of each filesystem. In the next output note that there are filesystems with gigabyte, megabyte and even kilobyte sizes.

df -h

Read the remaining 43 paragraphs

Source : How to View Free Disk Space and Disk Usage From the Linux Terminal