systemd/man/hostnamectl.html
2015-02-17 11:22:16 +01:00

125 lines
13 KiB
HTML

<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 219</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="idm139815306047440"></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-info.html"><span class="citerefentry"><span class="refentrytitle">machine-info</span>(5)</span></a>.</p><p>Use
<a href="systemd-firstboot.html"><span class="citerefentry"><span class="refentrytitle">systemd-firstboot</span>(1)</span></a>
to initialize the system host name for mounted (but not booted)
system images.</p></div><div class="refsect1"><a name="idm139815306039440"></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="--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="-M"><span class="term"><code class="option">-M</code>, </span><span class="term"><code class="option">--machine=</code></span><a class="headerlink" title="Permalink to this term" href="#-M"></a></dt><dd><p><a name="machine-text"></a>Execute operation on a local container. Specify a
container name to connect to.</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 <em class="replaceable"><code>NAME</code></em></strong></span></span><a class="headerlink" title="Permalink to this term" href="#set-hostname%20NAME"></a></dt><dd><p>Set the system hostname to
<em class="replaceable"><code>NAME</code></em>. 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.</p><p>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 <em class="replaceable"><code>NAME</code></em></strong></span></span><a class="headerlink" title="Permalink to this term" href="#set-icon-name%20NAME"></a></dt><dd><p>Set the system icon name to
<em class="replaceable"><code>NAME</code></em>. 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>.</p><p>Pass an empty string 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 <em class="replaceable"><code>TYPE</code></em></strong></span></span><a class="headerlink" title="Permalink to this term" href="#set-chassis%20TYPE"></a></dt><dd><p>Set the chassis type to
<em class="replaceable"><code>TYPE</code></em>. 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>",
"<code class="literal">watch</code>",
"<code class="literal">embedded</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.</p><p>Pass an empty string to reset the chassis type to the
default value which is determined from the firmware and
possibly other parameters.</p></dd><dt id="set-deployment ENVIRONMENT"><span class="term"><span class="command"><strong>set-deployment <em class="replaceable"><code>ENVIRONMENT</code></em></strong></span></span><a class="headerlink" title="Permalink to this term" href="#set-deployment%20ENVIRONMENT"></a></dt><dd><p>Set the deployment environment description.
<em class="replaceable"><code>ENVIRONMENT</code></em> must be a single word
without any control characters. One of the following is
suggested:
"<code class="literal">development</code>",
"<code class="literal">integration</code>",
"<code class="literal">staging</code>",
"<code class="literal">production</code>".
</p><p>Pass an empty string to reset to the default empty
value.</p></dd><dt id="set-location LOCATION"><span class="term"><span class="command"><strong>set-location <em class="replaceable"><code>LOCATION</code></em></strong></span></span><a class="headerlink" title="Permalink to this term" href="#set-location%20LOCATION"></a></dt><dd><p>Set the location string for the system, if it
is known. <em class="replaceable"><code>LOCATION</code></em> should be a
human-friendly, free-form string describing the physical
location of the system, if it is known and applicable. This
may be as generic as "<code class="literal">Berlin, Germany</code>" or as
specific as "<code class="literal">Left Rack, 2nd Shelf</code>".</p><p>Pass an empty string to reset to the default empty
value.</p></dd></dl></div></div><div class="refsect1"><a name="idm139815304974256"></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="idm139815304973104"></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>,
<a href="systemd-firstboot.html"><span class="citerefentry"><span class="refentrytitle">systemd-firstboot</span>(1)</span></a>
</p></div></div></body></html>