It's More Fun to Compute ([info]pixel_juice) wrote in [info]linux,
@ 2007-09-16 14:57:00
Previous Entry  Add to memories!  Tell a Friend!  Next Entry
List a total directory size.
Today I FINALLY learned a command line command that I have been trying to figure out for ages. I know to many of you this is probably VERY noobish stuff, but for me it was a nice little breakthrough. Funny it comes 4 years into my usage.

I store loads of stuff on my server and I often want to puTTY in and just get a quick size for a given folder. Today I discovered the "du" command. :)

Let say I want to see the size of my music folder:
du -sh music

If I want to see the various sizes of the folders within my music folder:
du -h music

Tada! Let me know of other, better ways to do this.

Hope this helps someone.



(Post a new comment)


[info]azekeil
2007-09-16 08:09 pm UTC (link)
man -k or apropos are your friends :)

(Reply to this) (Thread)


[info]pixel_juice
2007-09-16 08:41 pm UTC (link)
Yup and I had problems getting the keywords write. I could find LS commands that would display sizes and df commands to show free space, but I couldn't get down with summaries of directory usage. But anyway, this works great.

I wasn't aware of apropos. Thanks!

(Reply to this) (Parent)


[info]userunknown
2007-09-16 09:02 pm UTC (link)
try

du -ac | sort -n

(Reply to this) (Thread)


[info]pixel_juice
2007-09-16 09:09 pm UTC (link)
Interesting. Thanks!

I missed the -c option.

(Reply to this) (Parent)


[info]x_eleven
2007-09-16 09:39 pm UTC (link)
Might also want to take a look at these:

BASH Programming Introduction

ADvanced BASH Scripting Guide

Lots of discussions of useful commands. If you installed EMACS, you also get with it an extensive set of "info" documentation as well.

(Reply to this) (Thread)


[info]pengshui_master
2007-09-16 09:56 pm UTC (link)
Actually in gnome yelp will render info and man page as well.

Personally I find yelp the only sane info browser - which is odd because many of the stuff that gnome does I'm not a fan of.

(Reply to this) (Parent)


[info]seriouslyuguys
2007-09-17 01:01 am UTC (link)
This is exactly how I felt when I found xargs after looking for it for two years.

(Reply to this)


[info]mattcaron
2007-09-17 01:17 pm UTC (link)
du -ks --max-depth=1 | sort -rn

Will show the size of all dirs, incuding one that starts w/ periods, and sort them so that the largest ones are at the bottom.

Caveats:
- Does not show the size of files in the current dir, only directories
- Shows it in k (because otherwise sort doesn't work very nicely).

(Reply to this)


[info]theweaselking
2007-09-17 01:54 pm UTC (link)
I use "du -sxch *" for the current size of all directories in the current directory.

Or "du -sxch music/*" for subfolders of music, etc.

(Reply to this)


Create an Account
Forgot your login or password?
Login w/ OpenID
English • Español • Deutsch • Русский…