Check directory/dir/file size in Linux

#check partition sizes
df -h

#check directory size
du -s -h /var/log/

#check every directory and file sizes under a dir.
du -s -h /var/log/*

#check individual size size
du -s -h /var/log/lastlog

Very useful. Got it from here.

Linux commandline lessons

  • df -h tells you about your devices’ storage usage
  • du -sh <directory> gives you an idea how much space a directory is using
  • Logfiles are your friends, until one day they become your enemy and eat up all storage
  • To truncate a file (remove contents), just use >/var/log/log.file