df - disk file systemdf - disk file system

df command (df – disk file system) – Linux command is one of power full command which is widely used to enhance and improve the server environment. During building shells script, we might get file system issues where disk file is full or so on. The same scenario could be happen in production issues as well. Hence getting challenge to look the actual file system and read it carefully will be always right to perform the task.

1. Disk file system related Linux command :

  1. df – disk file system
  2. du – disk usages.

 2. df command (df – disk file system 🙂

Below are the list of df command which is frequently used in Linux machine.

df -h : display result in human readable format.

df -m : display result of file system usages in MB.

df -k : display file system usages in kb.

df – T :  display file system type with new column.

df/home :  display information of directory /home.

df –help – if you need any help of df command.

 

if you interested in another Linux article. You can read this amazing article as well.

Unix – Command grep, sed and awk – Best Practice

Watch below video to understand df command in Linux.

https://youtu.be/CumpF98F2BY

logs :

sachin@pwr-VirtualBox:~$ df -h

Filesystem      Size  Used Avail Use% Mounted on

udev            1.7G     0  1.7G   0% /dev

tmpfs           346M  1.7M  344M   1% /run

/dev/sda1        35G   12G   21G  37% /

tmpfs           1.7G     0  1.7G   0% /dev/shm

tmpfs           5.0M  4.0K  5.0M   1% /run/lock

tmpfs           1.7G     0  1.7G   0% /sys/fs/cgroup

/dev/loop2       66M   66M     0 100% /snap/gtk-common-themes/1519

/dev/loop0      768K  768K     0 100% /snap/gnome-characters/761

sachin@pwr-VirtualBox:~$ df -m

Filesystem     1M-blocks  Used Available Use% Mounted on

udev                1695     0      1695   0% /dev

tmpfs                346     2       344   1% /run

/dev/sda1          34972 12184     20981  37% /

tmpfs               1726     0      1726   0% /dev/shm

tmpfs                  5     1         5   1% /run/lock

tmpfs               1726     0      1726   0% /sys/fs/cgroup

/dev/loop2            66    66         0 100% /snap/gtk-common-themes/1519

/dev/loop0             1     1         0 100% /snap/gnome-characters/761

/dev/loop1            92    92         0 100% /snap/gtk-common-themes/1535

sachin@pwr-VirtualBox:~$ df -k

Filesystem     1K-blocks     Used Available Use% Mounted on

udev             1734712        0   1734712   0% /dev

tmpfs             353452     1680    351772   1% /run

/dev/sda1       35810848 12475788  21483772  37% /

tmpfs            1767248        0   1767248   0% /dev/shm

tmpfs               5120        4      5116   1% /run/lock

tmpfs            1767248        0   1767248   0% /sys/fs/cgroup

/dev/loop2         66816    66816         0 100% /snap/gtk-common-themes/1519

/dev/loop0           768      768         0 100% /snap/gnome-characters/761

sachin@pwr-VirtualBox:~$ df -T

Filesystem     Type     1K-blocks     Used Available Use% Mounted on

udev           devtmpfs   1734712        0   1734712   0% /dev

tmpfs          tmpfs       353452     1680    351772   1% /run

/dev/sda1      ext4      35810848 12475788  21483772  37% /

tmpfs          tmpfs      1767248        0   1767248   0% /dev/shm

tmpfs          tmpfs         5120        4      5116   1% /run/lock

tmpfs          tmpfs      1767248        0   1767248   0% /sys/fs/cgroup

/dev/loop2     squashfs     66816    66816         0 100% /snap/gtk-common-themes/1519

/dev/loop0     squashfs       768      768         0 100% /snap/gnome-characters/761


sachin@pwr-VirtualBox:~$ df /home

Filesystem     1K-blocks     Used Available Use% Mounted on

/dev/sda1       35810848 12475788  21483772  37% /

sachin@pwr-VirtualBox:~$ 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).

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: <http://www.gnu.org/software/coreutils/>

Full documentation at: <http://www.gnu.org/software/coreutils/df>

or available locally via: info '(coreutils) df invocation'

sachin@pwr-VirtualBox:~$

 

You can watch full video to understand more about this topic.

2 thoughts on “How to find the file system size in Linux using df command.”

Leave a Reply

Your email address will not be published. Required fields are marked *

Netflix’s Overall Architecture. Gold is money every thing else is credit