Hi Guys,
Just a quick one here, If you want to know size of a directory/folder you can use du command which is short form to disk usage
You can cd to that directory and run this command
Forget about the fact that I am logged in as root, I was just doing some weird things.
Option 1
1 |
du -h | tail -n 1 |
Option 2
1 |
du -h --max-depth=0 |
or
1 |
du -hs |
Now the above commands will print fill directory size but just in case you want to list sub directory size separately then this is how you do it
1 |
du -h --max-depth=1 |
You can also specify directory path as shown below
1 |
du -h --max-depth=0 /home/web |
Above will work on /home/web folder
You can also get quite interesting but if all depends what you are trying to do
just type
1 |
man du |
to see what else you can do
here is a quick link to man page available through
http://unixhelp.ed.ac.uk/CGI/man-cgi?du
Above listed is just to give you an indicator Linux is so wide with its commands that there could be another 10s of combination to achieve above results but I am not not aware of those 10s so I rely on the above mentioned commands 🙂
I hope this helps
Just in case you would like to add something to this post or want to correct improper use of a command please leave your comments
Cheers
Leave a Reply