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'>
27 <title>hostnamectl</title>
28 <productname>systemd</productname>
32 <contrib>Developer</contrib>
33 <firstname>Lennart</firstname>
34 <surname>Poettering</surname>
35 <email>lennart@poettering.net</email>
41 <refentrytitle>hostnamectl</refentrytitle>
42 <manvolnum>1</manvolnum>
46 <refname>hostnamectl</refname>
47 <refpurpose>Control the system hostname</refpurpose>
52 <command>hostnamectl <arg choice="opt" rep="repeat">OPTIONS</arg> <arg choice="req">COMMAND</arg></command>
57 <title>Description</title>
59 <para><command>hostnamectl</command> may be used to
60 query and change the system hostname and related
63 <para>This tool distinguishes three different host
64 names: the high-level "pretty" hostname which might
65 include all kinds of special characters
66 (e.g. "Lennart's Laptop"), the static hostname which
67 is used to initialize the kernel hostname at boot
68 (e.g. "lennarts-laptop"), and the transient hostname
69 which might be assigned temporarily due to network
70 configuration and might revert back to the static
71 hostname if network connectivity is lost and is only
72 temporarily written to the kernel hostname
73 (e.g. "dhcp-47-11").</para>
75 <para>Note that the pretty hostname has little
76 restrictions on the characters used, while the static
77 and transient hostnames are limited to the usually
78 accepted characters of internet domain names.</para>
80 <para>The static host name is stored in
81 <filename>/etc/hostname</filename>, see
82 <citerefentry><refentrytitle>hostname</refentrytitle><manvolnum>5</manvolnum></citerefentry>
83 for more information. The pretty host name, chassis
84 type and icon name are stored in
85 <filename>/etc/machine-info</filename>, see
86 <citerefentry><refentrytitle>machine-id</refentrytitle><manvolnum>5</manvolnum></citerefentry>.</para>
90 <title>Options</title>
92 <para>The following options are understood:</para>
96 <term><option>-h</option></term>
97 <term><option>--help</option></term>
99 <listitem><para>Prints a short help
100 text and exits.</para></listitem>
104 <term><option>--version</option></term>
106 <listitem><para>Prints a short version
107 string and exits.</para></listitem>
111 <term><option>--no-ask-password</option></term>
113 <listitem><para>Don't query the user
114 for authentication for privileged
115 operations.</para></listitem>
119 <term><option>-H</option></term>
120 <term><option>--host</option></term>
122 <listitem><para>Execute the operation
123 remotely. Specify a hostname, or
124 username and hostname separated by @,
125 to connect to. This will use SSH to
127 system.</para></listitem>
131 <term><option>--static</option></term>
132 <term><option>--transient</option></term>
133 <term><option>--pretty</option></term>
136 <command>set-hostname</command> is
137 invoked and one or more of these
138 options are passed only the selected
140 updated.</para></listitem>
144 <para>The following commands are understood:</para>
148 <term><command>status</command></term>
150 <listitem><para>Show current system
152 information.</para></listitem>
156 <term><command>set-hostname [NAME]</command></term>
158 <listitem><para>Set the system
159 hostname. By default this will alter
160 the pretty, the static, and the
161 transient hostname alike, however if
163 <option>--static</option>,
164 <option>--transient</option>,
165 <option>--pretty</option> are used
166 only the selected hostnames are
167 changed. If the pretty hostname is
168 being set, and static or transient are
169 being set as well the specified host
170 name will be simplified in regards to
171 the character set used before the
172 latter are updated. This is done by
173 replacing spaces by "-" and removing
174 special characters. This ensures that
175 the pretty and the static hostname
176 are always closely related while still
177 following the validity rules of the
178 specific name. This simplification of
179 the hostname string is not done if
180 only the transient and/or static host
181 names are set, and the pretty host
182 name is left untouched. Pass the empty
183 string "" as hostname to reset the
184 selected hostnames to their default
186 "localhost").</para></listitem>
190 <term><command>set-icon-name [NAME]</command></term>
192 <listitem><para>Set the system icon
193 name. The icon name is used by some
194 graphical applications to visualize
195 this host. The icon name should follow
197 url="http://standards.freedesktop.org/icon-naming-spec/icon-naming-spec-latest.html">Icon
198 Naming Specification</ulink>. Pass an
199 empty string to this operation to
200 reset the icon name to the default
201 value which is determined from chassis
202 type (see below) and possibly other
203 parameters.</para></listitem>
207 <term><command>set-chassis [TYPE]</command></term>
209 <listitem><para>Set the chassis
210 type. The chassis type is used by some
211 graphical applications to visualize
212 the host or alter user
213 interaction. Currently, the following
214 chassis types are defined:
215 <literal>desktop</literal>,
216 <literal>laptop</literal>,
217 <literal>server</literal>,
218 <literal>tablet</literal>,
219 <literal>handset</literal>, as well as
220 the special chassis types
221 <literal>vm</literal> and
222 <literal>container</literal> for
223 virtualized systems that lack an
224 immediate physical chassis. Pass an
225 empty string to this operation to
226 reset the chassis type to the default
227 value which is determined from the
228 firmware and possibly other
229 parameters.</para></listitem>
236 <title>Exit status</title>
238 <para>On success 0 is returned, a non-zero failure
239 code otherwise.</para>
243 <title>See Also</title>
245 <citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
246 <citerefentry><refentrytitle>hostname</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
247 <citerefentry><refentrytitle>hostname</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
248 <citerefentry><refentrytitle>machine-info</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
249 <citerefentry><refentrytitle>systemctl</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
250 <citerefentry><refentrytitle>systemd-hostnamed.service</refentrytitle><manvolnum>8</manvolnum></citerefentry>