Saturday, April 20, 2013

Listing sizes of stuff

Got to wondering how to show how big a file is, including all the files and folders inside of it. When one uses:

ls -l

to list files it will list every folder as size 4096 (or 4.0K if use use the -h flag as well). Well I'm pretty sure that I have more than 4KB of Music so I got looking for a way to show how big the file is. It was pretty easy to find. simply

du -hs /path/to/directory

the s flag is for summary, that way when you use the command it doesn't show the size of everything recursively, just the total.

Along with this stuff I was trying to see how to list the size of the whole drive and other partitions. One method was to use

sudo fdisk -l

but that only listed one partition for me, and didn't change the size to human readable form a much better command I found was df with the -h flag for human readable form thus

df -h

will list all partitions and their sizes, not just the one.

No comments:

Post a Comment