Operating System - Linux
1751894 Members
4849 Online
108783 Solutions
New Discussion юеВ

Re: How to get directory size?

 
cutefriend
New Member

How to get directory size?

Hi,

how to get particular directory size ?

Thanks,
5 REPLIES 5
FLQ
Valued Contributor

Re: How to get directory size?

Hi cutefriend,

try "du -sk ." while positioning yourself in the directory

or "du -sk /path/to/directory"

HTH
Steven Schweda
Honored Contributor

Re: How to get directory size?

What does "directory size" mean to you?

ls -ld directory_name
du -ks directory_name
Alzhy
Honored Contributor

Re: How to get directory size?

Hi Cuty,

By "directory size" I trust:
1.) How much space is the directory (folder?) occupying?

Ans: du -s -k /dirpath
du -s -k /dir/path/dirfolder

2.) Capacity of the directory/folder to hold files (in terms of MBytes, Gbytes or Tbyets?)

Ans: df -h /dirpath
df -h /dir/path/dirfolder

2.1) No of Files (aka inodes) capacity and usage -- i.e. how many files aer stashed in its placeholder filesystem

Ans: df -i /dirpath
df -i /dir/path/dirfolder


3.) How many files are contained there at?

Ans: df -i /dirpath (if dir/folder is a filesystem)
df -i /dir/path/dirfolder (if dir/folder is a filesystem)
ls -lR /dirpath | wc -l
ls -lR /dir/path/dirfolder |wc -l


Hope this helps.
Hakuna Matata.
bullz
Super Advisor

Re: How to get directory size?

It's very common answer in unix.

use du -sh (or) du -sk

see, below, U can get the directory size for /var/log

root@chitti # du -sh /var/log
102K /var/log
ganesh pink
Occasional Contributor

Re: How to get directory size?

$ du /dirpath
The above command would give you the directory size of the directory


$ du -ah
This command would display in its output, not only the directories but also all the files that are present in the current directory. Note that 'du' always counts all files and directories while giving the final size in the last line. But the '-a' displays the filenames along with the directory names in the output. '-h' is once again human readable format.