There are many programs in Linux which would show the size of a file, some of them show it in blocks, some are in bytes. But when it comes to some human readable form, like ls -sh, lvs, dd bs=size and so many, how do we decide if it's a multiple of 1024 or 1000 when we see a kb, KB, mB, MB, K, G etc. Some distinguish them with capitalization like lvs, some with different characters like dd, however, is there a general rule of these kinds of things cause I can't find it so far. Thanks.
Based on this, 1 kilobyte is equal to 1000 bytes. Its international symbol is kB. In computer technologies, a kilobyte is specified as 1024 (210). This is because the binary system is widely used in file management systems.
Remember: Computers can only work with binary code. However computers do like the number 1024 because its binary code is 10000000000. That's why there are 1024 Bytes in a KB, 1024 KB in a MB and so on…
Right-click the file and click Properties. The image below shows that you can determine the size of the file or files you have highlighted from in the file properties window. In this example, the chrome. jpg file is 18.5 KB (19,032 bytes), and that the size on disk is 20.0 KB (20,480 bytes).
In digital units of measurement, 1 MB is equal to 1024 Kilo Bytes or KB.
If you look at man units, you'll see a description of the two types of units. Decimal and Binary. Decimal units like Kilobyte (KB) and Megabyte (MB) are in multiples of 1000 (10^3) while Binary units like Kibibyte (KiB) and Mebibyte (MiB) are in multiples of 1024 (2^10).
If the unit being displayed includes a binary prefix like KiB, MiB, GiB, you can be certain it's 1024. For unclear units, a general thumb rule:
Ubuntu published a policy in 2010 for their units which appears to be reasonably consistent across Linux distributions, although not guaranteed:
Use base-10 for:
Use base-2 for:
For file sizes there are two possibilities:
1 As noted by Kris Avi in a comment, some command-line tools developed before this policy may use only base-2 values but indicate decimal units, and may not have changed in order to avoid breaking existing parsing scripts.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With