Wednesday, 6 June 2012

du and ls show different sizes for the same file


du and ls show different sizes for the same file

After uncompressing a file i was confused to see different sizes for the same file with du and ls command


When i used du it was showing the size




But ls output was showing a different size


So i realized these commands works in different ways

ls with option -l shows the allocated size but du shows the actual size (amount of space used).

If you want to see actual size with ls use -s option. If you use this way you can see both ls and du gives same output, in this case actual size is printer first