AI Workshop: learn to build apps with AI →
System Information: du - Disk Usage

Join the AI Workshop and learn to build real-world apps with AI. A hands-on, practical program to level up your skills.


The du command will calculate the size of a directory as a whole:

du

The number 32 here is the size in bytes.

Running du * will calculate the size of each file and directory in the current folder:

You can set du to display values in megabytes using du -m, and gigabytes using du -g.

The -h option will show a human-readable notation for sizes, adapting to the size:

Adding the -a option will print the size of each file in the directories, too:

A handy thing is to sort the directories by size:

du -h <directory> | sort -nr

then pipe to head to get only the first 10 results:

The du command works on Linux, macOS, WSL, and anywhere you have a UNIX environment

Lessons in this unit:

0: Introduction
1: uname - System Information
2: whoami - Current User
3: who - Logged In Users
4: df - Disk Free Space
5: ▶︎ du - Disk Usage
6: ps - Process Status
7: top - Task Manager
8: env - Environment Variables
9: printenv - Print Environment
10: Linux, no space left on device
11: How to find the process that is using a port