Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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

Which goes faster on Linux/Unix?

du -b file.dat


stat -c %s file.dat
share|improve this question
Isn't this something you could Just Try™? – jtbandes Jul 18 '11 at 0:05
I have tried it, and the results are sometimes inconsistent, that's why I'm asking other people. – Matt Jul 18 '11 at 16:48
up vote 2 down vote accepted

It seems du is slightly faster in this example.

$ time bash -c 'for ((i=1; i<1000;i++)); do stat -c %s file1 >/dev/null; done'
real    0m3.588s
user    0m0.120s
sys 0m0.344s

$ time bash -c 'for ((i=1; i<1000;i++)); do du -b file1 >/dev/null; done'
real    0m3.161s
user    0m0.092s
sys 0m0.360s

But personally, I'd prefer to use stat, because most people use stat to retrieve basic information of a single file. So it's more likely stat will be optimized for such jobs in future.

share|improve this answer
Here is stat: "real 0m2.183s" and here is du: "real 0m1.940s".. My file is 500MB [taken from /dev/zero], so I guess du is faster.. – Matt Jul 18 '11 at 16:49

You can use the time command to find out:

time du -b file.dat
time stat -c %s file.dat
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.