Part of administering any system is to ensure that it does not run out of disk space. This is especially true for Linux as some of the best practices in Linux is to install specific part of the system into a separate partition whereby some Linux distributions will automatically do that during system installation. This increases the chance that any of the disks or partitions to independently run out of free space.

Filesystem's size, usage and available space can be checked from the command line using df command. It is however can't be used to check the size of specific files and folders.

Steps to check disk utilization and free space in Linux:

  1. Launch terminal.
  2. Show disk / partition size, usage and available space usage using df.
    $ df
    Filesystem     1K-blocks    Used Available Use% Mounted on
    tmpfs             399740    1800    397940   1% /run
    /dev/sda3       19991152 7696980  11255632  41% /
    tmpfs            1998688       0   1998688   0% /dev/shm
    tmpfs               5120       0      5120   0% /run/lock
    tmpfs               4096       0      4096   0% /sys/fs/cgroup
    /dev/sda2         524272    7984    516288   2% /boot/efi
    tmpfs             399736     108    399628   1% /run/user/1000
  3. Show usage and available space using df in human readable format.
    $ df -h
    Filesystem      Size  Used Avail Use% Mounted on
    tmpfs           391M  1.8M  389M   1% /run
    /dev/sda3        20G  7.4G   11G  41% /
    tmpfs           2.0G     0  2.0G   0% /dev/shm
    tmpfs           5.0M     0  5.0M   0% /run/lock
    tmpfs           4.0M     0  4.0M   0% /sys/fs/cgroup
    /dev/sda2       512M  7.8M  505M   2% /boot/efi
    tmpfs           391M  100K  391M   1% /run/user/1000

    Unit changed to M(Megabyte), G(Gigabyte), T (Terabyte) etc instead of in blocks.

  4. Show disk usage information for a specific partition.
    $ df -h /dev/sda3
    Filesystem      Size  Used Avail Use% Mounted on
    /dev/sda3        20G  7.4G   11G  41% /
  5. Show disk usage information for a specific mount point.
    $ df -h /boot/efi
    Filesystem      Size  Used Avail Use% Mounted on
    /dev/sda2       512M  7.8M  505M   2% /boot/efi

  6. Show disk usage in more format and details using different options for df.
    $ df -hT
    Filesystem     Type   Size  Used Avail Use% Mounted on
    tmpfs          tmpfs  391M  1.8M  389M   1% /run
    /dev/sda3      ext4    20G  7.4G   11G  41% /
    tmpfs          tmpfs  2.0G     0  2.0G   0% /dev/shm
    tmpfs          tmpfs  5.0M     0  5.0M   0% /run/lock
    tmpfs          tmpfs  4.0M     0  4.0M   0% /sys/fs/cgroup
    /dev/sda2      vfat   512M  7.8M  505M   2% /boot/efi
    tmpfs          tmpfs  391M  112K  391M   1% /run/user/1000
  7. Utilize more options for df command to check disk size and usage in Linux.
    $ df --help
    Usage: df [OPTION]... [FILE]...
    Show information about the file system on which each FILE resides,
    or all file systems by default.
    
    Mandatory arguments to long options are mandatory for short options too.
      -a, --all             include pseudo, duplicate, inaccessible file systems
      -B, --block-size=SIZE  scale sizes by SIZE before printing them; e.g.,
                               '-BM' prints sizes in units of 1,048,576 bytes;
                               see SIZE format below
      -h, --human-readable  print sizes in powers of 1024 (e.g., 1023M)
      -H, --si              print sizes in powers of 1000 (e.g., 1.1G)
      -i, --inodes          list inode information instead of block usage
      -k                    like --block-size=1K
      -l, --local           limit listing to local file systems
          --no-sync         do not invoke sync before getting usage info (default)
          --output[=FIELD_LIST]  use the output format defined by FIELD_LIST,
                                   or print all fields if FIELD_LIST is omitted.
      -P, --portability     use the POSIX output format
          --sync            invoke sync before getting usage info
          --total           elide all entries insignificant to available space,
                              and produce a grand total
      -t, --type=TYPE       limit listing to file systems of type TYPE
      -T, --print-type      print file system type
      -x, --exclude-type=TYPE   limit listing to file systems not of type TYPE
      -v                    (ignored)
          --help     display this help and exit
          --version  output version information and exit
    
    Display values are in units of the first available SIZE from --block-size,
    and the DF_BLOCK_SIZE, BLOCK_SIZE and BLOCKSIZE environment variables.
    Otherwise, units default to 1024 bytes (or 512 if POSIXLY_CORRECT is set).
    
    The SIZE argument is an integer and optional unit (example: 10K is 10*1024).
    Units are K,M,G,T,P,E,Z,Y (powers of 1024) or KB,MB,... (powers of 1000).
    Binary prefixes can be used, too: KiB=K, MiB=M, and so on.
    
    FIELD_LIST is a comma-separated list of columns to be included.  Valid
    field names are: 'source', 'fstype', 'itotal', 'iused', 'iavail', 'ipcent',
    'size', 'used', 'avail', 'pcent', 'file' and 'target' (see info page).
    
    GNU coreutils online help: <https://www.gnu.org/software/coreutils/>
    Full documentation <https://www.gnu.org/software/coreutils/df>
    or available locally via: info '(coreutils) df invocation'

    Related: df man page

Discuss the article:

Comment anonymously. Login not required.

Share!