Never Ending Security

It starts all here

Df Commands Cheatsheet

df Command Examples

df Command Examples – The ‘df‘ command stand for “disk filesystem“, is used to get full summary of available and used disk space of a file system on Linux. Using the ‘-h‘ switch (df -h) will show the file system disk space statistics in “human readable” format

Check File System Disk Space Usage

The “df” command shows the information about device name, total blocks, total disk space, used disk space, available disk space and mount points on a file system.

[cyberpunk@n0where.net ~]# df

Filesystem           1K-blocks      Used Available Use% Mounted on
/dev/sda2             78361192  23185840  51130588  32% /
/dev/sda2             24797380  22273432   1243972  95% /home
/dev/sda2             29753588  25503792   2713984  91% /data
/dev/sda2               295561     21531    258770   8% /boot
tmpfs                   257476         0    257476   0% /dev/shm

Display Information for All FS Disk Space Usage

Show file system information with system disk usage and memory utilization.

[cyberpunk@n0where.net ~]# df -a

Filesystem           1K-blocks      Used Available Use% Mounted on
/dev/sda2             78361192  23186116  51130312  32% /
proc                         0         0         0   -  /proc
sysfs                        0         0         0   -  /sys
devpts                       0         0         0   -  /dev/pts
/dev/sda2             24797380  22273432   1243972  95% /home
/dev/sda2             29753588  25503792   2713984  91% /data
/dev/sda2               295561     21531    258770   8% /boot
tmpfs                   257476         0    257476   0% /dev/shm
none                         0         0         0   -  /proc/sys/fs/binfmt_misc
sunrpc                       0         0         0   -  /var/lib/nfs/rpc_pipefs

Show Disk Space Usage in HRF

By default df displays information in bytes, but we can force it to show its output in Human Readable formats by using ‘-h’

[cyberpunk@n0where.net ~]# df -h

Filesystem            Size  Used Avail Use% Mounted on
/dev/sda2              75G   23G   49G  32% /
/dev/sda2              24G   22G  1.2G  95% /home
/dev/sda2              29G   25G  2.6G  91% /data
/dev/sda2             289M   22M  253M   8% /boot
tmpfs                 252M     0  252M   0% /dev/shm

Display /home File System Information

Show information about /home in human readable format:

[cyberpunk@n0where.net ~]# df -hT /home

Filesystem      Type    Size  Used Avail Use% Mounted on
/dev/sda2           ext3     24G   22G  1.2G  95% /home

Display File System Information in Bytes

Display all file system information and usage in 1024-byte blocks with ‘-k‘ switch

[cyberpunk@n0where.net ~]# df -k

Filesystem           1K-blocks      Used Available Use% Mounted on
/dev/sda2             78361192  23187212  51129216  32% /
/dev/sda2             24797380  22273432   1243972  95% /home
/dev/sda2             29753588  25503792   2713984  91% /data
/dev/sda2               295561     21531    258770   8% /boot
tmpfs                   257476         0    257476   0% /dev/shm

Display File System Information in MB

Display information about  file system usage in MB (Mega Byte) – The  ‘-m‘ switch

[cyberpunk@n0where.net ~]# df -m

Filesystem           1M-blocks      Used Available Use% Mounted on
/dev/sda2                76525     22644     49931  32% /
/dev/sda2                24217     21752      1215  95% /home
/dev/sda2                29057     24907      2651  91% /data
/dev/sda2                  289        22       253   8% /boot
tmpfs                      252         0       252   0% /dev/shm

Display Information of File System in GB

Display information about  file system usage in GB (Gigabyte) – the ‘df -h‘ switch.

[cyberpunk@n0where.net ~]# df -h

Filesystem            Size  Used Avail Use% Mounted on
/dev/sda2              75G   23G   49G  32% /
/dev/sda2              24G   22G  1.2G  95% /home
/dev/sda2              29G   25G  2.6G  91% /data
/dev/sda2             289M   22M  253M   8% /boot
tmpfs                 252M     0  252M   0% /dev/shm

Display File System Inodes

Use ‘-i‘ switch to display the number of used inodes (and percentage).

[cyberpunk@n0where.net ~]# df -i

Filesystem            Inodes   IUsed   IFree IUse% Mounted on
/dev/sda2           20230848  133143 20097705    1% /
/dev/sda2            6403712  798613 5605099   13% /home
/dev/sda2            7685440 1388241 6297199   19% /data
/dev/sda2              76304      40   76264    1% /boot
tmpfs                  64369       1   64368    1% /dev/shm

Display File System Type

Show file system type with ‘T‘ switch:

[cyberpunk@n0where.net ~]# df -T

Filesystem      Type   1K-blocks  Used      Available Use% Mounted on
/dev/sda2           ext3    78361192  23188812  51127616  32%   /
/dev/sda2           ext3    24797380  22273432  1243972   95%   /home
/dev/sda2           ext3    29753588  25503792  2713984   91%   /data
/dev/sda2           ext3    295561     21531    258770    8%    /boot
tmpfs           tmpfs   257476         0    257476    0%   /dev/shm

Include Certain File System Type

If you want to display only certain file system type use the ‘-t‘ switch:

[cyberpunk@n0where.net ~]# df -t ext3

Filesystem           1K-blocks      Used Available Use% Mounted on
/dev/sda2              78361192  23190072  51126356  32% /
/dev/sda2              24797380  22273432   1243972  95% /home
/dev/sda2              29753588  25503792   2713984  91% /data
/dev/sda2                295561     21531    258770   8% /boot

Exclude Certain File System Type

Exclude certain file system type from the output with  ‘-x‘ switch:

[cyberpunk@n0where.net ~]# df -x ext3

Filesystem           1K-blocks      Used Available Use% Mounted on
tmpfs                   257476         0    257476   0% /dev/shm

Display df Command Information

Form more examples use ‘–help‘ switch. This will display a list of available option that that you can use with df command.

[cyberpunk@n0where.net ~]# 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 dummy file systems
  -B, --block-size=SIZE use SIZE-byte blocks
  -h, --human-readable  print sizes in human readable format (e.g., 1K 234M 2G)
  -H, --si              likewise, but use powers of 1000 not 1024
  -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)
  -P, --portability     use the POSIX output format
      --sync            invoke sync before getting usage info
  -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

SIZE may be (or may be an integer optionally followed by) one of following:
kB 1000, K 1024, MB 1000*1000, M 1024*1024, and so on for G, T, P, E, Z, Y.

Report bugs to <bug-coreutils@gnu.org>.

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s