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 the Linux df command and how you can easily use it in Linux.

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. The df command is used to check disk space in Linux. 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%, and 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%, and 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%, and 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%, and 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%, and 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%, and Mounted on, respectively. You can also use the –help alternative for further assistance:

df --help

Conclusion

The Linux command to check disk space is the df function. Using various options available for the df command, we can see the disk size in various formats and with various parameters as seen in the above example. We hope that our information helped you to understand the df command and where you can easily use it. If you're looking to host a website or run complex applications, buy linux vps can provide you with the power, flexibility, and security you need to meet your goals.

People also read: