How to check Disk size, file size and directory size in Linux (Cent OS and Ubuntu)

Check all disk size

You can use df command to see all available disk partition, total size and available size.

$ df

It display 6 columns.

  • File system – It shows the type of files like /dev/loop0, /dev/xvda1, udev or tempfs.
  • Blocks – It shows number of blocks per KB.
  • Used – It shows number of KB used on that partition.
  • Available – It shows number of KB available on that partition.
  • Used Percentage – It shows how much % you have used on that partition.
  • Mounted On – It shows mounted path like /dev, /run, / , dev/shm, run/lock or /snap/core information of that partition.

To see the better format you can use

$df -h

Check all Folder sizes with du command

$ du

To see the better format you can use du with option -h

$ du -h

To find directory level used space you need to use command du -d 1 <file path>. Here d 1 means directory level 1 and if you want to check 2 level of deep directory you need to use -d 2 option.

$ sudo du -d 1 /var

To see the detail in better way you use -h option.

$ sudo du -d 1 -h /var

Leave a Comment