3

My root directory "/" on my ubuntu server is filling up. I'd like to look at the folders in it and try to spot what's filling up. Can someone please tell me how to show the sizes of the folders in the root directory "/" (I think that's root, I always get confused with home "~")

Also is there a way to show the size of folders on a file system "/dev/nvme1n1p2"

code:

df -h /

output:

Filesystem      Size  Used Avail Use% Mounted on
/dev/nvme1n1p2  228G  213G  3.8G  99% /

1 Answers1

5

Yes! You could try du -chd1 /.

This will give you output similar to the following:

4.3G    /var
264M    /opt
...

Then to narrow down results you could replace / with any folder you'd like, such as du -chd1 /var

EDIT: I have edited the command with the suggestion from muru, and now this will include dot folders if scanning something like your home directory.

ryan77627
  • 81
  • 5
  • Instead of -s /*, you should use -d1 /. Otherwise you might miss dot folders in / (unlikely, but if you're looking to free up space, then accidentally created folders are often candidates) – muru Nov 19 '21 at 06:05
  • Ah, you're right. I always forget to include the dot folders whenever I use * (whether that be copying or otherwise). Thanks! – ryan77627 Nov 19 '21 at 20:57