hostname - Man Page

Local hostname configuration file

Synopsis

/etc/hostname

Description

The /etc/hostname file configures the name of the local system. Unless overridden as described in the next section, systemd(1) will set this hostname during boot using the sethostname(2) system call.

The file should contain a single newline-terminated hostname string. Comments (lines starting with a "#") are ignored. The hostname should be composed of up to 64 7-bit ASCII lower-case alphanumeric characters or hyphens forming a valid DNS domain name. It is recommended that this name contains only a single label, i.e. without any dots. Invalid characters will be filtered out in an attempt to make the name valid, but obviously it is recommended to use a valid name and not rely on this filtering.

You may use hostnamectl(1) to change the value of this file during runtime from the command line. Use systemd-firstboot(1) to initialize it on mounted (but not booted) system images.

Hostname Semantics

systemd(1) and the associated tools will obtain the hostname in the following ways:

Effectively, the static hostname has higher priority than a transient hostname, which has higher priority than the fallback hostname. Transient hostnames are equivalent, so setting a new transient hostname causes the previous transient hostname to be forgotten. The hostname specified on the kernel command line is like a transient hostname, with the exception that it has higher priority when the machine boots. Also note that those are the semantics implemented by systemd tools, but other programs may also set the hostname.

History

The simple configuration file format of /etc/hostname originates from Debian GNU/Linux.

See Also

systemd(1), sethostname(2), hostname(1), hostname(7), machine-id(5), machine-info(5), hostnamectl(1), systemd-hostnamed.service(8), systemd-firstboot(1)

Notes

1.

NetworkManager
https://developer.gnome.org/NetworkManager/stable/

Referenced By

hostnamectl(1), machine-id(5), machine-info(5), os-release(5), sssd-ad(5), sssd-ipa(5), systemd.directives(7), systemd-firstboot(1), systemd-hostnamed.service(8), systemd.index(7).

systemd 257~rc2