Session and utilities

The numfmt command

Converts numbers to human-readable form (1M, 2G) or back. Very useful when reading sizes.

Syntax

numfmt [--to=iec|--to=si|--from=iec] <número>

Most useful options

--to=iecConverts to K/M/G with base 1024
--to=siConverts to K/M/G with base 1000
--from=iecThe reverse: from 1K to 1024

Copy-ready examples

$ numfmt --to=iec 1048576Bytes to readable
$ numfmt --from=iec 1MReadable to bytes

You can try them in the browser terminal: it does not touch your computer.

Typical mistakes

  • iec uses 1024 and si uses 1000; they are not the same.

Related commands

FAQ

Why does 1M give different values?

Because iec (1024) and si (1000) use different bases.

Learn to actually use it

The basic Linux course takes you from zero to console fluency with 24 self-grading lessons.

Start the free course