ORG.FREED....HOSTNAME1(5)
๐ ORG.FREEDESKTOP.HOSTNAME1 ๐
okay bestie, so this is the manual page for org.freedesktop.hostname1 โ that's the D-Bus interface situation for systemd-hostnamed, section 5 of the manual. come sit with me, we're gonna go through this together and you're gonna understand it. no cap. ๐ซถ
โจ INTRODUCTION โจ
so systemd-hostnamed.service(8) is a system service โ like, a real one, a whole daemon โ and what it does is let user programs control the hostname and related machine metadata. cute, right?
this page right here describes two things, and you're gonna want both:
- the hostname semantics โ like, what even is a hostname and what do the rules say
- the D-Bus interface โ the actual API you talk to
both. periodt. ๐
๐ THE D-BUS API ๐
okay so the service exposes these interfaces on the bus, and I'm gonna give you the whole thing verbatim because you need the exact names, no paraphrasing allowed:
node /org/freedesktop/hostname1 {
interface org.freedesktop.hostname1 {
methods:
SetHostname(in s hostname,
in b interactive);
SetStaticHostname(in s hostname,
in b interactive);
SetPrettyHostname(in s hostname,
in b interactive);
SetIconName(in s icon,
in b interactive);
SetChassis(in s chassis,
in b interactive);
SetDeployment(in s deployment,
in b interactive);
SetLocation(in s location,
in b interactive);
SetTags(in as tags);
AddAndRemoveTags(in as add,
in as remove);
GetProductUUID(in b interactive,
out ay uuid);
GetHardwareSerial(out s serial);
Describe(out s json);
GetMachineInfo(in s field,
out s value);
properties:
readonly s Hostname = '...';
readonly s StaticHostname = '...';
readonly s PrettyHostname = '...';
@org.freedesktop.DBus.Property.EmitsChangedSignal("const")
readonly s DefaultHostname = '...';
readonly s HostnameSource = '...';
readonly s IconName = '...';
readonly s Chassis = '...';
readonly s Deployment = '...';
readonly s Location = '...';
readonly as Tags = ['...', ...];
@org.freedesktop.DBus.Property.EmitsChangedSignal("const")
readonly s KernelName = '...';
@org.freedesktop.DBus.Property.EmitsChangedSignal("const")
readonly s KernelRelease = '...';
@org.freedesktop.DBus.Property.EmitsChangedSignal("const")
readonly s KernelVersion = '...';
@org.freedesktop.DBus.Property.EmitsChangedSignal("const")
readonly s OperatingSystemPrettyName = '...';
@org.freedesktop.DBus.Property.EmitsChangedSignal("const")
readonly s OperatingSystemFancyName = '...';
@org.freedesktop.DBus.Property.EmitsChangedSignal("const")
readonly s OperatingSystemCPEName = '...';
@org.freedesktop.DBus.Property.EmitsChangedSignal("const")
readonly t OperatingSystemSupportEnd = ...;
@org.freedesktop.DBus.Property.EmitsChangedSignal("const")
readonly s HomeURL = '...';
@org.freedesktop.DBus.Property.EmitsChangedSignal("const")
readonly s OperatingSystemImageID = '...';
@org.freedesktop.DBus.Property.EmitsChangedSignal("const")
readonly s OperatingSystemImageVersion = '...';
@org.freedesktop.DBus.Property.EmitsChangedSignal("const")
readonly s HardwareVendor = '...';
@org.freedesktop.DBus.Property.EmitsChangedSignal("const")
readonly s HardwareModel = '...';
@org.freedesktop.DBus.Property.EmitsChangedSignal("const")
readonly s HardwareSKU = '...';
@org.freedesktop.DBus.Property.EmitsChangedSignal("const")
readonly s HardwareVersion = '...';
@org.freedesktop.DBus.Property.EmitsChangedSignal("const")
readonly s FirmwareVersion = '...';
@org.freedesktop.DBus.Property.EmitsChangedSignal("const")
readonly s FirmwareVendor = '...';
@org.freedesktop.DBus.Property.EmitsChangedSignal("const")
readonly t FirmwareDate = ...;
@org.freedesktop.DBus.Property.EmitsChangedSignal("const")
readonly ay MachineID = [...];
@org.freedesktop.DBus.Property.EmitsChangedSignal("const")
readonly ay BootID = [...];
@org.freedesktop.DBus.Property.EmitsChangedSignal("const")
readonly u VSockCID = ...;
@org.freedesktop.DBus.Property.EmitsChangedSignal("const")
readonly s ChassisAssetTag = '...';
};
interface org.freedesktop.DBus.Peer { ... };
interface org.freedesktop.DBus.Introspectable { ... };
interface org.freedesktop.DBus.Properties { ... };
};
now the important vibe check ๐ โ whenever the hostname or any other metadata gets changed through the daemon, PropertyChanged signals get sent out to all the subscribed clients. like, everybody who's listening finds out. and here's the thing: changing a hostname using this interface is authenticated via polkit[1]. so it's not just anyone waltzing in and renaming your machine, bestie. there's a whole permission gate. slay. ๐ฅ
that's part one, and trust, there's more coming โ don't go anywhere. ๐
โจ SEMANTICS โจ
Okay bestie, this is the part where we explain what all those properties actually mean, because the names are lowkey cryptic and we're not about to let you guess. ๐ซถ
The StaticHostname property exposes the "static" hostname configured in /etc/hostname. The way it's giving: it is not always in sync with the current hostname as returned by the gethostname(3) system call. And if no static hostname is configured at all? This property will be the empty string. Empty. Nada. ๐
When systemd(1) or systemd-hostnamed.service(8) set the hostname, this static hostname has the highest priority. It's the main character, periodt.
The Hostname property exposes the actual hostname configured in the kernel via sethostname(2). It can be different from the static hostname โ yes, they can disagree, it's giving divorced parents ๐
. This property is never empty, though. Never.
The PrettyHostname property exposes the pretty hostname, which is a free-form UTF-8 hostname for presentation to the user. It's the cute one. User interfaces should ensure that the pretty hostname and the static hostname stay in sync, okay? Like, e.g. when the former is "Lennartโs Computer" the latter should be "lennarts-computer". If no pretty hostname is set this setting will be the empty string. Applications should then find a suitable fallback, such as the dynamic hostname. No pressure tho. ๐
The DefaultHostname property exposes the default hostname โ configured through os-release(5), or a fallback set at compilation time.
The HostnameSource property exposes the origin of the currently configured hostname. One of:
"static"โ set from/etc/hostname"transient"โ a non-permanent hostname from an external source"default"โ the value from os-release or the compiled-in fallback
The IconName property exposes the icon name following the XDG icon naming spec. If not set, information such as the chassis type (see below, bestie, keep reading) is used to find a suitable fallback icon name โ i.e. "computer-laptop" vs. "computer-desktop" is picked based on the chassis information. If no such data is available, the empty string is returned. In that case an application should fall back to a replacement icon, for example "computer". And if this property is set to the empty string, the automatic fallback name selection is enabled again. Iconic. ๐
The Chassis property exposes a chassis type, one of the currently defined chassis types:
"desktop""laptop""server""tablet""handset"
as well as the special chassis types "vm" and "container" for virtualized systems. Note that in most cases the chassis type will be determined automatically from DMI/SMBIOS/ACPI firmware information. Writing to this setting is hence useful only to override misdetected chassis types, or to configure the chassis type if it could not be auto-detected. Set this property to the empty string to reenable the automatic detection of the chassis type from firmware information. Handy fr fr. ๐ง
The Tags property exposes a list of machine tags: short labels that may be used to classify and group machines for management purposes โ for example to identify the role a machine plays in a deployment, the fleet or organizational unit it belongs to, or any other administrator-defined attribute. Each individual tag is 1...255 characters long and consists only of the ASCII alphanumeric characters, "-" and ".". The tags are stored as a colon-separated list in the TAGS= field of /etc/machine-info, see machine-info(5) for details. If no tags are configured this property is the empty list. Cute lil organizational queenies. ๐
Note thatsystemd-hostnamedstarts only on request and terminates after a short idle period. This effectively means thatPropertyChangedmessages are not sent out for changes made directly on the files (as in: administrator edits the files withvi). This is the intended behavior: manual configuration changes should require manual reloading. It's not a bug bestie, it's a vibe. ๐
The transient (dynamic) hostname exposed by the Hostname property maps directly to the kernel hostname. This hostname should be assumed to be highly dynamic, and hence should be watched directly, without depending on PropertyChanged messages from systemd-hostnamed. To accomplish this, open /proc/sys/kernel/hostname and poll(3) for SIGHUP which is triggered by the kernel every time the hostname changes. Again: this is special for the transient (dynamic) hostname, and does not apply to the configured (fixed) hostname. Don't mix them up, iykyk. ๐
Applications may read the hostname data directly if hostname change notifications are not necessary. Use gethostname(2), /etc/hostname (possibly with per-distribution fallbacks), and machine-info(5) for that. For more information on these files and syscalls see the respective man pages. โจ
KernelName, KernelRelease, and KernelVersion expose the kernel name (e.g. "Linux"), release (e.g. "5.0.0-11"), and version (i.e. the build number, e.g. "#11") as reported by uname(2).
OperatingSystemPrettyName, OperatingSystemFancyName, OperatingSystemCPEName, and HomeURL expose the PRETTY_NAME=, FANCY_NAME=, CPE_NAME= and HOME_URL= fields from os-release(5). The purpose of those properties is to allow remote clients to access this information over D-Bus. Local clients can access the information directly. Efficiency slay. ๐ฆ
MachineID expose the 128bit machine ID, see machine-id(5) for details.
BootID expose the 128bit boot ID, as per /proc/sys/kernel/random/boot_id.
VSockCID exposes the system's local AF_VSOCK CID (Context Identifier, i.e. address) for the system, if one is available in the virtual machine environment. Set to UINT32_MAX otherwise. See vsock(7) for details.
OperatingSystemSupportEnd exposes when the OS' vendor support ends, if this information is known. It's an unsigned 64bit value, in ยตs since the UNIX epoch, UTC. If this information is not known carries the value 2^64-1, i.e. UINT64_MAX.
OperatingSystemImageID and OperatingSystemImageVersion expose the OS image name and version if available, or contain empty strings otherwise. This mostly corresponds to the IMAGE_ID= and IMAGE_VERSION= fields of the os-release file.
HardwareVendor, HardwareModel, HardwareSKU, and HardwareVersion expose vendor information about the hardware of the system. The stock keeping unit (SKU) describes a distinct type of hardware for sale, purchase or inventory management. The SKU and version are only available if they deviate from the model and among each other. Thereby the version is more specific and only available if it differs from the model and SKU. If no such information can be determined these properties are set to empty strings. (Yes that's a lot of conditions, no we're not making it up. ๐ญ)
FirmwareVersion and FirmwareVendor expose information about the system's firmware, i.e. a version string and a vendor name. If no such information can be determined these properties are set to empty strings.
FirmwareDate exposes the firmware build date, if that information is known. It's an unsigned 64bit value, in ยตs since the UNIX epoch, UTC. If not known UNIT64_MAX. (Yes, spelled exactly like that in the original. Copying it character for character because that's the rule and we respect the rule. ๐)
ChassisAssetTag exposes an unique identifier of the system chassis. If this information is not known this property is set to an empty string.
๐ธ Methods ๐ธ
Okay so these are the calls you can actually make. Let's go, one by one, no skips. ๐
SetHostname()sets the transient (dynamic) hostname, which is used if no static hostname is set. This value must be an internet-style hostname, 7-bit lowercase ASCII, no special chars/spaces. An empty string will unset the transient hostname.SetStaticHostname()sets the static hostname which is exposed by theStaticHostnameproperty. When called with an empty argument, the static configuration in/etc/hostnameis removed. Since the static hostname has the highest priority, calling this function usually affects also theHostnameproperty and the effective hostname configured in the kernel. Big moves. ๐ฅSetPrettyHostname()sets the pretty hostname which is exposed by thePrettyHostnameproperty.SetIconName(),SetChassis(),SetDeployment(), andSetLocation()set the propertiesIconName(the name of the icon representing for the machine),Chassis(the machine form factor),Deployment(the system deployment environment), andLocation(physical system location), respectively.SetTags()sets the machine tags exposed by theTagsproperty. It takes a list of strings, each of which must be a valid machine tag (1...255 ASCII alphanumeric characters,"-"and"."). Passing an empty list removes theTAGS=field from/etc/machine-info.AddAndRemoveTags()incrementally updates theTagsproperty instead of replacing it. It takes two lists of machine tags: the tags in add are added to the current list, and the tags in remove are dropped from it โ the resulting list is(current โช add) \ remove, sorted and deduplicated. This is useful when several independent agents each manage a subset of the tags without racing on a read-modify-write of the full list. Each tag must be a valid machine tag, as forSetTags(). Collaborative queenies, we love to see it. ๐ซถ
PrettyHostname, IconName, Chassis, Deployment, Location, and Tags are stored in /etc/machine-info. See machine-info(5) for the semantics of those settings.
GetProductUUID()returns the "product UUID" as exposed by the kernel based on DMI information in/sys/class/dmi/id/product_uuid. Reading the file directly requires root privileges, and this method allows access to unprivileged clients through the polkit framework. Look at us being inclusive. โจGetHardwareSerial()returns the "hardware serial" as exposed by the kernel based on DMI information. Reading the file directly requires root privileges, and this method allows access to unprivileged clients through the polkit framework.Describe()returns a JSON representation of all properties in one. One-stop shop, we're obsessed. ๐GetMachineInfo()returns the value of the given field from/etc/machine-info. For well-known fields, this method reads values from the same internal cache used by the corresponding D-Bus property getters, but returns only the raw/etc/machine-infovalues (i.e. without property-level fallback logic such as DMI/chassis-based detection). Custom (non-standard) fields are read directly from the file. An error is returned if the field name is empty, invalid, or not set in the file. So like, check your field names bestie. ๐ญ
๐ Security ๐
The interactive boolean parameters can be used to control whether polkit should interactively ask the user for authentication credentials if required. Consent matters, always. ๐
The polkit action for SetHostname() is org.freedesktop.hostname1.set-hostname.
For SetStaticHostname() and SetPrettyHostname() it is org.freedesktop.hostname1.set-static-hostname.
For SetIconName(), SetChassis(), SetDeployment(), SetLocation(), SetTags() and AddAndRemoveTags() it is org.freedesktop.hostname1.set-machine-info.
๐ RECOMMENDATIONS ๐
okay so bestie, here's three lil scenarios where the pretty hostname and the icon name are supposed to be used, and honestly they're so good:
- When you're registering DNS-SD services: put the pretty hostname in the service name, and pass the icon name in the TXT data, if there even is an icon name. Then browsing clients can just show the server icon on every single service, like โจmagicโจ. This is extra useful for WebDAV applications or UPnP media sharing.
- Set the bluetooth name to the pretty hostname. do it. it's cute.
- When your file browser has a "Computer" icon, swap the name out for the pretty hostname if it's set, and swap the icon out for the icon name, if that is set.
To properly handle name lookups when your local hostnames keep changing and you do not want to be out here editing /etc/hosts every five minutes, we recommend using systemd-hostnamed in combination with nss-myhostname(8). that's the combo, that's the move ๐ซถ
Now here are some recommendations to follow when generating a static (internet) hostname from a pretty name:
- Generate a single DNS label only, not an FQDN. That means no dots allowed. Strip them, or replace them with
-. - It's probably safer to not use any non-ASCII chars, even if DNS allows this in some way these days. In fact, restrict your charset to
"a-zA-Z0-9"and"-". Strip other chars, or try to replace them in some smart way with chars from this set, for example"รค"โ"ae", and use"-"as the replacement for all punctuation characters and whitespace. - Try to avoid creating repeated
"-", as well as"-"as the first or last char. no--, no leading dash, no trailing dash, we're not doing that ๐ - Limit the hostname to 63 chars, which is the length of a DNS label.
- If after stripping special chars the empty string is the result, you can pass this as-is to
systemd-hostnamedin which case it will automatically use a suitable fallback. iconic behaviour honestly. - Uppercase characters should be replaced with their lowercase equivalents.
Note that whilesystemd-hostnamedapplies some checks to the hostname you pass, they are much looser than the recommendations above. For example,systemd-hostnamedwill also accept"_"in the hostname, but we recommend not using this to avoid clashes with DNS-SD service types. Alsosystemd-hostnamedallows longer hostnames, but because of the DNS label limitations, we recommend not making use of this.
Here are a couple of example conversions, and ngl these are lowkey my favourite part:
"Lennart's PC"โ"lennarts-pc""Mรผllers Computer"โ"muellers-computer""Voran!"โ"voran""Es war einmal ein Mรคnnlein"โ"es-war-einmal-ein-maennlein""Jawoll. Ist doch wahr!"โ"jawoll-ist-doch-wahr""ใฌใใผใ"โ"localhost""...zack!!! zack!..."โ"zack-zack"
Of course, an already valid internet hostname label that you enter and pass through this conversion should stay unmodified, so that users have direct control of it, if they want โ by simply ignoring the fact that the pretty hostname is pretty and just editing it as if it was the normal internet name. main character energy: you keep control, periodt.
๐ EXAMPLES ๐
Example 1. Introspect org.freedesktop.hostname1 on the bus
$ gdbus introspect --system \
--dest org.freedesktop.hostname1 \
--object-path /org/freedesktop/hostname1
๐ฆ VERSIONING ๐ฆ
These D-Bus interfaces follow the usual interface versioning guidelines[2].
โญ HISTORY โญ
The D-Bus API
FirmwareVersionandGetHardwareSerial()were added in version 251.OperatingSystemSupportEnd,FirmwareVendor, andFirmwareDatewere added in version 253.MachineID,BootIDandVSockCIDwere added in version 256.ChassisAssetTag,OperatingSystemImageID,OperatingSystemImageVersion,HardwareSKU, andHardwareVersionwere added in version 258.OperatingSystemFancyNamewas added in version 260.GetMachineInfo(),TagsandSetTags()were added in version 261.AddAndRemoveTags()was added in version 262.
๐ SEE ALSO ๐
systemd(1), systemd-hostnamed.service(8), hostnamectl(1), David Zeuthen's original Fedora Feature page about xdg-hostname[3]
๐ NOTES ๐
- polkit
https://www.freedesktop.org/software/polkit/docs/latest/ - the usual interface versioning guidelines
https://0pointer.de/blog/projects/versioning-dbus.html - Feature page about xdg-hostname
https://fedoraproject.org/wiki/Features/BetterHostname
and that's the whole page bestie!! ๐ this one shipped as systemd 262.1 and it lives under the title ORG.FREED....HOSTNAME1(5). go forth, name your hosts pretty, convert them responsibly, and remember: pretty name for the vibes, DNS label for the internet. slay ๐ฆโจ๐ธ
๐ฆ where this page comes from
- arch rolling: systemd 262.1-1 ยท LGPL-2.1-or-later AND CC0-1.0 AND GPL-2.0-or-later AND MIT-0
- ๐ girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms