Real size of folder?

9,861

Your second output, du -s Folder is in kilobytes not megabytes. That is the default output for du. To convert to MB divide by 1024: 120664/1024 = 117.8359375, with the h flag this gets rounded up to 118MB.

You can also view the size of the folder in Bytes with du -sb Folder.

The du utility gives you the amount that is actually used by the disk. The value you are seeing in the file explorer is the apparent size. These are not the same as explained in man du:

   --apparent-size
          print  apparent sizes, rather than disk usage; although the apparent size is usually smaller, it may be larger due
          to holes in (`sparse') files, internal fragmentation, indirect blocks, and the like

If you use --apparent-size option in du it will give you the same value that you see in the file explorer.

As for why size on disk is different than the size of all the files, see this response: Why is disk usage greater than the size of all files on it?

Share:
9,861

Related videos on Youtube

padawanTony
Author by

padawanTony

Just a guy trying to make it through life...and coding :)

Updated on September 18, 2022

Comments

  • padawanTony
    padawanTony over 1 year

    When I run du -hs Folder in the terminal I get: 118M

    When I run du -s Folder in the terminal I get: 120664M

    When I run du -h Folder in the terminal I get: 118m

    When I find the size through the file explorer (right click -> properties) I get: 65.5M

    So, which is the correct one and why does this happen?

  • Shashwat
    Shashwat over 5 years
    In my case, du -sh --apparent-size shows 182M, du -sh shows 190M and size from the explorer gives 137.8M. What am I missing?