Describe the host¶
Source · io.systemd.Hostname · systemd v257+ · Unprivileged
hostnamectl in 40 lines. One Describe call returns everything
systemd-hostnamed knows about the machine: hostnames, chassis, OS, kernel,
hardware and firmware. Optional fields are pointers; varlink.Deref reads them
without nil checks.
Run it¶
Output (illustrative)
Static hostname: build-07
Transient hostname: build-07
Icon name: computer-server
Chassis: server
Operating system: Fedora Linux 42 (Server Edition)
Kernel: Linux 6.14.4-300.fc42.x86_64
Hardware vendor: Dell Inc.
Hardware model: PowerEdge R650
The code¶
How it works¶
Describetakes aDescribeInwhose only field,AllowInteractiveAuthentication, is optional, so an empty struct is fine.- Required vs optional.
Hostname,KernelNameandKernelReleaseare plain strings (always present);StaticHostname,Chassisand friends are*stringbecause a host may not set them. varlink.Derefreturns""for unset fields, androwskips empty values, which mirrorshostnamectl's output.- The example pins
systemd/v257/hostname. See Versioning for a field in this interface whose type changed between releases.