hostidx
Print the numeric identifier for the current host.
Mirrors GNU hostid. Run it as hostidx, or as gnux hostidx.
Synopsis
hostidx [OPTION]GNU reference
Description
hostidx prints the host's 32-bit identifier in hexadecimal, eight digits wide, as gethostid(3) returns it. On Linux that is the contents of /etc/hostid when the file exists, and otherwise a value glibc derives from the first IPv4 address the host name resolves to. On macOS and the BSDs it is the kern.hostid sysctl, which may be zero. Windows has no gethostid, so hostidx derives the value from the host's address there too, as glibc does; with no address it prints 00000000. The identifier is not guaranteed to be unique.
Permissions
Reads /etc/hostid on Linux when it exists. Needs no permissions.
Use cases
- Reporting the identifier that some license managers bind to.
- Telling machines apart in a log when the
hostnameis not enough.
Flags
--help display this help and exit
--version output version information and exitExamples
Print the host identifier a license server asks for
hostidxa8c002d7Record the host name and identifier together in a log line
echox "$(hostnamex) $(hostidx)" >> machines.logExit status
| Status | Meaning |
|---|---|
| 0 | success: every operand was processed |
| 1 | failure: an operand could not be processed (diagnosed on standard error), or a command-line mistake |
Help in the terminal
hostidx --help # options, first examples, exit status
gnux help hostidx # this page: the full manual
gnux help hostidx --OPTION # one option in depth, with its examples