Sunday, September 23, 2012
6:13 PM

du: Finding the file/folder size from command line in linux

To find the amount of space occupied by any file or folder in the system we can use the command du.

Let us say we have a folder test which contains the files file1,file2,file3,temp

To find the size of the folder test



The first column Indicates the size of the folder and the second column gives the name of the folder. By default du also lists the sizes of only the sub folders and not of files.
In case we want to have a look at the size of the files too we can use the option "-a"



The size column if displayed with no suffix can be difficult to read for bigger sized files, to make the reading easier we can use the option "-h" which sill convert it into more human readable form



The suffix K indicating the size is in Kilo bytes. For Mega bytes it will be M for giga G etc.
If we just want the size of the folder and not its sub folders we can use the option "-s"



We can also pass file names to find the size of a file instead of a folder.



Thus we can easily find the space occupied by any file or folder on the system using the du command

0 comments:

Post a Comment