The fastest way to see folder sizes

The du command (short for "disk usage") tells you how much space a folder and everything inside it is taking up. Open your terminal and type du -sh /path/to/folder — replace /path/to/folder with the actual folder you want to check. The -s flag shows just the total for that folder, and -h makes the number human-readable (like "2.3G" instead of "2400000").

If you want to see the size of every subfolder inside a directory, use du -sh /path/to/folder/*. This shows you which subdirectories are eating the most space, ranked from smallest to largest. Add | sort -h at the end to sort them automatically — the command becomes du -sh /path/to/folder/* | sort -h.

Key Takeaways

  • du -sh /path/to/folder shows the total size of one folder in a format you can read.
  • du -sh /path/to/folder/* breaks down the size of every subfolder so you can see which ones are largest.
  • Add | sort -h to the end of any du command to sort results from smallest to biggest.
  • The ncdu tool provides an interactive menu where you can browse folders and their sizes without typing multiple commands.

Understanding du output and flags

When you run du -sh, the output shows two things: a number (the size) and a path (the folder). The size uses standard units: K for kilobytes, M for megabytes, G for gigabytes. A folder showing "5.2G" is using 5.2 gigabytes of space.

The flags matter. Without -h, you get the size in blocks (usually 1024 bytes each), which is hard to read. Without -s, du lists every subfolder and sub-subfolder, which creates a long list. Together, -sh gives you what you actually want: one readable number per folder.

If you want to see sizes in a specific unit no matter what, use -BM (for megabytes) or -BG (for gigabytes) instead of -h. For example, du -sB G /path/to/folder always shows the result in gigabytes.

Finding your largest folders quickly

When you have a directory with many subfolders, you often want to know which ones are taking up the most space. Run du -sh /path/to/folder/* | sort -rh — the -r flag reverses the sort order, so the biggest folders appear first. This is the fastest way to spot what's consuming your disk.

If the list is long, pipe it to head to see only the top results: du -sh /path/to/folder/* | sort -rh | head -10 shows the 10 largest subfolders. Change the number to see more or fewer results.

For your home directory specifically, use du -sh ~/* instead of typing the full path. The tilde (~) is shorthand for your home folder, so this command when ready shows you what's largest in your user account.

Using ncdu for an interactive view

If typing commands feels tedious, ncdu (NCurses Disk Usage) provides a menu-based interface. Install it with sudo apt install ncdu on Ubuntu or Debian, or sudo yum install ncdu on Red Hat systems. Then run ncdu /path/to/folder and you get an interactive list you can navigate with arrow keys.

Inside ncdu, press the down arrow to move between folders, press Enter to open a folder and see what's inside it, and press 'q' to quit. The largest items appear at the top by default. This is especially useful when you're exploring a folder structure you don't know well — you can drill down into subfolders without typing new commands each time.

Checking disk space across your whole system

To see how much total space your entire system is using, run df -h. This shows every mounted disk or partition, how much space is used, how much is free, and what percentage is full. The output includes your main hard drive and any external drives or network storage you have connected.

If you only care about one specific partition, use df -h /path/to/folder — it shows you the disk that folder lives on and how full that disk is. This is useful when you're trying to figure out whether you actually have room to read or copy something.

Excluding certain folders from your count

Sometimes you want to know a folder's size but exclude certain subfolders — for example, you might want to count your project folder but skip the backup subdirectory. Use the --exclude flag: du -sh --exclude=backup /path/to/folder. Replace "backup" with the name of the subfolder you want to skip.

To exclude multiple folders, repeat the flag: du -sh --exclude=backup --exclude=cache /path/to/folder. You can also use wildcards: du -sh --exclude='*.tmp' /path/to/folder excludes any file or folder with a .tmp extension.

Frequently Asked Questions

Why does du show a different size than my file manager?

File managers sometimes count the space a file takes on disk differently than du does. A 1MB file might use 4MB on disk because of how the filesystem allocates space. Du shows the actual disk usage, which is usually what you care about when you're running out of room.

How do I check the size of a folder I don't have permission to read?

You may need to run the command with sudo: sudo du -sh /path/to/folder. Be careful with sudo — only use it when you know the folder exists and you have a reason to access it. If you still get a "permission denied" error, you don't have access to that folder even as an administrator.

Can I save the output to a file instead of just looking at it?

Yes. Add > filename.txt to the end of any command: du -sh /path/to/folder/* | sort -rh > sizes.txt. This creates a file called sizes.txt with the results, which you can open in a text editor or share with someone else.

What's the difference between du and ls -lh?

The ls -lh command shows the size of individual files, but not the total size of a folder. Du shows the total size of a folder and everything inside it, which is what you need when you're trying to free up space or understand what's taking room.