Overview
hostid prints a number, in hexadecimal, that identifies the machine. On many systems it is derived from the machine's IP address or set by an administrator, so it is not a reliable unique name. It is an old command, kept for compatibility.
Background
hostid is part of GNU coreutils and is also an applet in BusyBox. macOS does not ship it. They agree on printing eight hexadecimal digits.
Examples
Print the identifier and check that it is eight hexadecimal digits:
hostid | grep -c '^[0-9a-f]\{8\}$'
Common mistakes
The value is not guaranteed to be unique or stable: it can change when the network configuration changes, and two machines can print the same one. For a stable machine identity use /etc/machine-id on Linux or a cloud instance ID. macOS has no hostid.
Portability
This page has no Apple view: macOS has no hostid. The output depends on the machine, so the Common example checks its shape. The Common examples were executed on GNU coreutils 9.11 and BusyBox 1.37.0 (see the development guide for the exact check).
About GNU hostid
GNU hostid is part of GNU coreutils, and this page's checks ran coreutils 9.11.
References
Original explanations, with upstream documentation for further reading. FreeBSD references are comparison material, not a claim of Apple version equivalence.