]> git.ipfire.org Git - thirdparty/systemd.git/blob - man/hostnamectl.xml
treewide: use log_*_errno whenever %m is in the format string
[thirdparty/systemd.git] / man / hostnamectl.xml
1 <?xml version='1.0'?> <!--*-nxml-*-->
2 <!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.2//EN"
3 "http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd">
4
5 <!--
6 This file is part of systemd.
7
8 Copyright 2012 Lennart Poettering
9
10 systemd is free software; you can redistribute it and/or modify it
11 under the terms of the GNU Lesser General Public License as published by
12 the Free Software Foundation; either version 2.1 of the License, or
13 (at your option) any later version.
14
15 systemd is distributed in the hope that it will be useful, but
16 WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 Lesser General Public License for more details.
19
20 You should have received a copy of the GNU Lesser General Public License
21 along with systemd; If not, see <http://www.gnu.org/licenses/>.
22 -->
23
24 <refentry id="hostnamectl" conditional='ENABLE_HOSTNAMED'
25 xmlns:xi="http://www.w3.org/2001/XInclude">
26
27 <refentryinfo>
28 <title>hostnamectl</title>
29 <productname>systemd</productname>
30
31 <authorgroup>
32 <author>
33 <contrib>Developer</contrib>
34 <firstname>Lennart</firstname>
35 <surname>Poettering</surname>
36 <email>lennart@poettering.net</email>
37 </author>
38 </authorgroup>
39 </refentryinfo>
40
41 <refmeta>
42 <refentrytitle>hostnamectl</refentrytitle>
43 <manvolnum>1</manvolnum>
44 </refmeta>
45
46 <refnamediv>
47 <refname>hostnamectl</refname>
48 <refpurpose>Control the system hostname</refpurpose>
49 </refnamediv>
50
51 <refsynopsisdiv>
52 <cmdsynopsis>
53 <command>hostnamectl</command>
54 <arg choice="opt" rep="repeat">OPTIONS</arg>
55 <arg choice="req">COMMAND</arg>
56 </cmdsynopsis>
57 </refsynopsisdiv>
58
59 <refsect1>
60 <title>Description</title>
61
62 <para><command>hostnamectl</command> may be used to
63 query and change the system hostname and related
64 settings.</para>
65
66 <para>This tool distinguishes three different
67 hostnames: the high-level "pretty" hostname which
68 might include all kinds of special characters
69 (e.g. "Lennart's Laptop"), the static hostname which
70 is used to initialize the kernel hostname at boot
71 (e.g. "lennarts-laptop"), and the transient hostname
72 which is a default received from network configuration.
73 If a static hostname is set, and is valid (something other
74 than localhost), then the transient hostname is not used.</para>
75
76 <para>Note that the pretty hostname has little
77 restrictions on the characters used, while the static
78 and transient hostnames are limited to the usually
79 accepted characters of Internet domain names.</para>
80
81 <para>The static hostname is stored in
82 <filename>/etc/hostname</filename>, see
83 <citerefentry><refentrytitle>hostname</refentrytitle><manvolnum>5</manvolnum></citerefentry>
84 for more information. The pretty hostname, chassis
85 type, and icon name are stored in
86 <filename>/etc/machine-info</filename>, see
87 <citerefentry><refentrytitle>machine-info</refentrytitle><manvolnum>5</manvolnum></citerefentry>.</para>
88
89 <para>Use
90 <citerefentry><refentrytitle>systemd-firstboot</refentrytitle><manvolnum>1</manvolnum></citerefentry>
91 to initialize the system host name for mounted (but
92 not booted) system images.</para>
93 </refsect1>
94
95 <refsect1>
96 <title>Options</title>
97
98 <para>The following options are understood:</para>
99
100 <variablelist>
101 <varlistentry>
102 <term><option>--no-ask-password</option></term>
103
104 <listitem><para>Do not query the user
105 for authentication for privileged
106 operations.</para></listitem>
107 </varlistentry>
108
109 <varlistentry>
110 <term><option>--static</option></term>
111 <term><option>--transient</option></term>
112 <term><option>--pretty</option></term>
113
114 <listitem><para>If
115 <command>status</command> is used (or
116 no explicit command is given) and one
117 of those fields is given,
118 <command>hostnamectl</command> will
119 print out just this selected
120 hostname.</para>
121
122 <para>If used with
123 <command>set-hostname</command>, only
124 the selected hostname(s) will be
125 updated. When more than one of those
126 options is used, all the specified
127 hostnames will be updated.
128 </para></listitem>
129 </varlistentry>
130
131 <xi:include href="user-system-options.xml" xpointer="host" />
132 <xi:include href="user-system-options.xml" xpointer="machine" />
133
134 <xi:include href="standard-options.xml" xpointer="help" />
135 <xi:include href="standard-options.xml" xpointer="version" />
136 </variablelist>
137
138 <para>The following commands are understood:</para>
139
140 <variablelist>
141 <varlistentry>
142 <term><command>status</command></term>
143
144 <listitem><para>Show current system
145 hostname and related
146 information.</para></listitem>
147 </varlistentry>
148
149 <varlistentry>
150 <term><command>set-hostname <replaceable>NAME</replaceable></command></term>
151
152 <listitem><para>Set the system
153 hostname to
154 <replaceable>NAME</replaceable>. By
155 default, this will alter the pretty,
156 the static, and the transient hostname
157 alike; however, if one or more of
158 <option>--static</option>,
159 <option>--transient</option>,
160 <option>--pretty</option> are used,
161 only the selected hostnames are
162 changed. If the pretty hostname is
163 being set, and static or transient are
164 being set as well, the specified
165 hostname will be simplified in regards
166 to the character set used before the
167 latter are updated. This is done by
168 replacing spaces with
169 <literal>-</literal> and removing
170 special characters. This ensures that
171 the pretty and the static hostname are
172 always closely related while still
173 following the validity rules of the
174 specific name. This simplification of
175 the hostname string is not done if
176 only the transient and/or static host
177 names are set, and the pretty host
178 name is left untouched.</para>
179
180 <para>Pass the empty string
181 <literal></literal> as the hostname to
182 reset the selected hostnames to their
183 default (usually
184 <literal>localhost</literal>).</para></listitem>
185 </varlistentry>
186
187 <varlistentry>
188 <term><command>set-icon-name <replaceable>NAME</replaceable></command></term>
189
190 <listitem><para>Set the system icon
191 name to
192 <replaceable>NAME</replaceable>. The
193 icon name is used by some graphical
194 applications to visualize this host.
195 The icon name should follow the <ulink
196 url="http://standards.freedesktop.org/icon-naming-spec/icon-naming-spec-latest.html">Icon
197 Naming Specification</ulink>.</para>
198
199 <para>Pass an empty string to reset
200 the icon name to the default value,
201 which is determined from chassis type
202 (see below) and possibly other
203 parameters.</para></listitem>
204 </varlistentry>
205
206 <varlistentry>
207 <term><command>set-chassis <replaceable>TYPE</replaceable></command></term>
208
209 <listitem><para>Set the chassis type
210 to <replaceable>TYPE</replaceable>.
211 The chassis type is used by some
212 graphical applications to visualize
213 the host or alter user interaction.
214 Currently, the following chassis types
215 are defined:
216 <literal>desktop</literal>,
217 <literal>laptop</literal>,
218 <literal>server</literal>,
219 <literal>tablet</literal>,
220 <literal>handset</literal>,
221 <literal>watch</literal>,
222 <literal>embedded</literal> as well as
223 the special chassis types
224 <literal>vm</literal> and
225 <literal>container</literal> for
226 virtualized systems that lack an
227 immediate physical chassis.</para>
228
229 <para>Pass an empty string to reset
230 the chassis type to the default value
231 which is determined from the firmware
232 and possibly other parameters.</para>
233 </listitem>
234 </varlistentry>
235
236 <varlistentry>
237 <term><command>set-deployment <replaceable>ENVIRONMENT</replaceable></command></term>
238
239 <listitem><para>Set the deployment
240 environment
241 description. <replaceable>ENVIRONMENT</replaceable>
242 must be a single word without any
243 control characters. One of the
244 following is suggested:
245 <literal>development</literal>,
246 <literal>integration</literal>,
247 <literal>staging</literal>,
248 <literal>production</literal>.
249 </para>
250
251 <para>Pass an empty string to reset to
252 the default empty value.</para>
253 </listitem>
254 </varlistentry>
255
256 <varlistentry>
257 <term><command>set-location <replaceable>LOCATION</replaceable></command></term>
258
259 <listitem><para>Set the location
260 string for the system, if it is
261 known. <replaceable>LOCATION</replaceable>
262 should be a human-friendly, free-form
263 string describing the physical
264 location of the system, if it is known
265 and applicable. This may be as generic
266 as <literal>Berlin, Germany</literal>
267 or as specific as <literal>Left Rack,
268 2nd Shelf</literal>.</para>
269
270 <para>Pass an empty string to reset to
271 the default empty value.</para>
272 </listitem>
273 </varlistentry>
274 </variablelist>
275 </refsect1>
276
277 <refsect1>
278 <title>Exit status</title>
279
280 <para>On success, 0 is returned, a non-zero failure
281 code otherwise.</para>
282 </refsect1>
283
284 <refsect1>
285 <title>See Also</title>
286 <para>
287 <citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
288 <citerefentry><refentrytitle>hostname</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
289 <citerefentry><refentrytitle>hostname</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
290 <citerefentry><refentrytitle>machine-info</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
291 <citerefentry><refentrytitle>systemctl</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
292 <citerefentry><refentrytitle>systemd-hostnamed.service</refentrytitle><manvolnum>8</manvolnum></citerefentry>,
293 <citerefentry><refentrytitle>systemd-firstboot</refentrytitle><manvolnum>1</manvolnum></citerefentry>
294 </para>
295 </refsect1>
296
297 </refentry>