LinuxCommandLibrary

systemd-hostnamed.service

Manage system hostname and related metadata

SYNOPSIS

systemd-hostnamed.service is a background service managed by systemd. User interaction for its functionality is primarily via the hostnamectl utility:

hostnamectl [OPTIONS] [COMMAND]

PARAMETERS

status
    Displays the current system hostname, icon name, chassis, machine ID, boot ID, and other system information.

set-hostname NAME
    Sets the system's static hostname. This name is stored in /etc/hostname.

set-pretty-hostname NAME
    Sets a human-readable "pretty" hostname, often used in graphical user interfaces.

set-machine-id ID
    Sets the machine's unique ID. This ID is typically stored in /etc/machine-id.

--static
    Used with set-* commands to ensure the change is persistent and saved to disk.

--transient
    Used with set-hostname to set a hostname that is only valid until the next reboot.

--pretty
    Used with set-hostname to simultaneously set the pretty hostname to the same value as the static hostname.

-H, --host USER@HOST
    Operates on a remote host via SSH, allowing remote management of hostname properties.

DESCRIPTION

systemd-hostnamed.service is a core systemd service responsible for managing various host-specific identifiers. This includes the system's static hostname (e.g., mycomputer.local), the pretty hostname (a more descriptive and human-readable name like "My Laptop"), and the unique machine ID. It provides a D-Bus interface, allowing other system components and user utilities like hostnamectl(1) to query and modify these properties dynamically and persistently.

The service ensures consistency of hostname information across the system, updating relevant configuration files like /etc/hostname and /etc/machine-id when changes are made. It also handles transient hostnames, which are active only until the next reboot, alongside static ones that persist across reboots. By centralizing hostname management, systemd-hostnamed.service streamlines system configuration and provides a robust API for applications needing to identify the host. It runs automatically in the background as part of the systemd init system.

CAVEATS

systemd-hostnamed.service requires the D-Bus message bus to operate and expose its API.

Direct interaction with the systemd-hostnamed.service process is generally not required or recommended; instead, use the hostnamectl(1) utility, which communicates with the service via its D-Bus interface.

Modifying system identifiers like the hostname or machine ID requires appropriate administrative privileges (e.g., root access or PolicyKit permissions). Changes made without explicitly specifying --static or --transient typically apply to both the static and transient hostnames if applicable.

D-BUS INTERFACE

systemd-hostnamed.service exposes a well-defined D-Bus interface (org.freedesktop.hostname1) that allows other processes and applications to programmatically interact with and modify host-related properties without direct file manipulation.

CONFIGURATION FILES

The service manages and interacts with standard configuration files such as /etc/hostname (for the static hostname) and /etc/machine-id (for the unique machine identifier). It also supports managing the "pretty hostname" which is not stored in a traditional file but via other systemd mechanisms or D-Bus properties.

HISTORY

systemd-hostnamed.service was introduced as part of the systemd project, aiming to modernize and centralize the management of system hostnames and related identifiers. Prior to systemd, hostname management was often handled by simpler scripts or directly by the hostname(1) command, sometimes leading to inconsistencies between different system components.

With hostnamed, a consistent D-Bus API became available, allowing applications to reliably query and set these properties. Its development aligned with systemd's broader goal of providing well-defined APIs for common system tasks, improving interoperability and robustness across Linux distributions.

SEE ALSO

hostnamectl(1), hostname(1), systemctl(1), machine-id(5), systemd(1)

Copied to clipboard