1

I mean, did the developers think people would enjoy reading 19478204 rather than 19 GB?

Could it be that in the older systems there weren't as much disk space so it was OK back then to count each digit?

closed as primarily opinion-based by Jenny D, jasonwryan, Anthon, Michael Homer, cuonglm May 4 '15 at 7:12

Many good questions generate some degree of opinion based on expert experience, but answers to this question will tend to be almost entirely based on opinions, rather than facts, references, or specific expertise. If this question can be reworded to fit the rules in the help center, please edit the question.

  • It's probably not accurate to think that measuring it in such small denominations was because volumes were smaller. It's more reasonable to assume that when df was first created, the main problem it was trying to solve was just getting a brief summary of disk usage somehow. So people at the time were more concerned with there just being some number available to work with. -h was probably added later for people who didn't want to do the math each time but when adding new options you should keep default behavior, so they left it at printing blocks. – Bratchley May 4 '15 at 2:45
  • Backwards incompatible. Don't you care about breaking existing code? – Anthon May 4 '15 at 6:36
7

It is more precise to output the byte count rather than the human readable numbers. I use both, but when copying data or verifying file sizes, non-human readable is a must.

Since one person's sensible default is another's constant annoyance, there's really no 'right' or 'wrong' answer. However, it is easy to force df to output human readable numbers:

$ echo "alias df='df -h'" >> ~/.bashrc

If you ever want to use df in its default mode, escape it with a \ like this:

$ \df
5

I'm just guessing, but most Unix tools are built to work in pipelines. Viewed that way the number of bytes is probably the most useful, and thus a sensible default

2

TL;DR: because hard drives are in blocks of (mostly) 512 or some other power of 2

If you divide output of df -k (which is the default of GNU df version) by 1024 you actually get df -h.From reading Wikipedia as well as man page on my Ubuntu system for df, it appears that there is a historical reason for it, as Unix System V was consistently using 512 size blocks. In fact, disks sectors are made to hold 512MB, so I guess this is practical in the sense of understanding how many sectors of the disk space your partition takes up.

On the other hand, 1024 blocks is closer to what we understand as 1000 bytes, hence GNU probably made df output that by default. But again, while we humans think in bytes that are powers of 10, disks are created in sectors and computers speak in powers of 2^x.

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