Units Data Files (Units: A Unit Conversion Program and Scientific Calculator)

### 14.1 Units Data Files ¶

The units and prefixes that `units` can convert are defined in the units data file, typically `/usr/share/units/definitions.units`. If you can’t find this file, run `units --version` to get information on the file locations for your installation. Although you can extend or modify this data file if you have appropriate user privileges, it’s usually better to put extensions in separate files so that the definitions will be preserved if you update `units`.

You can include additional data files in the units database using the ‘`!include`’ command in the standard units data file. For example

    !include    /usr/local/share/units/local.units

might be appropriate for a site-wide supplemental data file. The location of the ‘`!include`’ statement in the standard units data file is important; later definitions replace earlier ones, so any definitions in an included file will override definitions before the ‘`!include`’ statement in the standard units data file. With normal invocation, no warning is given about redefinitions; to ensure that you don’t have an unintended redefinition, run `units -c` after making changes to any units data file.

If you want to add your own units in addition to or in place of standard or site-wide supplemental units data files, you can include them in the `.units` file in your home directory. If this file exists it is read after the standard units data file, so that any definitions in this file will replace definitions of the same units in the standard data file or in files included from the standard data file. This file will not be read if any units files are specified on the command line. (Under Windows the personal units file is named `unitdef.units`.) Running `units -V` will display the location and name of your personal units file.

The `units` program first tries to determine your home directory from the `HOME` environment variable. On systems running Microsoft Windows, if `HOME` does not exist, `units` attempts to find your home directory from `HOMEDRIVE`, `HOMEPATH` and `USERPROFILE`. You can specify an arbitrary file as your personal units data file with the `MYUNITSFILE` environment variable; if this variable exists, its value is used without searching your home directory. The default units data files are described in more detail in Data Files.