Debian Codegraph @

upstream/debian-trixie/man5/hostname.5

raw
1 '\" t
2 .TH "HOSTNAME" "5" "" "systemd 257.13" "hostname"
3 .\" -----------------------------------------------------------------
4 .\" * Define some portability stuff
5 .\" -----------------------------------------------------------------
6 .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
7 .\" http://bugs.debian.org/507673
8 .\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html
9 .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
10 .ie \n(.g .ds Aq \(aq
11 .el .ds Aq '
12 .\" -----------------------------------------------------------------
13 .\" * set default formatting
14 .\" -----------------------------------------------------------------
15 .\" disable hyphenation
16 .nh
17 .\" disable justification (adjust text to left margin only)
18 .ad l
19 .\" -----------------------------------------------------------------
20 .\" * MAIN CONTENT STARTS HERE *
21 .\" -----------------------------------------------------------------
22 .SH "NAME"
23 hostname \- Local hostname configuration file
24 .SH "SYNOPSIS"
25 .PP
26 /etc/hostname
27 .SH "DESCRIPTION"
28 .PP
29 The
30 /etc/hostname
31 file configures the name of the local system\&. Unless overridden as described in the next section,
32 \fBsystemd\fR(1)
33 will set this hostname during boot using the
34 \fBsethostname\fR(2)
35 system call\&.
36 .PP
37 The file should contain a single newline\-terminated hostname string\&. Comments (lines starting with a
38 "#") 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 strongly recommended that this name contains only a single DNS label, i\&.e does not contain any dots\&. This recommendation reflects both usual expectations of applications, and the fact that the Linux kernel limits the length of the system hostname to 64 (i\&.e\&. close to the maximum DNS label length of 63) rather than 255 (the maximum DNS domain name length)\&. When applied, 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\&.
39 .PP
40 You may use
41 \fBhostnamectl\fR(1)
42 to change the value of this file during runtime from the command line\&. Use
43 \fBsystemd-firstboot\fR(1)
44 to initialize it on mounted (but not booted) system images\&.
45 .SH "HOSTNAME SEMANTICS"
46 .PP
47 \fBsystemd\fR(1)
48 and the associated tools will obtain the hostname in the following ways:
49 .sp
50 .RS 4
51 .ie n \{\
52 \h'-04'\(bu\h'+03'\c
53 .\}
54 .el \{\
55 .sp -1
56 .IP \(bu 2.3
57 .\}
58 If the kernel command line parameter
59 \fIsystemd\&.hostname=\fR
60 specifies a valid hostname,
61 \fBsystemd\fR(1)
62 will use it to set the hostname during early boot, see
63 \fBkernel-command-line\fR(7),
64 .RE
65 .sp
66 .RS 4
67 .ie n \{\
68 \h'-04'\(bu\h'+03'\c
69 .\}
70 .el \{\
71 .sp -1
72 .IP \(bu 2.3
73 .\}
74 Otherwise, the "static" hostname specified by
75 /etc/hostname
76 as described above will be used\&.
77 .RE
78 .sp
79 .RS 4
80 .ie n \{\
81 \h'-04'\(bu\h'+03'\c
82 .\}
83 .el \{\
84 .sp -1
85 .IP \(bu 2.3
86 .\}
87 Otherwise, a transient hostname may be set during runtime, for example based on information in a DHCP lease, see
88 \fBsystemd-hostnamed.service\fR(8)\&. Both
89 \m[blue]\fBNetworkManager\fR\m[]\&\s-2\u[1]\d\s+2
90 and
91 \fBsystemd-networkd.service\fR(8)
92 allow this\&. Note that
93 \fBsystemd-hostnamed.service\fR(8)
94 gives higher priority to the static hostname, so the transient hostname will only be used if the static hostname is not configured\&.
95 .RE
96 .sp
97 .RS 4
98 .ie n \{\
99 \h'-04'\(bu\h'+03'\c
100 .\}
101 .el \{\
102 .sp -1
103 .IP \(bu 2.3
104 .\}
105 Otherwise, a fallback hostname configured at compilation time will be used ("localhost")\&.
106 .RE
107 .PP
108 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\&.
109 .SH "HISTORY"
110 .PP
111 The simple configuration file format of
112 /etc/hostname
113 originates from Debian GNU/Linux\&.
114 .SH "SEE ALSO"
115 .PP
116 \fBsystemd\fR(1), \fBsethostname\fR(2), \fBhostname\fR(1), \fBhostname\fR(7), \fBmachine-id\fR(5), \fBmachine-info\fR(5), \fBhostnamectl\fR(1), \fBsystemd-hostnamed.service\fR(8), \fBsystemd-firstboot\fR(1)
117 .SH "NOTES"
118 .IP " 1." 4
119 NetworkManager
120 .RS 4
121 \%https://developer.gnome.org/NetworkManager/stable/
122 .RE