Monday, 10 September 2012

Getting the Directory Size in Unix/Linux


On some Day, we might need to find the size of the directory through the Unix command or through the SSH Client. To get a Directory size, use the following commands.

praba@treadstone$ ls
Java     build   source    lib
praba@treadstone$ du –sh build
2.6M build


Atleast I post this for myself to get it back, if I forgot in nearby future.

Here ‘s’ refers ‘size’ and ‘h’ refers to the ‘human readable’ format. There are many more options available with command ‘du’. To know it more about. Execute

>man du


To get the File System Disk Space, use 'df'. displays the amount of disk space available on the file system containing. 



praba@treadstone$ ls

Java     build   source    lib

praba@treadstone$ df –kh build

Filesystem              size     used      avail       capacity         Mounted on
cevic:/f                   2.7T    2.4T       225G        92%        /praba/Builds/F1


here 'h' refers the 'human readable' format. 'k' refers the block size. 

>man df option will let us know the more option. 


There will be huge time difference between the 'du' and 'df' commands. Try executing the 'df' for entire file system. 'du' for knowing the particular file size. 






~Prabakaran

No comments:

Post a Comment