hostid
Display the numeric identifier for the host
TLDR
Display the numeric identifier for the current host in hexadecimal
SYNOPSIS
hostid [OPTION]…
PARAMETERS
--help
display this help and exit
--version
output version information and exit
DESCRIPTION
The hostid command outputs a 32-bit numeric identifier (host ID) for the current machine in hexadecimal format. This ID is an 8-digit lowercase hex value, padded with leading zeros if necessary (e.g., 802a2a97).
On Linux, hostid from the util-linux package first attempts to read the binary file /etc/hostid, which contains a 4-byte little-endian unsigned integer. If absent, it generates an ID by hashing the first 16 bytes of /etc/machine-id (from systemd) using the DJB hash, ensuring persistence across reboots.
Traditionally used by legacy software (e.g., for licensing in tools like Oracle or old games), the host ID provided a simple machine fingerprint. Early UNIX derived it from the primary IP address via gethostid(3), but modern systems avoid this due to DHCP and virtualization. Root can set it persistently with sethostid or by writing binary data to /etc/hostid (e.g., printf '\x97\x2a\x2a\x80' | sudo tee /etc/hostid).
Primarily informational, it's not secure or guaranteed unique. Output is deterministic unless /etc/machine-id changes (e.g., VM clones). Run without arguments for instant output.
CAVEATS
Host ID not guaranteed unique across systems or persistent without /etc/hostid. 32-bit limit; unsuitable for security. Changes if machine-id regenerates (e.g., live migration).
Value always 8 lowercase hex digits.
SETTING HOST ID
As root: sudo sethostid 0x01234567 or printf '\x67\x45\x23\x01' | sudo tee /etc/hostid. Reboot or reread not needed.
EXAMPLE OUTPUT
$ hostid
7f020001
HISTORY
Originated in 4.2BSD (1983); standardized in POSIX.1-2001 as LEGACY but retained. Linux util-linux version (since 1990s) shifted from IP-based to file/machine-id for reliability.


