How to display files sizes in MB in Linux/Ubuntu

Sometimes we want to see the sizes of files as returned by the ls command displayed in some reasonable format or in other words in human readable presentation.

To display the file
sizes in units like 7K, 5M, 8.2G, etc… use the -lh option with  ls. 

ls -lh

command ls -lh

Note that -h is a GNU coreutils extension.

To display the sizes rounded up to the nearest MiB (2^20 bytes), you should use the command :

ls -l –block-size=M

command ls -l --block-size=M

Read: How to find the largest files on Linux

If the M suffix bothers you in some way, you can get rid of it by using –block-size=1M.

command ls -l --block-size=1M

If however you want to see the size in MB (10^6 bytes) instead, you should use the command with the option –block-size=MB.

command ls -l --block-size=MB

To understand the differences between the units MiB and MB, have a look at the table below (courtesy :

differences between MB and MiB

For more on this, you may want to visit the man page for ls.
Simply type in man ls and look up the word SIZE. In case you are interested, you will find other units as well (besides MB/MiB).

ziad nahdy

Ziad Nahdy, fan of open source, worked at SAP for 17 years. He is a technical writer, blogger and Linux enthusiast. He loves to read and help others with their problems. He is addicted to open source software but he also loves other technology related stuff.

Leave a Reply

Close Menu