I have a file in linux machine whose size is 3404494030 upon doing "ls -l". When I do "ls -lh" it shows 3.2 GB which is correct when converted from bytes to Gigabytes. But when I do "du -h" for the same file, it shows 4 GB. I have tried on many instances but I have found that there is inconsistency between the output of "ls" and "du". I also tried to see the size of the file using filezilla client (ftp client on windows) by right clicking on the file and monitoring its size through the file properties. The output of "ls" and filezilla matches. I am using CentOS and I am wondering if it is a bug of "du" or is there a problem in my understanding of "du". There is a similar question asked earlier. I checked it and found it to be a trivial question.

2 Answers 2


ls shows space allocated for file.

du shows amount of space actually used by file.


Sparse Files:

$ dd if=/dev/zero of=sparse.img bs=1M seek=1024 count=0
$ ls -lh sparse.img
-rw-rw-r-- 1 ruiqi ruiqi 1.0G Nov 26 11:23 sparse.img
$ du sparse.img
0   sparse.img
  • I think my file is not a sparse file. I am not sure whether your example is applicable in my case because for my file "du" shows 4 GB which is greater than the output of "ls" which is only 3.2 GB
    – justin waugh
    Nov 26, 2012 at 3:56

You must log in to answer this question.