{
    "content": [
        {
            "type": "text",
            "text": "# org.freedesktop.hostname1(5) (man)\n\n**Summary:** org.freedesktop.hostname1 - The D-Bus interface of systemd-hostnamed\n\n## Examples\n\n- `$ gdbus introspect --system \\`\n- `--dest org.freedesktop.hostname1 \\`\n- `--object-path /org/freedesktop/hostname1`\n\n## Section Outline\n\n- **NAME** (2 lines)\n- **INTRODUCTION** (4 lines)\n- **THE D-BUS API** (88 lines)\n- **SEMANTICS** (62 lines) — 2 subsections\n  - Methods (25 lines)\n  - Security (8 lines)\n- **RECOMMENDATIONS** (62 lines)\n- **VERSIONING** (2 lines)\n- **EXAMPLES** (1 lines) — 1 subsections\n  - Example 1. Introspect org.freedesktop.hostname1 on the bus (5 lines)\n- **SEE ALSO** (2 lines)\n- **NOTES** (12 lines)\n\n## Full Content\n\n### NAME\n\norg.freedesktop.hostname1 - The D-Bus interface of systemd-hostnamed\n\n### INTRODUCTION\n\nsystemd-hostnamed.service(8) is a system service that can be used to control the hostname and\nrelated machine metadata from user programs. This page describes the hostname semantics and\nthe D-Bus interface.\n\n### THE D-BUS API\n\nThe service exposes the following interfaces on the bus:\n\nnode /org/freedesktop/hostname1 {\ninterface org.freedesktop.hostname1 {\nmethods:\nSetHostname(in  s hostname,\nin  b interactive);\nSetStaticHostname(in  s hostname,\nin  b interactive);\nSetPrettyHostname(in  s hostname,\nin  b interactive);\nSetIconName(in  s icon,\nin  b interactive);\nSetChassis(in  s chassis,\nin  b interactive);\nSetDeployment(in  s deployment,\nin  b interactive);\nSetLocation(in  s location,\nin  b interactive);\nGetProductUUID(in  b interactive,\nout ay uuid);\nDescribe(out s json);\nproperties:\nreadonly s Hostname = '...';\nreadonly s StaticHostname = '...';\nreadonly s PrettyHostname = '...';\n@org.freedesktop.DBus.Property.EmitsChangedSignal(\"const\")\nreadonly s DefaultHostname = '...';\nreadonly s HostnameSource = '...';\nreadonly s IconName = '...';\nreadonly s Chassis = '...';\nreadonly s Deployment = '...';\nreadonly s Location = '...';\n@org.freedesktop.DBus.Property.EmitsChangedSignal(\"const\")\nreadonly s KernelName = '...';\n@org.freedesktop.DBus.Property.EmitsChangedSignal(\"const\")\nreadonly s KernelRelease = '...';\n@org.freedesktop.DBus.Property.EmitsChangedSignal(\"const\")\nreadonly s KernelVersion = '...';\n@org.freedesktop.DBus.Property.EmitsChangedSignal(\"const\")\nreadonly s OperatingSystemPrettyName = '...';\n@org.freedesktop.DBus.Property.EmitsChangedSignal(\"const\")\nreadonly s OperatingSystemCPEName = '...';\n@org.freedesktop.DBus.Property.EmitsChangedSignal(\"const\")\nreadonly s HomeURL = '...';\n@org.freedesktop.DBus.Property.EmitsChangedSignal(\"const\")\nreadonly s HardwareVendor = '...';\n@org.freedesktop.DBus.Property.EmitsChangedSignal(\"const\")\nreadonly s HardwareModel = '...';\n};\ninterface org.freedesktop.DBus.Peer { ... };\ninterface org.freedesktop.DBus.Introspectable { ... };\ninterface org.freedesktop.DBus.Properties { ... };\n};\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\nWhenever the hostname or other metadata is changed via the daemon, PropertyChanged signals\nare sent out to subscribed clients. Changing a hostname using this interface is authenticated\nvia polkit[1].\n\n### SEMANTICS\n\nThe StaticHostname property exposes the \"static\" hostname configured in /etc/hostname. It is\nnot always in sync with the current hostname as returned by the gethostname(3) system call.\nIf no static hostname is configured this property will be the empty string.\n\nWhen systemd(1) or systemd-hostnamed.service(8) set the hostname, this static hostname has\nthe highest priority.\n\nThe Hostname property exposes the actual hostname configured in the kernel via\nsethostname(3). It can be different from the static hostname. This property is never empty.\n\nThe PrettyHostname property exposes the pretty hostname which is a free-form UTF-8 hostname\nfor presentation to the user. User interfaces should ensure that the pretty hostname and the\nstatic hostname stay in sync. E.g. when the former is \"Lennart’s Computer\" the latter should\nbe \"lennarts-computer\". If no pretty hostname is set this setting will be the empty string.\nApplications should then find a suitable fallback, such as the dynamic hostname.\n\nThe DefaultHostname property exposes the default hostname (configured through os-release(5),\nor a fallback set at compilation time).\n\nThe HostnameSource property exposes the origin of the currently configured hostname. One of\n\"static\" (set from /etc/hostname), \"transient\" (a non-permanent hostname from an external\nsource), \"default\" (the value from os-release or the compiled-in fallback).\n\nThe IconName property exposes the icon name following the XDG icon naming spec. If not set,\ninformation such as the chassis type (see below) is used to find a suitable fallback icon\nname (i.e.  \"computer-laptop\" vs.  \"computer-desktop\" is picked based on the chassis\ninformation). If no such data is available, the empty string is returned. In that case an\napplication should fall back to a replacement icon, for example \"computer\". If this property\nis set to the empty string, the automatic fallback name selection is enabled again.\n\nThe Chassis property exposes a chassis type, one of the currently defined chassis types:\n\"desktop\", \"laptop\", \"server\", \"tablet\", \"handset\", as well as the special chassis types \"vm\"\nand \"container\" for virtualized systems. Note that in most cases the chassis type will be\ndetermined automatically from DMI/SMBIOS/ACPI firmware information. Writing to this setting\nis hence useful only to override misdetected chassis types, or to configure the chassis type\nif it could not be auto-detected. Set this property to the empty string to reenable the\nautomatic detection of the chassis type from firmware information.\n\nNote that systemd-hostnamed starts only on request and terminates after a short idle period.\nThis effectively means that PropertyChanged messages are not sent out for changes made\ndirectly on the files (as in: administrator edits the files with vi). This is the intended\nbehavior: manual configuration changes should require manual reloading.\n\nThe transient (dynamic) hostname exposed by the Hostname property maps directly to the kernel\nhostname. This hostname should be assumed to be highly dynamic, and hence should be watched\ndirectly, without depending on PropertyChanged messages from systemd-hostnamed. To accomplish\nthis, open /proc/sys/kernel/hostname and poll(3) for SIGHUP which is triggered by the kernel\nevery time the hostname changes. Again: this is special for the transient (dynamic) hostname,\nand does not apply to the configured (fixed) hostname.\n\nApplications may read the hostname data directly if hostname change notifications are not\nnecessary. Use gethostname(3), /etc/hostname (possibly with per-distribution fallbacks), and\nmachine-info(3) for that. For more information on these files and syscalls see the respective\nman pages.\n\nKernelName, KernelRelease, and KernelVersion expose the kernel name (e.g.  \"Linux\"), release\n(e.g.  \"5.0.0-11\"), and version (i.e. the build number, e.g.  \"#11\") as reported by uname(2).\nOperatingSystemPrettyName, OperatingSystemCPEName, and HomeURL expose the PRETTYNAME=,\nCPENAME= and HOMEURL= fields from os-release(5). The purpose of those properties is to\nallow remote clients to access this information over D-Bus. Local clients can access the\ninformation directly.\n\n#### Methods\n\nSetHostname() sets the transient (dynamic) hostname, which is used if no static hostname is\nset. This value must be an internet-style hostname, 7-bit lowercase ASCII, no special\nchars/spaces. An empty string will unset the transient hostname.\n\nSetStaticHostname() sets the static hostname which is exposed by the StaticHostname property.\nWhen called with an empty argument, the static configuration in /etc/hostname is removed.\nSince the static hostname has the highest priority, calling this function usually affects\nalso the Hostname property and the effective hostname configured in the kernel.\n\nSetPrettyHostname() sets the pretty hostname which is exposed by the PrettyHostname property.\n\nSetIconName(), SetChassis(), SetDeployment(), and SetLocation() set the properties IconName\n(the name of the icon representing for the machine), Chassis (the machine form factor),\nDeployment (the system deployment environment), and Location (physical system location),\nrespectively.\n\nPrettyHostname, IconName, Chassis, Deployment, and Location are stored in /etc/machine-info.\nSee machine-info(5) for the semantics of those settings.\n\nGetProductUUID() returns the \"product UUID\" as exposed by the kernel based on DMI information\nin /sys/class/dmi/id/productuuid. Reading the file directly requires root privileges, and\nthis method allows access to unprivileged clients through the polkit framework.\n\nDescribe() returns a JSON representation of all properties in one.\n\n#### Security\n\nThe interactive boolean parameters can be used to control whether polkit should interactively\nask the user for authentication credentials if required.\n\nThe polkit action for SetHostname() is org.freedesktop.hostname1.set-hostname. For\nSetStaticHostname() and SetPrettyHostname() it is\norg.freedesktop.hostname1.set-static-hostname. For SetIconName(), SetChassis(),\nSetDeployment() and SetLocation() it is org.freedesktop.hostname1.set-machine-info.\n\n### RECOMMENDATIONS\n\nHere are three examples that show how the pretty hostname and the icon name should be used:\n\n•   When registering DNS-SD services: use the pretty hostname in the service name, and pass\nthe icon name in the TXT data, if there is an icon name. Browsing clients can then show\nthe server icon on each service. This is especially useful for WebDAV applications or\nUPnP media sharing.\n\n•   Set the bluetooth name to the pretty hostname.\n\n•   When your file browser has a \"Computer\" icon, replace the name with the pretty hostname\nif set, and the icon with the icon name, if it is set.\n\nTo properly handle name lookups with changing local hostnames without having to edit\n/etc/hosts, we recommend using systemd-hostnamed in combination with nss-myhostname(3).\n\nHere are some recommendations to follow when generating a static (internet) hostname from a\npretty name:\n\n•   Generate a single DNS label only, not an FQDN. That means no dots allowed. Strip them, or\nreplace them with \"-\".\n\n•   It's probably safer to not use any non-ASCII chars, even if DNS allows this in some way\nthese days. In fact, restrict your charset to \"a-zA-Z0-9\" and \"-\". Strip other chars, or\ntry to replace them in some smart way with chars from this set, for example \"ä\" → \"ae\",\nand use \"-\" as the replacement for all punctuation characters and whitespace.\n\n•   Try to avoid creating repeated \"-\", as well as \"-\" as the first or last char.\n\n•   Limit the hostname to 63 chars, which is the length of a DNS label.\n\n•   If after stripping special chars the empty string is the result, you can pass this as-is\nto systemd-hostnamed in which case it will automatically use a suitable fallback.\n\n•   Uppercase charaacters should be replaced with their lowercase equivalents.\n\nNote that while systemd-hostnamed applies some checks to the hostname you pass they are much\nlooser than the recommendations above. For example, systemd-hostnamed will also accept \"\" in\nthe hostname, but we recommend not using this to avoid clashes with DNS-SD service types.\nAlso systemd-hostnamed allows longer hostnames, but because of the DNS label limitations, we\nrecommend not making use of this.\n\nHere are a couple of example conversions:\n\n•   \"Lennart's PC\" → \"lennarts-pc\"\n\n•   \"Müllers Computer\" → \"muellers-computer\"\n\n•   \"Voran!\"  → \"voran\"\n\n•   \"Es war einmal ein Männlein\" → \"es-war-einmal-ein-maennlein\"\n\n•   \"Jawoll. Ist doch wahr!\"  → \"jawoll-ist-doch-wahr\"\n\n•   \"レナート\" → \"localhost\"\n\n•   \"...zack!!! zack!...\"  → \"zack-zack\"\n\nOf course, an already valid internet hostname label you enter and pass through this\nconversion should stay unmodified, so that users have direct control of it, if they want — by\nsimply ignoring the fact that the pretty hostname is pretty and just edit it as if it was the\nnormal internet name.\n\n### VERSIONING\n\nThese D-Bus interfaces follow the usual interface versioning guidelines[2].\n\n### EXAMPLES\n\n#### Example 1. Introspect org.freedesktop.hostname1 on the bus\n\n$ gdbus introspect --system \\\n--dest org.freedesktop.hostname1 \\\n--object-path /org/freedesktop/hostname1\n\n### SEE ALSO\n\nDavid Zeuthen's original Fedora Feature page about xdg-hostname[3]\n\n### NOTES\n\n1. polkit\nhttps://www.freedesktop.org/software/polkit/docs/latest/\n\n2. the usual interface versioning guidelines\nhttp://0pointer.de/blog/projects/versioning-dbus.html\n\n3. Feature page about xdg-hostname\nhttps://fedoraproject.org/wiki/Features/BetterHostname\n\n\n\nsystemd 249                                                             ORG.FREEDESKTOP.HOSTNAME1(5)\n\n"
        }
    ],
    "structuredContent": {
        "command": "org.freedesktop.hostname1",
        "section": "5",
        "mode": "man",
        "summary": "org.freedesktop.hostname1 - The D-Bus interface of systemd-hostnamed",
        "synopsis": null,
        "flags": [],
        "examples": [
            "$ gdbus introspect --system \\",
            "--dest org.freedesktop.hostname1 \\",
            "--object-path /org/freedesktop/hostname1"
        ],
        "see_also": [],
        "section_outline": [
            {
                "name": "NAME",
                "lines": 2,
                "subsections": []
            },
            {
                "name": "INTRODUCTION",
                "lines": 4,
                "subsections": []
            },
            {
                "name": "THE D-BUS API",
                "lines": 88,
                "subsections": []
            },
            {
                "name": "SEMANTICS",
                "lines": 62,
                "subsections": [
                    {
                        "name": "Methods",
                        "lines": 25
                    },
                    {
                        "name": "Security",
                        "lines": 8
                    }
                ]
            },
            {
                "name": "RECOMMENDATIONS",
                "lines": 62,
                "subsections": []
            },
            {
                "name": "VERSIONING",
                "lines": 2,
                "subsections": []
            },
            {
                "name": "EXAMPLES",
                "lines": 1,
                "subsections": [
                    {
                        "name": "Example 1. Introspect org.freedesktop.hostname1 on the bus",
                        "lines": 5
                    }
                ]
            },
            {
                "name": "SEE ALSO",
                "lines": 2,
                "subsections": []
            },
            {
                "name": "NOTES",
                "lines": 12,
                "subsections": []
            }
        ]
    }
}