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 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>
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>
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-id</refentrytitle><manvolnum>5</manvolnum></citerefentry>.</para>
91 <title>Options</title>
93 <para>The following options are understood:</para>
97 <term><option>--no-ask-password</option></term>
99 <listitem><para>Do not query the user
100 for authentication for privileged
101 operations.</para></listitem>
105 <term><option>-P</option></term>
106 <term><option>--privileged</option></term>
108 <listitem><para>Acquire privileges via PolicyKit
109 before executing the operation.</para></listitem>
113 <term><option>--static</option></term>
114 <term><option>--transient</option></term>
115 <term><option>--pretty</option></term>
118 <command>status</command> is used (or
119 no explicit command is given) and one
120 of those fields is given,
121 <command>hostnamectl</command> will
122 print out just this selected
126 <command>set-hostname</command>, only
127 the selected hostname(s) will be
128 updated. When more than one of those
129 options is used, all the specified
130 hostnames will be updated.
134 <xi:include href="user-system-options.xml" xpointer="host" />
136 <xi:include href="standard-options.xml" xpointer="help" />
137 <xi:include href="standard-options.xml" xpointer="version" />
140 <para>The following commands are understood:</para>
144 <term><command>status</command></term>
146 <listitem><para>Show current system
148 information.</para></listitem>
152 <term><command>set-hostname [NAME]</command></term>
154 <listitem><para>Set the system
155 hostname. By default, this will alter
156 the pretty, the static, and the
157 transient hostname alike; however, if
159 <option>--static</option>,
160 <option>--transient</option>,
161 <option>--pretty</option> are used,
162 only the selected hostnames are
163 changed. If the pretty hostname is
164 being set, and static or transient are
165 being set as well, the specified
166 hostname will be simplified in regards
167 to the character set used before the
168 latter are updated. This is done by
169 replacing spaces with
170 <literal>-</literal> and removing
171 special characters. This ensures that
172 the pretty and the static hostname are
173 always closely related while still
174 following the validity rules of the
175 specific name. This simplification of
176 the hostname string is not done if
177 only the transient and/or static host
178 names are set, and the pretty host
179 name is left untouched. Pass the empty
180 string <literal></literal> as the
181 hostname to reset the selected
182 hostnames to their default (usually
183 <literal>localhost</literal>).</para></listitem>
187 <term><command>set-icon-name [NAME]</command></term>
189 <listitem><para>Set the system icon
190 name. The icon name is used by some
191 graphical applications to visualize
192 this host. The icon name should follow
194 url="http://standards.freedesktop.org/icon-naming-spec/icon-naming-spec-latest.html">Icon
195 Naming Specification</ulink>. Pass an
196 empty string to this operation to
197 reset the icon name to the default
198 value, which is determined from chassis
199 type (see below) and possibly other
200 parameters.</para></listitem>
204 <term><command>set-chassis [TYPE]</command></term>
206 <listitem><para>Set the chassis
207 type. The chassis type is used by some
208 graphical applications to visualize
209 the host or alter user
210 interaction. Currently, the following
211 chassis types are defined:
212 <literal>desktop</literal>,
213 <literal>laptop</literal>,
214 <literal>server</literal>,
215 <literal>tablet</literal>,
216 <literal>handset</literal>, as well as
217 the special chassis types
218 <literal>vm</literal> and
219 <literal>container</literal> for
220 virtualized systems that lack an
221 immediate physical chassis. Pass an
222 empty string to this operation to
223 reset the chassis type to the default
224 value which is determined from the
225 firmware and possibly other
226 parameters.</para></listitem>
233 <title>Exit status</title>
235 <para>On success, 0 is returned, a non-zero failure
236 code otherwise.</para>
240 <title>See Also</title>
242 <citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
243 <citerefentry><refentrytitle>hostname</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
244 <citerefentry><refentrytitle>hostname</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
245 <citerefentry><refentrytitle>machine-info</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
246 <citerefentry><refentrytitle>systemctl</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
247 <citerefentry><refentrytitle>systemd-hostnamed.service</refentrytitle><manvolnum>8</manvolnum></citerefentry>