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