The fastest way to see how much space a folder uses

The du command shows you how much disk space a directory and everything inside it takes up. Run du -sh /path/to/directory and you get a single number: the total size. The -s flag means "summary" (one total, not a breakdown of every subfolder), and -h means "human-readable" (showing MB or GB instead of raw bytes).

If you want to see the size of your current folder without typing a path, use du -sh . — the dot means "here". For your home directory from anywhere, use du -sh ~.

Key Takeaways

  • du -sh /path/to/directory gives you the total size of a folder in a format you can read, like 2.3G or 450M.
  • The -s flag shows only the summary total; without it, du lists every subfolder separately, which is slower on large directories.
  • du -sh * in a folder shows the size of each item inside it, so you can find what is taking up the most space.
  • If a folder requires permission you do not have, du will skip it silently; use sudo du -sh /path to see everything, but this requires your password.

Seeing what is taking up space inside a folder

When you want to know which subfolder or file is the culprit, use du -sh * in that directory. This lists the size of each item at the top level. Run it in your Downloads folder and you might see one video file taking up 3GB while everything else is under 100MB.

To sort the results from largest to smallest, pipe the output to sort: du -sh * | sort -h. The -h flag in sort tells it to understand sizes like 1G and 500M, not just treat them as text. Now the biggest items appear at the bottom, so you can scroll down and spot them immediately.

If you want to go one level deeper and see subfolders inside subfolders, use du -h /path/to/directory without the -s flag. This is slower on large directories because du has to measure everything, but it shows you the full tree of what is where.

Understanding du output and what the numbers mean

When du shows you a size, it is counting the actual data stored in files, plus the space used by the folder structure itself (which is usually tiny). If you copy a file and du shows it takes 500MB, that is the real amount of disk space it occupies, not some theoretical size.

One thing to watch: if a file is a symbolic link (a shortcut to another file), du counts only the link itself, not the file it points to. This is usually what you want — you do not want to count the same file twice. If you need to count what a link points to, use du -Lsh /path (capital L), which follows links.

Another edge case: if you run du on a folder you do not have permission to read, du skips those subfolders and shows you only what it can see. The number you get is incomplete. If you own the folder or have sudo access, run sudo du -sh /path to see everything, but remember that sudo requires your password and should only be used when necessary.

Comparing du with other tools

The ncdu command is an interactive version of du — it shows you a folder tree you can navigate with arrow keys, and you can drill down into any subfolder to see what is inside. If your system has ncdu installed, run ncdu /path/to/directory and use the arrow keys to explore. Press q to quit. This is slower than plain du for a quick check, but faster if you need to hunt through many levels of folders.

df is a different command that shows you how much space is left on your entire hard drive or partition, not the size of a specific folder. Use df -h to see all your drives and how full each one is. It answers "how much room do I have left" rather than "what is taking up my space".

The ls -lh command shows the size of individual files in a folder, but not the total size of subfolders. It is useful for spotting one huge file, but du is what you need to find out why an entire folder is large.

Checking directory size without typing paths

If you are already inside a folder in your terminal, you do not need to type the full path. Use du -sh . to measure the current folder, or du -sh .. to measure the parent folder (one level up). The dot is shorthand for "here" and two dots mean "the folder above this one".

To see the size of everything in your current folder broken down by item, type du -sh * with no path at all. The asterisk means "everything here". If you want to include hidden files and folders (those starting with a dot), use du -sh .[^.]* * instead, though this is rarely necessary for finding space hogs.

Handling large directories and slow performance

On a folder with millions of files, du can take a while because it has to read every single one. If you are checking a very large directory and du seems stuck, it is probably still working — du does not show progress. You can open another terminal window and check something else while it runs.

If you want to limit du to only the top level of a folder without going into subfolders, use du -sh --max-depth=1 /path. This shows you the size of each subfolder but does not measure what is inside them. It is much faster on deep folder structures and often tells you enough to find the problem.

On some systems, network folders or cloud storage mounted as directories can be very slow to measure because du has to check every file over the network. If you are checking a folder like that, expect du to take longer than usual.

Frequently Asked Questions

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

File managers sometimes show "apparent size" (the actual data in the file) while du shows "disk usage" (how much space the file takes on disk, including padding). For most files the difference is tiny, but on some systems or file types it can be noticeable. Both numbers are correct — they just measure different things.

Can I check the size of a folder I do not own?

You can run du on any folder you have permission to read. If you do not have read permission, du skips those subfolders silently and shows you an incomplete total. If you own the folder or have sudo access, use sudo du -sh /path to see everything, but this requires your password.

How do I find the largest files in a directory, not just the largest folders?

Use find /path -type f -exec ls -lh {} \; | sort -k5 -h to list all files sorted by size, largest last. This is slower than du because it has to examine every file individually, but it shows you individual files rather than folder totals. For a quicker look, use ls -lhS to sort files in the current folder by size.

What does the -h flag actually do?

The -h flag tells du to show sizes in human-readable format: K for kilobytes, M for megabytes, G for gigabytes. Without it, du shows sizes in kilobytes by default, which is hard to read for large folders. Always use -h unless you have a specific reason not to.

Can I save the output of du to a file so I can look at it later?

Yes. Use du -sh /path/to/directory > filename.txt to save the result to a file. The > symbol redirects the output. You can then open the file in any text editor. For a more detailed report, use du -h /path/to/directory > report.txt to save the full breakdown of every subfolder.