Seeing a Folder’s Size in the Terminal

Absolutely, Daryn!


The command you’ll want to use from the Terminal is ‘du‘ which is short for, “display disk usage statistics”. Just invoking ‘du‘ will give you too detailed of a list (and not the answer you want), but with a couple of switches and a filename target you’ll get what you’re looking for. From the Terminal, type: du -sh * and that will give you a listing of your files and folders with their sizes.


 but with a couple of switches and a filename target you Seeing a Folder’s Size in the Terminal

By issuing ‘du -sh *’ in the Terminal I can see the sizes of all my files and folders


So you understand what you just typed (or are about to type):



  • du – that’s the command

  • -s – this switch tells ‘du’ to show you one line per filename specified

  • -h – this switch tells ‘du’ to output the sizes in ‘human-readable’ format. Because we’re using two switches, s and h, we can combine them together with ‘-sh

  • * – this is the filename target, and the asterisk means “everything that doesn’t start with a period.” You could specify a single directory here or a list, or individual files. du will take them all.


For anyone doing this from the Terminal of a normally-booted Mac, this will work exactly as you see above. Unfortunately Recover Mode is a little different because the ‘du’ command isn’t included in the skeleton system you’re running. You’ll have to point to a different volume that contains it. Thankfully, your Mac’s normal hard drive has this, and it will work even if it’s in read-only mode. You’d modify the above command and add “/Volumes/[Volume Name]/usr/bin/” to the beginning of the statement, where [Volume Name] is the name of your hard drive. If your hard drive name contains a space, it’s safer to wrap the whole thing in double quotes as I have just to make life easier.


My hard drive is named “Back Seat Betty” because I name all my drives after Miles Davis songs, so for me that command would be:


“/Volumes/Back Seat Betty/usr/bin/du” -sh *


The Terminal can be both handy and efficient, not to mention fun. Tread thoughtfully and deliberately, and always remember to use the ‘man‘ command to get details if you’re unsure. For today’s lesson, typing ‘man du‘ will give you more information about the ‘du’ command than you ever wanted. Enjoy!


0 Response to "Seeing a Folder’s Size in the Terminal"

Post a Comment

Iklan Atas Artikel

Iklan Tengah Artikel 1

Iklan Tengah Artikel 2

Iklan Bawah Artikel