The Units Tool in Linux

GNU Units can be used for many things. It is such a useful tool that I always install it on all Linux nodes.

Here is how I use it:

Convert network speed. ISPs and network device use bit per second, downloaders usually use byte per second.

units 1000Mbps MiB/s
; 119.21 MiB/s
units 100Mbps MiB/s
; 11.92 MiB/s
units 20Mbps MiB/s
; 2.38 MiB/s
units 4Mbps KiB/s
; 488 KiB/s

Calculate average download speed

units 800MiB/25min KiB/s
; 546.1 KiB/s

Convert hard drive space. Operating systems show GiB/TiB, while vendors use GB/TB.

units 1TB GiB
; 931.3 GiB
units 2TB GiB
; 1862.6 GiB

You can do calculation too. For example, if you have 24 16TB disks. Each data is stored in 3 replicas. At 80% capacity, you may store up to

units 16TB*24/3*0.8 TiB
; 93.13 TiB

Do time calculations

units '2 hour + 34 min + 1 day'
; 95640 s
units '2 hour + 34 min + 1 day' hour
; 26.6 hour
units 8mo weeks
; 34.8 weeks

Convert between tps and maximum possible total request per day

units 132tps req/day
; 11404800 req/day
units 132tps million*req/day
; 11.4 million*req/day

Convert between (single node) tps and average response time

units 132tps ms/req
; 7.5 ms/req

Convert foreign currency to local currency

units 39.99hkd usd
; 5.1 usd

units 500hkd/mo usd/year
; 765 usd/year

You may have notice some units are not built-in. Units allow you to define your own units very easily. Here is my ~/.units file:

word    !
words   1 word

rmb     !
cny     rmb
RMB     rmb
hkd     0.9393 rmb
aud     4.6608 rmb
usd     7.2959 rmb
eur     8.266 rmb
euro    eur
gbp     9.7282 rmb
GBp     0.01gbp
jpy     0.050583 rmb
sgd     5.5781 rmb
s$      sgd
inr     0.081919 rmb
rs      inr
mvr     0.4637 rmb
laari   0.01 mvr

request !
req     request
r       request
tps     req/s

BTC     64219 usd
bitcoin 1 BTC
btc     BTC

ETH     3490 usd
Ether    1 ETH
Ethereum 1 ETH
eth      ETH

# units 0K tempC
# units 0K tempF

core    !

jin     0.5kg

char    !

share   !

w       10000
yi      100000000

tx      !
transaction   tx
trans   tx

kwh     1000*watt*hour

You can define basic unit by using ‘!’, you can define unit alias, you can define conversion. See man units for more information.

Scroll to Top