With the help of a Unit converter we can convert one unit of measurement to another. In this article, we cover how to get that done through command-line tool – units. The package – units is available in both the Operating Systems i.e. Ubuntu and AlmaLinux 9.
Details of measurement of an object can be expressed in different systems of measurements. With the help of a Unit converter like units, it is possible to convert one unit of measurement to another. We cover its installation steps first.
Note: Following operations require superuser privileges. Contact your System Administrator if you don’t have access to superuser privileges.
Install units in Ubuntu
The package is available through standard Ubuntu repository therefore update that first –
sudo apt update
Next, to install units –
sudo apt install units
Install units in AlmaLinux 9
The package is available through BaseOS repository. So, open a terminal and issue the following –
# dnf install units
Use units in Ubuntu/AlmaLinux 9
There are two ways to access Unit converter – units. Either we can issue a command in the terminal or we can run an interactive session of units it in the terminal itself.
I. Let’s say we want to convert 10 centimeters to inches. Then, command in that case will be –
units "10 centimeters" "inches"
This would get us –
* 3.9370079 / 0.254
where, * indicates the outcome, which in this case is 3.9370079.
/ gives us the inverse of converted value.
II. As already discussed, we can also run an interactive session of units –
It would prompt with –
Here, enter 10 centimeters. Then, enter – inches
This would get us the converted value. Use Ctrl+C to exit the interactive session.
In conclusion, we have covered how to do unit conversion through units command-line tool here.
Additional Info –
In the terminal, issue the following to get location of default units data file –
Usually, it is stored in directory as –
The file contains units database.