1 <?xml version='
1.0'
?> <!--*-nxml-*-->
2 <!DOCTYPE refentry PUBLIC
"-//OASIS//DTD DocBook XML V4.5//EN"
3 "http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd">
4 <!-- SPDX-License-Identifier: LGPL-2.1+ -->
6 <refentry id=
"hostnamectl" conditional='ENABLE_HOSTNAMED'
7 xmlns:
xi=
"http://www.w3.org/2001/XInclude">
10 <title>hostnamectl
</title>
11 <productname>systemd
</productname>
15 <refentrytitle>hostnamectl
</refentrytitle>
16 <manvolnum>1</manvolnum>
20 <refname>hostnamectl
</refname>
21 <refpurpose>Control the system hostname
</refpurpose>
26 <command>hostnamectl
</command>
27 <arg choice=
"opt" rep=
"repeat">OPTIONS
</arg>
28 <arg choice=
"req">COMMAND
</arg>
33 <title>Description
</title>
35 <para><command>hostnamectl
</command> may be used to query and
36 change the system hostname and related settings.
</para>
38 <para>This tool distinguishes three different hostnames: the
39 high-level
"pretty" hostname which might include all kinds of
40 special characters (e.g.
"Lennart's Laptop"), the static hostname
41 which is used to initialize the kernel hostname at boot (e.g.
42 "lennarts-laptop"), and the transient hostname which is a fallback
43 value received from network configuration. If a static hostname is
44 set, and is valid (something other than localhost), then the
45 transient hostname is not used.
</para>
47 <para>Note that the pretty hostname has little restrictions on the characters and length used, while the static and
48 transient hostnames are limited to the usually accepted characters of Internet domain names, and
64 characters at
49 maximum (the latter being a Linux limitation).
</para>
51 <para>The static hostname is stored in
52 <filename>/etc/hostname
</filename>, see
53 <citerefentry><refentrytitle>hostname
</refentrytitle><manvolnum>5</manvolnum></citerefentry>
54 for more information. The pretty hostname, chassis type, and icon
55 name are stored in
<filename>/etc/machine-info
</filename>, see
56 <citerefentry><refentrytitle>machine-info
</refentrytitle><manvolnum>5</manvolnum></citerefentry>.
</para>
59 <citerefentry><refentrytitle>systemd-firstboot
</refentrytitle><manvolnum>1</manvolnum></citerefentry>
60 to initialize the system hostname for mounted (but not booted)
65 <title>Commands
</title>
67 <para>The following commands are understood:
</para>
71 <term><command>status
</command></term>
73 <listitem><para>Show current system hostname and related information. If no command is specified,
74 this is the implied default.
</para></listitem>
78 <term><command>set-hostname
<replaceable>NAME
</replaceable></command></term>
80 <listitem><para>Set the system hostname to
<replaceable>NAME
</replaceable>. By default, this will alter the
81 pretty, the static, and the transient hostname alike; however, if one or more of
<option>--static
</option>,
82 <option>--transient
</option>,
<option>--pretty
</option> are used, only the selected hostnames are changed. If
83 the pretty hostname is being set, and static or transient are being set as well, the specified hostname will be
84 simplified in regards to the character set used before the latter are updated. This is done by removing special
85 characters and spaces. This ensures that the pretty and the static hostname are always closely related while
86 still following the validity rules of the specific name. This simplification of the hostname string is not done
87 if only the transient and/or static hostnames are set, and the pretty hostname is left untouched.
</para>
89 <para>Pass the empty string
<literal></literal> as the
90 hostname to reset the selected hostnames to their default
91 (usually
<literal>localhost
</literal>).
</para></listitem>
95 <term><command>set-icon-name
<replaceable>NAME
</replaceable></command></term>
97 <listitem><para>Set the system icon name to
98 <replaceable>NAME
</replaceable>. The icon name is used by some
99 graphical applications to visualize this host. The icon name
100 should follow the
<ulink
101 url=
"http://standards.freedesktop.org/icon-naming-spec/icon-naming-spec-latest.html">Icon
102 Naming Specification
</ulink>.
</para>
104 <para>Pass an empty string to reset the icon name to the
105 default value, which is determined from chassis type (see
106 below) and possibly other parameters.
</para></listitem>
110 <term><command>set-chassis
<replaceable>TYPE
</replaceable></command></term>
112 <listitem><para>Set the chassis type to
113 <replaceable>TYPE
</replaceable>. The chassis type is used by
114 some graphical applications to visualize the host or alter
115 user interaction. Currently, the following chassis types are
117 <literal>desktop
</literal>,
118 <literal>laptop
</literal>,
119 <literal>convertible
</literal>,
120 <literal>server
</literal>,
121 <literal>tablet
</literal>,
122 <literal>handset
</literal>,
123 <literal>watch
</literal>,
124 <literal>embedded
</literal>,
125 as well as the special chassis types
126 <literal>vm
</literal> and
127 <literal>container
</literal> for virtualized systems that lack
128 an immediate physical chassis.
</para>
130 <para>Pass an empty string to reset the chassis type to the
131 default value which is determined from the firmware and
132 possibly other parameters.
</para>
137 <term><command>set-deployment
<replaceable>ENVIRONMENT
</replaceable></command></term>
139 <listitem><para>Set the deployment environment description.
140 <replaceable>ENVIRONMENT
</replaceable> must be a single word
141 without any control characters. One of the following is
143 <literal>development
</literal>,
144 <literal>integration
</literal>,
145 <literal>staging
</literal>,
146 <literal>production
</literal>.
149 <para>Pass an empty string to reset to the default empty
155 <term><command>set-location
<replaceable>LOCATION
</replaceable></command></term>
157 <listitem><para>Set the location string for the system, if it
158 is known.
<replaceable>LOCATION
</replaceable> should be a
159 human-friendly, free-form string describing the physical
160 location of the system, if it is known and applicable. This
161 may be as generic as
<literal>Berlin, Germany
</literal> or as
162 specific as
<literal>Left Rack,
2nd Shelf
</literal>.
</para>
164 <para>Pass an empty string to reset to the default empty
172 <title>Options
</title>
174 <para>The following options are understood:
</para>
178 <term><option>--no-ask-password
</option></term>
180 <listitem><para>Do not query the user for authentication for
181 privileged operations.
</para></listitem>
185 <term><option>--static
</option></term>
186 <term><option>--transient
</option></term>
187 <term><option>--pretty
</option></term>
189 <listitem><para>If
<command>status
</command> is invoked (or no explicit command is given) and one of these
190 switches is specified,
<command>hostnamectl
</command> will print out just this selected hostname.
</para>
192 <para>If used with
<command>set-hostname
</command>, only the selected hostname(s) will be updated. When more
193 than one of these switches are specified, all the specified hostnames will be updated.
</para></listitem>
196 <xi:include href=
"user-system-options.xml" xpointer=
"host" />
197 <xi:include href=
"user-system-options.xml" xpointer=
"machine" />
199 <xi:include href=
"standard-options.xml" xpointer=
"help" />
200 <xi:include href=
"standard-options.xml" xpointer=
"version" />
205 <title>Exit status
</title>
207 <para>On success,
0 is returned, a non-zero failure code
212 <title>See Also
</title>
214 <citerefentry><refentrytitle>systemd
</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
215 <citerefentry><refentrytitle>hostname
</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
216 <citerefentry><refentrytitle>hostname
</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
217 <citerefentry><refentrytitle>machine-info
</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
218 <citerefentry><refentrytitle>systemctl
</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
219 <citerefentry><refentrytitle>systemd-hostnamed.service
</refentrytitle><manvolnum>8</manvolnum></citerefentry>,
220 <citerefentry><refentrytitle>systemd-firstboot
</refentrytitle><manvolnum>1</manvolnum></citerefentry>