[TriLUG] Disk space calculations in Linux

Kevin Hunter hunteke at earlham.edu
Thu Jan 24 18:07:36 EST 2008


At 5:15p -0500 on 24 Jan 2008, James Tuttle wrote:
> While we're at it, let's talk about du versus ls versus other size
> calculating utilities.  I never know what to use.

man pages will begin to point you the right direction.  As far as 
utilities go, ls and du serve two different roles: list files, and show 
disk usage.

ls /can/ list files recursively and show their size, but it's oriented 
towards files more than disk usage.  Some common arguments of ls

ls     # Straight up list your files in your directory.
ls -l  # list in long format (incl. date, size, inode links, etc.)
ls -lh # same as -l, but show size human-readable (e.g G, M, K)
ls -lk # same as -l, but show in convert to kilobytes

and if you want, ls -R lists recursively.

du, on the other hand won't give you individual file information other 
than size and is meant for finding what files are the space hogs.  Try

du
du -h
du -hs
du -hs /dir1 /dir2 *
du -ch

Off the top of my head, df and *fdisk come to mind.  You may find this 
page a good starting point as well:

http://en.wikipedia.org/wiki/Ls

Kevin



More information about the TriLUG mailing list