en
  English
Phone :  +370 (5) 204-1903
Email: sales@1gbits.com
  1. Dedicated server
  2. Blog
  3. DF command in Linux: explained

DF command in Linux: explained

While using Linux, you'll want to understand how much storage a given file system takes up, including how much space is available on that operating system. Since LINUX is a command-oriented operating system, it has a command-line utility for this. The df command in Linux displays the amount of storage space used by the file system. "Disk filesystem" is what the 'df' stands for. It specifies how many blocks are used, how many blocks are open, and where the file system is placed. In this tutorial, you will get to know everything about df command and how you can easily use it in Linux.

Linux Tutorial Jun 17, 21 by Nisal N 6 min Read
DF command in Linux: explained

How Does the df Command Work?

df [OPTION]...[FILE]...

If you have a file called xyz.txt and want to see how much storage space is used on the file system that holds it, you can use df as follows:

// using df for a specific file //

$df xyz.txt

/dev/th2 1957125 1512 1955712 1% /snap/core 

These columns are File system,1K-blocks, Used, Available, Use%, Mounted on, respectively.

df Usage Examples with Options

  • To view size in 1024th power, use the -h option.

df -h /home/xyz

Output 

/dev/sda10 70G 60G 10.0G 85.7% /home

These columns are File system,1K-blocks, Used, Available, Use%, Mounted on, respectively

  • Use the -a alternative to view the whole file system.

df -a

Output

/dev/sda20      78674504  67424540   7415321  90%   /home
/dev/sds2        517905      31909         486996   7%       /boot/efi
tmpfs             805624       12              805612   1%      /run/user/121
tmpfs             805624       64              805560   1%      /run/user/1000
gvfsd-fuse             0         0                    0            -        /run/user/1000/gvfs

These columns are File system, 1K-blocks, Used, Available, Use%, Mounted on, respectively

  • To display sizes in 1000th power, use the -H option.

df -H /home/xyz

Output

/dev/sda10       81G   70G  7.5G  91% /home

These columns are File system,1K-blocks, Used, Available, Use%, Mounted on respectively

  • Using the --total alternative to get the grand total.

df --total

Output

udev             3886816          0               388681       0%       /dev
tmpfs            803624         10072          793552       2%       /run
/dev/sda9      68217056    18236336     46697536     28%     /
tmpfs            4023116        50140          3972976      2%      /dev/shm
tmpfs            5120            4               5116         1%     /run/lock
tmpfs            4023116          0              4023116      0%      /sys/fs/cgroup
/dev/loop0    88732          88732           0            100%    /snap/simplescreenrecorder/1
/dev/loop2    85887          85887           0            100%    /snap/core/3748
/dev/loop3    85887         85887           0            100%   /snap/core/3604
/dev/loop1    84428          84428           0            100%   /snap/core/3887
/dev/sda10   78873504    67529320     7314540      91%   /home
/dev/sda1     508904        30908           477996       7%   /boot/efi
tmpfs            808624          12             8086         1%   /run/user/121
tmpfs            808624          64             808560      1%   /run/user/1000
total          162305550   86010792    68890820    56%     -

The total is defined in the last row of the above table production. These columns are File system,1K-blocks, Used, Available, Use%, Mounted on, respectively.

  1. To see the file type, use the -T switch.

df -T /home/xyz

Output 

/dev/sda10 ext3 79873704 68528248 7415842 91% /home

From the given data, you can see the file type of /home/xyz is ext3. These columns are File system,1K-blocks, Used, Available, Use%, Mounted on, respectively. You can also use the –help alternative for further assistance:

df --help

Conclusion

The df function in the Linux operating system is used to see the details about the disk size and management. Use various options available for the df command, and we can see the disk size in various formats and with various parameters provided in the above example. We hope that our information helped you to understand the df command and where you can easily use it. 

author img

Nisal N

Computers has always fascinated me since I was a kid and here we are. I love travelling for 2 reasons: the first one to see a new part of the world and second (the most important one) to experience the rich culture hidden among the country and people. I'm pretty good at cooking but very poor when it comes to baking.

Leave A Comment