# hostname(5) - man - phpMan

[HOSTNAME(5)](https://www.chedong.com/phpMan.php/man/HOSTNAME/5/markdown)                                   hostname                                   [HOSTNAME(5)](https://www.chedong.com/phpMan.php/man/HOSTNAME/5/markdown)



## NAME
       hostname - 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)](https://www.chedong.com/phpMan.php/man/systemd/1/markdown) will set this hostname during boot using the
       [**sethostname**(2)](https://www.chedong.com/phpMan.php/man/sethostname/2/markdown) 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)](https://www.chedong.com/phpMan.php/man/hostnamectl/1/markdown) to change the value of this file during runtime from the command
       line. Use [**systemd-firstboot**(1)](https://www.chedong.com/phpMan.php/man/systemd-firstboot/1/markdown) to initialize it on mounted (but not booted) system images.

## HOSTNAME SEMANTICS
       [**systemd**(1)](https://www.chedong.com/phpMan.php/man/systemd/1/markdown) and the associated tools will obtain the hostname in the following ways:

       •   If the kernel commandline parameter _systemd.hostname=_ specifies a valid hostname,
           [**systemd**(1)](https://www.chedong.com/phpMan.php/man/systemd/1/markdown) will use it to set the hostname during early boot, see [**kernel-command-line**(7)](https://www.chedong.com/phpMan.php/man/kernel-command-line/7/markdown),

       •   Otherwise, the "static" hostname specified by /etc/hostname as described above will be
           used.

       •   Otherwise, a transient hostname may be set during runtime, for example based on
           information in a DHCP lease, see [**systemd-hostnamed.service**(8)](https://www.chedong.com/phpMan.php/man/systemd-hostnamed.service/8/markdown). Both **NetworkManager**[1] and
           [**systemd-networkd.service**(8)](https://www.chedong.com/phpMan.php/man/systemd-networkd.service/8/markdown) allow this. Note that [**systemd-hostnamed.service**(8)](https://www.chedong.com/phpMan.php/man/systemd-hostnamed.service/8/markdown) gives
           higher priority to the static hostname, so the transient hostname will only be used if
           the static hostname is not configured.

       •   Otherwise, a fallback hostname configured at compilation time will be used ("localhost").

       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)](https://www.chedong.com/phpMan.php/man/systemd/1/markdown), [**sethostname**(2)](https://www.chedong.com/phpMan.php/man/sethostname/2/markdown), [**hostname**(1)](https://www.chedong.com/phpMan.php/man/hostname/1/markdown), [**hostname**(7)](https://www.chedong.com/phpMan.php/man/hostname/7/markdown), [**machine-id**(5)](https://www.chedong.com/phpMan.php/man/machine-id/5/markdown), [**machine-info**(5)](https://www.chedong.com/phpMan.php/man/machine-info/5/markdown),
       [**hostnamectl**(1)](https://www.chedong.com/phpMan.php/man/hostnamectl/1/markdown), [**systemd-hostnamed.service**(8)](https://www.chedong.com/phpMan.php/man/systemd-hostnamed.service/8/markdown), [**systemd-firstboot**(1)](https://www.chedong.com/phpMan.php/man/systemd-firstboot/1/markdown)

## NOTES
        1. NetworkManager
           <https://developer.gnome.org/NetworkManager/stable/>



systemd 249                                                                              [HOSTNAME(5)](https://www.chedong.com/phpMan.php/man/HOSTNAME/5/markdown)
