In short, du (disk usage), list the size actually that file occupied, system use block to store data, each block is 4k, so even if you have a 10 bytes file, it will still use 4k disk usage, so du file shows 4k. But if you use ls -l, it shows 10 bytes.


Create file

  1. ~/Learning/Programming/C_Cpp on main +1 !1 ?5 at 04:40:25 PM ─╮
  2. dd if=/dev/zero of=./test bs=1040 count=1 ─╯
  3. 1+0 records in
  4. 1+0 records out
  5. 1040 bytes (1.0 kB, 1.0 KiB) copied, 0.00037525 s, 2.8 MB/s

ls -l

  1. ~/Learning/Programming/C_Cpp on main +1 !1 ?5 at 04:40:42 PM ─╮
  2. ls -l test ─╯
  3. .rw-r--r-- 1.0k coolder 8 Oct 16:40 test

du -sh

  1. ~/Learning/Programming/C_Cpp on main +1 !1 ?5 at 04:41:22 PM ─╮
  2. du -sh test ─╯
  3. 4.0K test