Flash Sale:75% Off Hosting + Free DomainEnds in13h47m14sView Plans
Hostvento logoHostvento

Check Folder Size and Disk Space in Linux (du and df)

Find out how big a folder is and how much space is left on the disk.

VPS and Cloud Servers2 min read11 screenshots

Why check

  • Find big files and folders that eat your space.
  • Free space before the disk is full.
  • Spot a folder that grows for no reason. That can point to logs gone wild or even malware.

Use du for folders and df for whole disks.

du: size of a folder

Basic use:

du /path/to/directory
du output in blocks

The numbers are hard to read. Add -h to see KB, MB or GB:

du -h ~/Documents
du with human-readable sizes

Show only the first level of subfolders with --max-depth=1:

du -h --max-depth=1
du with max-depth

Show only the total of a folder with -s:

du -sh
Total size of the current folder

The dot . means the current folder. Give a path to check another one: du -sh /var/log.

Find what fills the disk. This lists the first-level folders from big to small:

du -h --max-depth=1 / | sort -rh
Largest folders on the system

Go into the biggest folders one by one and run the command again.

df: free space on a disk

df
df output

Add -h for readable sizes:

df -h
df with human-readable sizes

Check one partition:

df -h /dev/sda2
df for one partition

Show the file system type with -T:

df -T
df with file system types

Check inodes (the number of files) with -i. A disk can be "full" because it ran out of inodes:

df -i
df showing inodes

Combine the options:

df -hT
df -hT

Quick recap

  • du -sh folder gives the size of one folder.
  • du -h --max-depth=1 / | sort -rh finds the biggest folders.
  • df -h shows free space, df -i shows free inodes.