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">
6 This file is part of systemd.
8 Copyright 2012 Lennart Poettering
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.
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.
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/>.
24 <refentry id="hostnamectl" conditional='ENABLE_HOSTNAMED'
25 xmlns:xi="http://www.w3.org/2001/XInclude">
28 <title>hostnamectl</title>
29 <productname>systemd</productname>
33 <contrib>Developer</contrib>
34 <firstname>Lennart</firstname>
35 <surname>Poettering</surname>
36 <email>lennart@poettering.net</email>
42 <refentrytitle>hostnamectl</refentrytitle>
43 <manvolnum>1</manvolnum>
47 <refname>hostnamectl</refname>
48 <refpurpose>Control the system hostname</refpurpose>
53 <command>hostnamectl</command>
54 <arg choice="opt" rep="repeat">OPTIONS</arg>
55 <arg choice="req">COMMAND</arg>
60 <title>Description</title>
62 <para><command>hostnamectl</command> may be used to
63 query and change the system hostname and related
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 might be assigned temporarily due to network
73 configuration and might revert back to the static
74 hostname if network connectivity is lost and is only
75 temporarily written to the kernel hostname
76 (e.g. "dhcp-47-11").</para>
78 <para>Note that the pretty hostname has little
79 restrictions on the characters used, while the static
80 and transient hostnames are limited to the usually
81 accepted characters of Internet domain names.</para>
83 <para>The static hostname is stored in
84 <filename>/etc/hostname</filename>, see
85 <citerefentry><refentrytitle>hostname</refentrytitle><manvolnum>5</manvolnum></citerefentry>
86 for more information. The pretty hostname, chassis
87 type, and icon name are stored in
88 <filename>/etc/machine-info</filename>, see
89 <citerefentry><refentrytitle>machine-id</refentrytitle><manvolnum>5</manvolnum></citerefentry>.</para>
93 <title>Options</title>
95 <para>The following options are understood:</para>
99 <term><option>--no-ask-password</option></term>
101 <listitem><para>Do not query the user
102 for authentication for privileged
103 operations.</para></listitem>
107 <term><option>-P</option></term>
108 <term><option>--privileged</option></term>
110 <listitem><para>Acquire privileges via PolicyKit
111 before executing the operation.</para></listitem>
115 <term><option>-H</option></term>
116 <term><option>--host</option></term>
118 <listitem><para>Execute the operation
119 remotely. Specify a hostname, or
120 username and hostname separated by <literal>@</literal>,
121 to connect to. This will use SSH to
123 system.</para></listitem>
127 <term><option>--static</option></term>
128 <term><option>--transient</option></term>
129 <term><option>--pretty</option></term>
132 <command>status</command> is used (or
133 no explicit command is given) and one
134 of those fields is given,
135 <command>hostnamectl</command> will
136 print out just this selected
140 <command>set-hostname</command>, only
141 the selected hostname(s) will be
142 updated. When more than one of those
143 options is used, all the specified
144 hostnames will be updated.
148 <xi:include href="standard-options.xml" xpointer="help" />
149 <xi:include href="standard-options.xml" xpointer="version" />
152 <para>The following commands are understood:</para>
156 <term><command>status</command></term>
158 <listitem><para>Show current system
160 information.</para></listitem>
164 <term><command>set-hostname [NAME]</command></term>
166 <listitem><para>Set the system
167 hostname. By default, this will alter
168 the pretty, the static, and the
169 transient hostname alike; however, if
171 <option>--static</option>,
172 <option>--transient</option>,
173 <option>--pretty</option> are used,
174 only the selected hostnames are
175 changed. If the pretty hostname is
176 being set, and static or transient are
177 being set as well, the specified
178 hostname will be simplified in regards
179 to the character set used before the
180 latter are updated. This is done by
181 replacing spaces with
182 <literal>-</literal> and removing
183 special characters. This ensures that
184 the pretty and the static hostname are
185 always closely related while still
186 following the validity rules of the
187 specific name. This simplification of
188 the hostname string is not done if
189 only the transient and/or static host
190 names are set, and the pretty host
191 name is left untouched. Pass the empty
192 string <literal></literal> as the
193 hostname to reset the selected
194 hostnames to their default (usually
195 <literal>localhost</literal>).</para></listitem>
199 <term><command>set-icon-name [NAME]</command></term>
201 <listitem><para>Set the system icon
202 name. The icon name is used by some
203 graphical applications to visualize
204 this host. The icon name should follow
206 url="http://standards.freedesktop.org/icon-naming-spec/icon-naming-spec-latest.html">Icon
207 Naming Specification</ulink>. Pass an
208 empty string to this operation to
209 reset the icon name to the default
210 value, which is determined from chassis
211 type (see below) and possibly other
212 parameters.</para></listitem>
216 <term><command>set-chassis [TYPE]</command></term>
218 <listitem><para>Set the chassis
219 type. The chassis type is used by some
220 graphical applications to visualize
221 the host or alter user
222 interaction. Currently, the following
223 chassis types are defined:
224 <literal>desktop</literal>,
225 <literal>laptop</literal>,
226 <literal>server</literal>,
227 <literal>tablet</literal>,
228 <literal>handset</literal>, as well as
229 the special chassis types
230 <literal>vm</literal> and
231 <literal>container</literal> for
232 virtualized systems that lack an
233 immediate physical chassis. Pass an
234 empty string to this operation to
235 reset the chassis type to the default
236 value which is determined from the
237 firmware and possibly other
238 parameters.</para></listitem>
245 <title>Exit status</title>
247 <para>On success, 0 is returned, a non-zero failure
248 code otherwise.</para>
252 <title>See Also</title>
254 <citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
255 <citerefentry><refentrytitle>hostname</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
256 <citerefentry><refentrytitle>hostname</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
257 <citerefentry><refentrytitle>machine-info</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
258 <citerefentry><refentrytitle>systemctl</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
259 <citerefentry><refentrytitle>systemd-hostnamed.service</refentrytitle><manvolnum>8</manvolnum></citerefentry>