io.systemd.Hostname¶
APIs for querying and changing the system hostname and related machine metadata.
| Property | Value |
|---|---|
| Go package | github.com/rossedman/sdvarlink/systemd/latest/hostname |
| Socket | /run/systemd/io.systemd.Hostname |
| Available since | systemd v257 |
| Methods · types · errors | 9 · 0 · 0 |
Methods¶
Describe¶
Returns hostname, kernel, OS, hardware, firmware and other machine metadata in one call.
Parameters
| Field | Type | Description |
|---|---|---|
allowInteractiveAuthentication |
?bool |
Controls whether interactive authentication (via polkit) shall be allowed. If unspecified defaults to false. |
Reply
| Field | Type | Description |
|---|---|---|
Hostname |
string |
The current system hostname. |
StaticHostname |
?string |
The statically configured hostname, from /etc/hostname. Null if none is configured. |
PrettyHostname |
?string |
The pretty (free-form, UTF-8) hostname. Null if none is configured. |
DefaultHostname |
?string |
The fallback hostname used when neither a static nor a transient hostname is set. |
HostnameSource |
string |
Indicates where the current hostname originates from, one of 'static', 'transient' or 'default'. |
IconName |
?string |
The name of an icon representing this system, following the XDG icon naming spec. Null if none is configured. |
Chassis |
?string |
The chassis type of this system, e.g. 'desktop', 'laptop', 'server', 'vm', … Null if unknown. |
ChassisAssetTag |
?string |
An unique identifier of the system chassis. |
Deployment |
?string |
The deployment environment of this system, e.g. 'production' or 'staging'. Null if none is configured. |
Location |
?string |
A human-readable description of the physical location of this system. Null if none is configured. |
KernelName |
string |
The operating system kernel name, as reported by uname(2), e.g. 'Linux'. |
KernelRelease |
string |
The kernel release string, as reported by uname(2). |
KernelVersion |
string |
The kernel version string, as reported by uname(2). |
OperatingSystemPrettyName |
?string |
'Pretty' name of the OS. This is the primary OS identifier that is suitable for presentation to the user. Typically includes a version too, but doesn't have to. |
OperatingSystemFancyName |
?string |
'Fancy' name of the OS; may contain non-ASCII Unicode chars, as well as basic ANSI sequences. This is similar to 'OperatingSystemPrettyName', but is preferably used on terminals that support ANSI sequences and full Unicode. |
OperatingSystemCPEName |
?string |
The CPE name of the OS, from the CPE_NAME= field of os-release. |
OperatingSystemHomeURL |
?string |
The home URL of the OS, from the HOME_URL= field of os-release. |
OperatingSystemSupportEnd |
?int |
The end-of-support time of the OS, in µs since the UNIX epoch. Null if not known. |
OperatingSystemReleaseData |
?[]string |
The full contents of os-release, as an array of 'KEY=VALUE' strings. |
OperatingSystemImageID |
?string |
The OS image identifier, from the IMAGE_ID= field of os-release. |
OperatingSystemImageVersion |
?string |
The OS image version, from the IMAGE_VERSION= field of os-release. |
MachineInformationData |
?[]string |
The full contents of /etc/machine-info, as an array of 'KEY=VALUE' strings. |
MachineTags |
?[]string |
The machine tags, from the TAGS= field of /etc/machine-info with any invalid tags filtered out. Empty if none are configured. |
HardwareVendor |
?string |
The hardware vendor of this system. Null if not known. |
HardwareModel |
?string |
The hardware model of this system. Null if not known. |
HardwareSerial |
?string |
The hardware serial number of this system. Reading it requires privileges. Null if not known. |
HardwareSKU |
?string |
The hardware SKU (stock keeping unit) of this system. Null if not known. |
HardwareVersion |
?string |
The hardware version of this system. Null if not known. |
FirmwareVersion |
?string |
The firmware version of this system. Null if not known. |
FirmwareVendor |
?string |
The firmware vendor of this system. Null if not known. |
FirmwareDate |
?int |
The firmware build date, in µs since the UNIX epoch. Null if not known. |
MachineID |
string |
The 128-bit machine ID of this system, formatted as a hexadecimal string. |
BootID |
string |
The 128-bit boot ID of the current boot, formatted as a hexadecimal string. |
ProductUUID |
?string |
The DMI product UUID of this system. Reading it requires privileges. Null if not known. |
VSockCID |
?int |
The AF_VSOCK context ID (CID) of this system. Null if not known. |
SetHostname¶
since v262
Sets the transient (runtime) hostname.
Parameters
| Field | Type | Description |
|---|---|---|
newValue |
?string |
The transient (runtime) hostname to set. If null the transient hostname is reset, so that the static hostname is used again. |
allowInteractiveAuthentication |
?bool |
Controls whether interactive authentication (via polkit) shall be allowed. If unspecified defaults to false. |
SetStaticHostname¶
since v262
Sets the static hostname, stored in /etc/hostname.
Parameters
| Field | Type | Description |
|---|---|---|
newValue |
?string |
The static hostname to set, stored in /etc/hostname. If null the static hostname is removed. |
allowInteractiveAuthentication |
?bool |
Controls whether interactive authentication (via polkit) shall be allowed. If unspecified defaults to false. |
SetPrettyHostname¶
since v262
Sets the pretty (free-form, UTF-8) hostname.
Parameters
| Field | Type | Description |
|---|---|---|
newValue |
?string |
The pretty (free-form, UTF-8) hostname to set. If null the pretty hostname is removed. |
allowInteractiveAuthentication |
?bool |
Controls whether interactive authentication (via polkit) shall be allowed. If unspecified defaults to false. |
SetIconName¶
since v262
Sets the icon name representing this system.
Parameters
| Field | Type | Description |
|---|---|---|
newValue |
?string |
The icon name to set. If null the icon name is removed. |
allowInteractiveAuthentication |
?bool |
Controls whether interactive authentication (via polkit) shall be allowed. If unspecified defaults to false. |
SetChassis¶
since v262
Sets the chassis type of this system.
Parameters
| Field | Type | Description |
|---|---|---|
newValue |
?string |
The chassis type to set. If null the chassis type is removed. |
allowInteractiveAuthentication |
?bool |
Controls whether interactive authentication (via polkit) shall be allowed. If unspecified defaults to false. |
SetDeployment¶
since v262
Sets the deployment environment of this system.
Parameters
| Field | Type | Description |
|---|---|---|
newValue |
?string |
The deployment environment to set. If null the deployment is removed. |
allowInteractiveAuthentication |
?bool |
Controls whether interactive authentication (via polkit) shall be allowed. If unspecified defaults to false. |
SetLocation¶
since v262
Sets the physical location of this system.
Parameters
| Field | Type | Description |
|---|---|---|
newValue |
?string |
The physical location to set. If null the location is removed. |
allowInteractiveAuthentication |
?bool |
Controls whether interactive authentication (via polkit) shall be allowed. If unspecified defaults to false. |
SetTags¶
since v262
Edits the machine tag list: optionally resets it to 'set', then adds 'add' and removes 'remove'.
Parameters
| Field | Type | Description |
|---|---|---|
set |
?[]string |
If specified, the machine tag list is first reset to exactly these tags, before the 'add' and 'remove' fields are applied. If null, the current tag list is used as basis instead. |
add |
?[]string |
Machine tags to add to the list. |
remove |
?[]string |
Machine tags to remove from the list. |
allowInteractiveAuthentication |
?bool |
Controls whether interactive authentication (via polkit) shall be allowed. If unspecified defaults to false. |