Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I create a file named file.o, i want to check the size of the file.o file.

du -h file.o ====> 4.0K

du -b file.o ====> 1120

according to du -b file.o, i get to know file.o is 1120bytes large. But why du -h file.o outputs 4.0K (means 4*1024 bytes)?

share|improve this question

migrated from Jan 20 '11 at 11:16

This question came from our site for professional and enthusiast programmers.

up vote 31 down vote accepted

The file is smaller, but it takes one whole 4.0K block on the disk (you can have only one file in one block). If its byte size were (for example) 5678 Bytes, it would occupy two 4.0K blocks, i.e. 8.0K.

du -b prints sizes in bytes, overriding the default block size.

share|improve this answer

To add to eumiro's answer, the block size can be different for each filesystem/partition.

You can find a filesystem's block size using tune2fs -l /dev/<disk> | grep '^Block size' or stat -c "%o" <file on the disk>.

share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .