1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134
|
<html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"><title>hostnamectl</title><meta name="generator" content="DocBook XSL Stylesheets V1.78.1"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><style>
a.headerlink {
color: #c60f0f;
font-size: 0.8em;
padding: 0 4px 0 4px;
text-decoration: none;
visibility: hidden;
}
a.headerlink:hover {
background-color: #c60f0f;
color: white;
}
h1:hover > a.headerlink, h2:hover > a.headerlink, h3:hover > a.headerlink, dt:hover > a.headerlink {
visibility: visible;
}
</style><a href="index.html">Index </a>·
<a href="systemd.directives.html">Directives </a>·
<a href="../python-systemd/index.html">Python </a>·
<a href="../libudev/index.html">libudev </a>·
<a href="../libudev/index.html">gudev </a><span style="float:right">systemd 215</span><hr><div class="refentry"><a name="hostnamectl"></a><div class="titlepage"></div><div class="refnamediv"><h2>Name</h2><p>hostnamectl — Control the system hostname</p></div><div class="refsynopsisdiv"><h2>Synopsis</h2><div class="cmdsynopsis"><p><code class="command">hostnamectl</code> [OPTIONS...] {COMMAND}</p></div></div><div class="refsect1"><a name="idm214197136464"></a><h2 id="Description">Description<a class="headerlink" title="Permalink to this headline" href="#Description">¶</a></h2><p><span class="command"><strong>hostnamectl</strong></span> may be used to
query and change the system hostname and related
settings.</p><p>This tool distinguishes three different
hostnames: the high-level "pretty" hostname which
might include all kinds of special characters
(e.g. "Lennart's Laptop"), the static hostname which
is used to initialize the kernel hostname at boot
(e.g. "lennarts-laptop"), and the transient hostname
which is a default received from network configuration.
If a static hostname is set, and is valid (something other
than localhost), then the transient hostname is not used.</p><p>Note that the pretty hostname has little
restrictions on the characters used, while the static
and transient hostnames are limited to the usually
accepted characters of Internet domain names.</p><p>The static hostname is stored in
<code class="filename">/etc/hostname</code>, see
<a href="hostname.html"><span class="citerefentry"><span class="refentrytitle">hostname</span>(5)</span></a>
for more information. The pretty hostname, chassis
type, and icon name are stored in
<code class="filename">/etc/machine-info</code>, see
<a href="machine-id.html"><span class="citerefentry"><span class="refentrytitle">machine-id</span>(5)</span></a>.</p></div><div class="refsect1"><a name="idm214193390992"></a><h2 id="Options">Options<a class="headerlink" title="Permalink to this headline" href="#Options">¶</a></h2><p>The following options are understood:</p><div class="variablelist"><dl class="variablelist"><dt id="--no-ask-password"><span class="term"><code class="option">--no-ask-password</code></span><a class="headerlink" title="Permalink to this term" href="#--no-ask-password">¶</a></dt><dd><p>Do not query the user
for authentication for privileged
operations.</p></dd><dt id="-P"><span class="term"><code class="option">-P</code>, </span><span class="term"><code class="option">--privileged</code></span><a class="headerlink" title="Permalink to this term" href="#-P">¶</a></dt><dd><p>Acquire privileges via PolicyKit
before executing the operation.</p></dd><dt id="--static"><span class="term"><code class="option">--static</code>, </span><span class="term"><code class="option">--transient</code>, </span><span class="term"><code class="option">--pretty</code></span><a class="headerlink" title="Permalink to this term" href="#--static">¶</a></dt><dd><p>If
<span class="command"><strong>status</strong></span> is used (or
no explicit command is given) and one
of those fields is given,
<span class="command"><strong>hostnamectl</strong></span> will
print out just this selected
hostname.</p><p>If used with
<span class="command"><strong>set-hostname</strong></span>, only
the selected hostname(s) will be
updated. When more than one of those
options is used, all the specified
hostnames will be updated.
</p></dd><dt id="-H"><span class="term"><code class="option">-H</code>, </span><span class="term"><code class="option">--host=</code></span><a class="headerlink" title="Permalink to this term" href="#-H">¶</a></dt><dd><p><a name="host-text"></a>Execute the operation remotely. Specify a hostname, or a
username and hostname separated by "<code class="literal">@</code>", to
connect to. The hostname may optionally be suffixed by a
container name, separated by "<code class="literal">:</code>", which
connects directly to a specific container on the specified
host. This will use SSH to talk to the remote machine manager
instance. Container names may be enumerated with
<span class="command"><strong>machinectl -H
<em class="replaceable"><code>HOST</code></em></strong></span>.</p></dd><dt id="-h"><span class="term"><code class="option">-h</code>, </span><span class="term"><code class="option">--help</code></span><a class="headerlink" title="Permalink to this term" href="#-h">¶</a></dt><dd><p><a name="help-text"></a>Print a short help text and exit.
</p></dd><dt id="--version"><span class="term"><code class="option">--version</code></span><a class="headerlink" title="Permalink to this term" href="#--version">¶</a></dt><dd><p><a name="version-text"></a>Print a short version string and exit.</p></dd></dl></div><p>The following commands are understood:</p><div class="variablelist"><dl class="variablelist"><dt id="status"><span class="term"><span class="command"><strong>status</strong></span></span><a class="headerlink" title="Permalink to this term" href="#status">¶</a></dt><dd><p>Show current system
hostname and related
information.</p></dd><dt id="set-hostname [NAME]"><span class="term"><span class="command"><strong>set-hostname [NAME]</strong></span></span><a class="headerlink" title="Permalink to this term" href="#set-hostname%20%5BNAME%5D">¶</a></dt><dd><p>Set the system
hostname. By default, this will alter
the pretty, the static, and the
transient hostname alike; however, if
one or more of
<code class="option">--static</code>,
<code class="option">--transient</code>,
<code class="option">--pretty</code> are used,
only the selected hostnames are
changed. If the pretty hostname is
being set, and static or transient are
being set as well, the specified
hostname will be simplified in regards
to the character set used before the
latter are updated. This is done by
replacing spaces with
"<code class="literal">-</code>" and removing
special characters. This ensures that
the pretty and the static hostname are
always closely related while still
following the validity rules of the
specific name. This simplification of
the hostname string is not done if
only the transient and/or static host
names are set, and the pretty host
name is left untouched. Pass the empty
string "<code class="literal"></code>" as the
hostname to reset the selected
hostnames to their default (usually
"<code class="literal">localhost</code>").</p></dd><dt id="set-icon-name [NAME]"><span class="term"><span class="command"><strong>set-icon-name [NAME]</strong></span></span><a class="headerlink" title="Permalink to this term" href="#set-icon-name%20%5BNAME%5D">¶</a></dt><dd><p>Set the system icon
name. The icon name is used by some
graphical applications to visualize
this host. The icon name should follow
the <a class="ulink" href="http://standards.freedesktop.org/icon-naming-spec/icon-naming-spec-latest.html" target="_top">Icon
Naming Specification</a>. Pass an
empty string to this operation to
reset the icon name to the default
value, which is determined from chassis
type (see below) and possibly other
parameters.</p></dd><dt id="set-chassis [TYPE]"><span class="term"><span class="command"><strong>set-chassis [TYPE]</strong></span></span><a class="headerlink" title="Permalink to this term" href="#set-chassis%20%5BTYPE%5D">¶</a></dt><dd><p>Set the chassis
type. The chassis type is used by some
graphical applications to visualize
the host or alter user
interaction. Currently, the following
chassis types are defined:
"<code class="literal">desktop</code>",
"<code class="literal">laptop</code>",
"<code class="literal">server</code>",
"<code class="literal">tablet</code>",
"<code class="literal">handset</code>", as well as
the special chassis types
"<code class="literal">vm</code>" and
"<code class="literal">container</code>" for
virtualized systems that lack an
immediate physical chassis. Pass an
empty string to this operation to
reset the chassis type to the default
value which is determined from the
firmware and possibly other
parameters.</p></dd></dl></div></div><div class="refsect1"><a name="idm214197252416"></a><h2 id="Exit status">Exit status<a class="headerlink" title="Permalink to this headline" href="#Exit%20status">¶</a></h2><p>On success, 0 is returned, a non-zero failure
code otherwise.</p></div><div class="refsect1"><a name="idm214197251232"></a><h2 id="See Also">See Also<a class="headerlink" title="Permalink to this headline" href="#See%20Also">¶</a></h2><p>
<a href="systemd.html"><span class="citerefentry"><span class="refentrytitle">systemd</span>(1)</span></a>,
<a href="hostname.html"><span class="citerefentry"><span class="refentrytitle">hostname</span>(1)</span></a>,
<a href="hostname.html"><span class="citerefentry"><span class="refentrytitle">hostname</span>(5)</span></a>,
<a href="machine-info.html"><span class="citerefentry"><span class="refentrytitle">machine-info</span>(5)</span></a>,
<a href="systemctl.html"><span class="citerefentry"><span class="refentrytitle">systemctl</span>(1)</span></a>,
<a href="systemd-hostnamed.service.html"><span class="citerefentry"><span class="refentrytitle">systemd-hostnamed.service</span>(8)</span></a>
</p></div></div></body></html>
|