]> git.ipfire.org Git - thirdparty/systemd.git/blame - man/machinectl.xml
systemctl: inline iterator declarations
[thirdparty/systemd.git] / man / machinectl.xml
CommitLineData
514094f9 1<?xml version='1.0'?>
3a54a157 2<!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
5fadff33
ZJS
3 "http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd" [
4<!ENTITY % entities SYSTEM "custom-entities.ent" >
5%entities;
6]>
db9ecf05 7<!-- SPDX-License-Identifier: LGPL-2.1-or-later -->
19887cd0 8
21ac6ff1 9<refentry id="machinectl" conditional='ENABLE_MACHINED'
798d3a52
ZJS
10 xmlns:xi="http://www.w3.org/2001/XInclude">
11
12 <refentryinfo>
13 <title>machinectl</title>
14 <productname>systemd</productname>
798d3a52
ZJS
15 </refentryinfo>
16
17 <refmeta>
18 <refentrytitle>machinectl</refentrytitle>
19 <manvolnum>1</manvolnum>
20 </refmeta>
21
22 <refnamediv>
23 <refname>machinectl</refname>
24 <refpurpose>Control the systemd machine manager</refpurpose>
25 </refnamediv>
26
27 <refsynopsisdiv>
28 <cmdsynopsis>
29 <command>machinectl</command>
30 <arg choice="opt" rep="repeat">OPTIONS</arg>
31 <arg choice="req">COMMAND</arg>
32 <arg choice="opt" rep="repeat">NAME</arg>
33 </cmdsynopsis>
34 </refsynopsisdiv>
35
36 <refsect1>
37 <title>Description</title>
38
39 <para><command>machinectl</command> may be used to introspect and
40 control the state of the
41 <citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry>
42 virtual machine and container registration manager
43 <citerefentry><refentrytitle>systemd-machined.service</refentrytitle><manvolnum>8</manvolnum></citerefentry>.</para>
91913f58
LP
44
45 <para><command>machinectl</command> may be used to execute
46 operations on machines and images. Machines in this sense are
47 considered running instances of:</para>
48
49 <itemizedlist>
50 <listitem><para>Virtual Machines (VMs) that virtualize hardware
51 to run full operating system (OS) instances (including their kernels)
52 in a virtualized environment on top of the host OS.</para></listitem>
53
54 <listitem><para>Containers that share the hardware and
55 OS kernel with the host OS, in order to run
56 OS userspace instances on top the host OS.</para></listitem>
57
fa69a4c7 58 <listitem><para>The host system itself.</para></listitem>
91913f58
LP
59 </itemizedlist>
60
61 <para>Machines are identified by names that follow the same rules
38b38500 62 as UNIX and DNS hostnames. For details, see below.</para>
fa69a4c7
ZJS
63
64 <para>Machines are instantiated from disk or file system images that
65 frequently — but not necessarily — carry the same name as machines running
66 from them. Images in this sense may be:</para>
91913f58
LP
67
68 <itemizedlist>
fa69a4c7 69 <listitem><para>Directory trees containing an OS, including the
3b121157
ZJS
70 top-level directories <filename>/usr/</filename>,
71 <filename>/etc/</filename>, and so on.</para></listitem>
91913f58 72
576cf244 73 <listitem><para>btrfs subvolumes containing OS trees, similar to regular directory trees.</para></listitem>
91913f58 74
576cf244
LP
75 <listitem><para>Binary "raw" disk image files containing MBR or GPT partition tables and Linux file
76 systems.</para></listitem>
77
78 <listitem><para>Similarly, block devices containing MBR or GPT partition tables and file systems.</para></listitem>
91913f58
LP
79
80 <listitem><para>The file system tree of the host OS itself.</para></listitem>
81 </itemizedlist>
82
798d3a52
ZJS
83 </refsect1>
84
798d3a52
ZJS
85 <refsect1>
86 <title>Commands</title>
87
88 <para>The following commands are understood:</para>
89
90 <refsect2><title>Machine Commands</title><variablelist>
91
92 <varlistentry>
93 <term><command>list</command></term>
94
95 <listitem><para>List currently running (online) virtual
91913f58
LP
96 machines and containers. To enumerate machine images that can
97 be started, use <command>list-images</command> (see
98 below). Note that this command hides the special
99 <literal>.host</literal> machine by default. Use the
100 <option>--all</option> switch to show it.</para></listitem>
798d3a52
ZJS
101 </varlistentry>
102
103 <varlistentry>
1eecafb8 104 <term><command>status</command> <replaceable>NAME</replaceable>…</term>
798d3a52 105
28f90ea2 106 <listitem><para>Show runtime status information about
798d3a52
ZJS
107 one or more virtual machines and containers, followed by the
108 most recent log data from the journal. This function is
109 intended to generate human-readable output. If you are looking
110 for computer-parsable output, use <command>show</command>
111 instead. Note that the log data shown is reported by the
112 virtual machine or container manager, and frequently contains
113 console output of the machine, but not necessarily journal
114 contents of the machine itself.</para></listitem>
115 </varlistentry>
116
117 <varlistentry>
1eecafb8 118 <term><command>show</command> [<replaceable>NAME</replaceable>…]</term>
798d3a52 119
e9c880dd
LP
120 <listitem><para>Show properties of one or more registered virtual machines or containers or the manager
121 itself. If no argument is specified, properties of the manager will be shown. If a NAME is specified,
122 properties of this virtual machine or container are shown. By default, empty properties are suppressed. Use
123 <option>--all</option> to show those too. To select specific properties to show, use
124 <option>--property=</option>. This command is intended to be used whenever computer-parsable output is
125 required, and does not print the control group tree or journal entries. Use <command>status</command> if you
126 are looking for formatted human-readable output.</para></listitem>
798d3a52
ZJS
127 </varlistentry>
128
129 <varlistentry>
1eecafb8 130 <term><command>start</command> <replaceable>NAME</replaceable>…</term>
798d3a52
ZJS
131
132 <listitem><para>Start a container as a system service, using
133 <citerefentry><refentrytitle>systemd-nspawn</refentrytitle><manvolnum>1</manvolnum></citerefentry>.
134 This starts <filename>systemd-nspawn@.service</filename>,
135 instantiated for the specified machine name, similar to the
136 effect of <command>systemctl start</command> on the service
137 name. <command>systemd-nspawn</command> looks for a container
138 image by the specified name in
139 <filename>/var/lib/machines/</filename> (and other search
140 paths, see below) and runs it. Use
b938cb90 141 <command>list-images</command> (see below) for listing
798d3a52
ZJS
142 available container images to start.</para>
143
144 <para>Note that
145 <citerefentry><refentrytitle>systemd-machined.service</refentrytitle><manvolnum>8</manvolnum></citerefentry>
146 also interfaces with a variety of other container and VM
147 managers, <command>systemd-nspawn</command> is just one
148 implementation of it. Most of the commands available in
149 <command>machinectl</command> may be used on containers or VMs
150 controlled by other managers, not just
151 <command>systemd-nspawn</command>. Starting VMs and container
152 images on those managers requires manager-specific
153 tools.</para>
154
155 <para>To interactively start a container on the command line
156 with full access to the container's console, please invoke
157 <command>systemd-nspawn</command> directly. To stop a running
b2bb19bb 158 container use <command>machinectl poweroff</command>.</para></listitem>
798d3a52
ZJS
159 </varlistentry>
160
161 <varlistentry>
91913f58 162 <term><command>login</command> [<replaceable>NAME</replaceable>]</term>
798d3a52 163
c454426c 164 <listitem><para>Open an interactive terminal login session in
b938cb90 165 a container or on the local host. If an argument is supplied,
91913f58
LP
166 it refers to the container machine to connect to. If none is
167 specified, or the container name is specified as the empty
168 string, or the special machine name <literal>.host</literal>
169 (see below) is specified, the connection is made to the local
170 host instead. This will create a TTY connection to a specific
171 container or the local host and asks for the execution of a
172 getty on it. Note that this is only supported for containers
173 running
798d3a52
ZJS
174 <citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry>
175 as init system.</para>
176
177 <para>This command will open a full login prompt on the
91913f58
LP
178 container or the local host, which then asks for username and
179 password. Use <command>shell</command> (see below) or
798d3a52 180 <citerefentry><refentrytitle>systemd-run</refentrytitle><manvolnum>1</manvolnum></citerefentry>
91913f58
LP
181 with the <option>--machine=</option> switch to directly invoke
182 a single command, either interactively or in the
183 background.</para></listitem>
798d3a52
ZJS
184 </varlistentry>
185
c454426c 186 <varlistentry>
1eecafb8 187 <term><command>shell</command> [[<replaceable>NAME</replaceable>@]<replaceable>NAME</replaceable> [<replaceable>PATH</replaceable> [<replaceable>ARGUMENTS</replaceable>…]]] </term>
c454426c
LP
188
189 <listitem><para>Open an interactive shell session in a
91913f58
LP
190 container or on the local host. The first argument refers to
191 the container machine to connect to. If none is specified, or
192 the machine name is specified as the empty string, or the
193 special machine name <literal>.host</literal> (see below) is
194 specified, the connection is made to the local host
195 instead. This works similar to <command>login</command> but
196 immediately invokes a user process. This command runs the
c46bc7e2
SL
197 specified executable with the specified arguments, or the
198 default shell for the user if none is specified, or
199 <filename>/bin/sh</filename> if no default shell is found. By default,
ef3100e9
LP
200 <option>--uid=</option>, or by prefixing the machine name with
201 a username and an <literal>@</literal> character, a different
202 user may be selected. Use <option>--setenv=</option> to set
203 environment variables for the executed process.</para>
204
7f129a1f
LP
205 <para>Note that <command>machinectl shell</command> does not propagate the exit code/status of the invoked
206 shell process. Use <command>systemd-run</command> instead if that information is required (see below).</para>
207
ef3100e9 208 <para>When using the <command>shell</command> command without
b938cb90 209 arguments, (thus invoking the executed shell or command on the
a8eaaee7 210 local host), it is in many ways similar to a <citerefentry
ef3100e9 211 project='die-net'><refentrytitle>su</refentrytitle><manvolnum>1</manvolnum></citerefentry>
b938cb90 212 session, but, unlike <command>su</command>, completely isolates
ef3100e9
LP
213 the new session from the originating session, so that it
214 shares no process or session properties, and is in a clean and
215 well-defined state. It will be tracked in a new utmp, login,
762a5766
LP
216 audit, security and keyring session, and will not inherit any
217 environment variables or resource limits, among other
218 properties.</para>
ef3100e9 219
7f129a1f
LP
220 <para>Note that <citerefentry><refentrytitle>systemd-run</refentrytitle><manvolnum>1</manvolnum></citerefentry>
221 with its <option>--machine=</option> switch may be used in place of the <command>machinectl shell</command>
222 command, and allows non-interactive operation, more detailed and low-level configuration of the invoked unit,
223 as well as access to runtime and exit code/status information of the invoked shell process. In particular, use
224 <command>systemd-run</command>'s <option>--wait</option> switch to propagate exit status information of the
225 invoked process. Use <command>systemd-run</command>'s <option>--pty</option> switch for acquiring an
226 interactive shell, similar to <command>machinectl shell</command>. In general, <command>systemd-run</command>
227 is preferable for scripting purposes. However, note that <command>systemd-run</command> might require higher
228 privileges than <command>machinectl shell</command>.</para></listitem>
c454426c
LP
229 </varlistentry>
230
798d3a52 231 <varlistentry>
1eecafb8
ZJS
232 <term><command>enable</command> <replaceable>NAME</replaceable>…</term>
233 <term><command>disable</command> <replaceable>NAME</replaceable>…</term>
798d3a52
ZJS
234
235 <listitem><para>Enable or disable a container as a system
236 service to start at system boot, using
237 <citerefentry><refentrytitle>systemd-nspawn</refentrytitle><manvolnum>1</manvolnum></citerefentry>.
238 This enables or disables
239 <filename>systemd-nspawn@.service</filename>, instantiated for
240 the specified machine name, similar to the effect of
241 <command>systemctl enable</command> or <command>systemctl
242 disable</command> on the service name.</para></listitem>
243 </varlistentry>
244
245 <varlistentry>
1eecafb8 246 <term><command>poweroff</command> <replaceable>NAME</replaceable>…</term>
798d3a52
ZJS
247
248 <listitem><para>Power off one or more containers. This will
249 trigger a reboot by sending SIGRTMIN+4 to the container's init
250 process, which causes systemd-compatible init systems to shut
b2bb19bb
CR
251 down cleanly. Use <command>stop</command> as alias for <command>poweroff</command>.
252 This operation does not work on containers that do not run a
798d3a52
ZJS
253 <citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry>-compatible
254 init system, such as sysvinit. Use
255 <command>terminate</command> (see below) to immediately
256 terminate a container or VM, without cleanly shutting it
257 down.</para></listitem>
258 </varlistentry>
259
260 <varlistentry>
1eecafb8 261 <term><command>reboot</command> <replaceable>NAME</replaceable>…</term>
798d3a52
ZJS
262
263 <listitem><para>Reboot one or more containers. This will
264 trigger a reboot by sending SIGINT to the container's init
265 process, which is roughly equivalent to pressing Ctrl+Alt+Del
266 on a non-containerized system, and is compatible with
267 containers running any system manager.</para></listitem>
268 </varlistentry>
269
270 <varlistentry>
1eecafb8 271 <term><command>terminate</command> <replaceable>NAME</replaceable>…</term>
798d3a52
ZJS
272
273 <listitem><para>Immediately terminates a virtual machine or
274 container, without cleanly shutting it down. This kills all
275 processes of the virtual machine or container and deallocates
276 all resources attached to that instance. Use
277 <command>poweroff</command> to issue a clean shutdown
278 request.</para></listitem>
279 </varlistentry>
280
281 <varlistentry>
1eecafb8 282 <term><command>kill</command> <replaceable>NAME</replaceable>…</term>
798d3a52
ZJS
283
284 <listitem><para>Send a signal to one or more processes of the
285 virtual machine or container. This means processes as seen by
286 the host, not the processes inside the virtual machine or
287 container. Use <option>--kill-who=</option> to select which
288 process to kill. Use <option>--signal=</option> to select the
289 signal to send.</para></listitem>
290 </varlistentry>
291
292 <varlistentry>
293 <term><command>bind</command> <replaceable>NAME</replaceable> <replaceable>PATH</replaceable> [<replaceable>PATH</replaceable>]</term>
294
d3590ace
LP
295 <listitem><para>Bind mounts a file or directory from the host into the specified container. The first path
296 argument is the source file or directory on the host, the second path argument is the destination file or
297 directory in the container. When the latter is omitted, the destination path in the container is the same as
298 the source path on the host. When combined with the <option>--read-only</option> switch, a ready-only bind
299 mount is created. When combined with the <option>--mkdir</option> switch, the destination path is first created
300 before the mount is applied. Note that this option is currently only supported for
7f43928b 301 <citerefentry><refentrytitle>systemd-nspawn</refentrytitle><manvolnum>1</manvolnum></citerefentry> containers,
d3590ace
LP
302 and only if user namespacing (<option>--private-users</option>) is not used. This command supports bind
303 mounting directories, regular files, device nodes, <constant>AF_UNIX</constant> socket nodes, as well as
304 FIFOs.</para></listitem>
798d3a52
ZJS
305 </varlistentry>
306
307 <varlistentry>
308 <term><command>copy-to</command> <replaceable>NAME</replaceable> <replaceable>PATH</replaceable> [<replaceable>PATH</replaceable>]</term>
309
310 <listitem><para>Copies files or directories from the host
311 system into a running container. Takes a container name,
312 followed by the source path on the host and the destination
b938cb90 313 path in the container. If the destination path is omitted, the
d01cd401 314 same as the source path is used.</para>
798d3a52 315
d01cd401
LP
316 <para>If host and container share the same user and group namespace, file ownership by numeric user ID and
317 group ID is preserved for the copy, otherwise all files and directories in the copy will be owned by the root
318 user and group (UID/GID 0).</para></listitem>
319 </varlistentry>
798d3a52
ZJS
320
321 <varlistentry>
322 <term><command>copy-from</command> <replaceable>NAME</replaceable> <replaceable>PATH</replaceable> [<replaceable>PATH</replaceable>]</term>
323
324 <listitem><para>Copies files or directories from a container
325 into the host system. Takes a container name, followed by the
e9dd6984 326 source path in the container and the destination path on the host.
b938cb90 327 If the destination path is omitted, the same as the source path
d01cd401
LP
328 is used.</para>
329
330 <para>If host and container share the same user and group namespace, file ownership by numeric user ID and
331 group ID is preserved for the copy, otherwise all files and directories in the copy will be owned by the root
332 user and group (UID/GID 0).</para></listitem>
798d3a52
ZJS
333 </varlistentry>
334 </variablelist></refsect2>
335
336 <refsect2><title>Image Commands</title><variablelist>
337
338 <varlistentry>
339 <term><command>list-images</command></term>
340
341 <listitem><para>Show a list of locally installed container and
342 VM images. This enumerates all raw disk images and container
343 directories and subvolumes in
344 <filename>/var/lib/machines/</filename> (and other search
345 paths, see below). Use <command>start</command> (see above) to
b938cb90
JE
346 run a container off one of the listed images. Note that, by
347 default, containers whose name begins with a dot
798d3a52
ZJS
348 (<literal>.</literal>) are not shown. To show these too,
349 specify <option>--all</option>. Note that a special image
350 <literal>.host</literal> always implicitly exists and refers
351 to the image the host itself is booted from.</para></listitem>
352 </varlistentry>
353
354 <varlistentry>
1eecafb8 355 <term><command>image-status</command> [<replaceable>NAME</replaceable>…]</term>
798d3a52
ZJS
356
357 <listitem><para>Show terse status information about one or
358 more container or VM images. This function is intended to
359 generate human-readable output. Use
360 <command>show-image</command> (see below) to generate
361 computer-parsable output instead.</para></listitem>
362 </varlistentry>
363
364 <varlistentry>
1eecafb8 365 <term><command>show-image</command> [<replaceable>NAME</replaceable>…]</term>
798d3a52
ZJS
366
367 <listitem><para>Show properties of one or more registered
368 virtual machine or container images, or the manager itself. If
369 no argument is specified, properties of the manager will be
037a3ded 370 shown. If a NAME is specified, properties of this virtual
798d3a52
ZJS
371 machine or container image are shown. By default, empty
372 properties are suppressed. Use <option>--all</option> to show
373 those too. To select specific properties to show, use
374 <option>--property=</option>. This command is intended to be
375 used whenever computer-parsable output is required. Use
376 <command>image-status</command> if you are looking for
377 formatted human-readable output.</para></listitem>
378 </varlistentry>
379
380 <varlistentry>
381 <term><command>clone</command> <replaceable>NAME</replaceable> <replaceable>NAME</replaceable></term>
382
d13febb1
LP
383 <listitem><para>Clones a container or VM image. The arguments specify the name of the image to clone and the
384 name of the newly cloned image. Note that plain directory container images are cloned into btrfs subvolume
385 images with this command, if the underlying file system supports this. Note that cloning a container or VM
17cbb288
LP
386 image is optimized for file systems that support copy-on-write, and might not be efficient on others, due to
387 file system limitations.</para>
3fe22bb4 388
38b38500 389 <para>Note that this command leaves hostname, machine ID and
3fe22bb4
LP
390 all other settings that could identify the instance
391 unmodified. The original image and the cloned copy will hence
392 share these credentials, and it might be necessary to manually
d94c2b06
LP
393 change them in the copy.</para>
394
395 <para>If combined with the <option>--read-only</option> switch a read-only cloned image is
396 created.</para></listitem>
798d3a52
ZJS
397 </varlistentry>
398
399 <varlistentry>
400 <term><command>rename</command> <replaceable>NAME</replaceable> <replaceable>NAME</replaceable></term>
401
d6ce17c7 402 <listitem><para>Renames a container or VM image. The
798d3a52
ZJS
403 arguments specify the name of the image to rename and the new
404 name of the image.</para></listitem>
405 </varlistentry>
406
407 <varlistentry>
408 <term><command>read-only</command> <replaceable>NAME</replaceable> [<replaceable>BOOL</replaceable>]</term>
409
d6ce17c7 410 <listitem><para>Marks or (unmarks) a container or VM image
798d3a52
ZJS
411 read-only. Takes a VM or container image name, followed by a
412 boolean as arguments. If the boolean is omitted, positive is
413 implied, i.e. the image is marked read-only.</para></listitem>
414 </varlistentry>
415
798d3a52 416 <varlistentry>
1eecafb8 417 <term><command>remove</command> <replaceable>NAME</replaceable>…</term>
798d3a52 418
d6ce17c7 419 <listitem><para>Removes one or more container or VM images.
798d3a52 420 The special image <literal>.host</literal>, which refers to
b938cb90 421 the host's own directory tree, may not be
798d3a52
ZJS
422 removed.</para></listitem>
423 </varlistentry>
424
d6ce17c7
LP
425 <varlistentry>
426 <term><command>set-limit</command> [<replaceable>NAME</replaceable>] <replaceable>BYTES</replaceable></term>
427
a8eaaee7 428 <listitem><para>Sets the maximum size in bytes that a specific
b938cb90 429 container or VM image, or all images, may grow up to on disk
7de30452 430 (disk quota). Takes either one or two parameters. The first,
d6ce17c7 431 optional parameter refers to a container or VM image name. If
b938cb90
JE
432 specified, the size limit of the specified image is changed. If
433 omitted, the overall size limit of the sum of all images stored
7de30452
LP
434 locally is changed. The final argument specifies the size
435 limit in bytes, possibly suffixed by the usual K, M, G, T
436 units. If the size limit shall be disabled, specify
437 <literal>-</literal> as size.</para>
438
5f7ecd61 439 <para>Note that per-container size limits are only supported on btrfs file systems.</para></listitem>
d6ce17c7
LP
440 </varlistentry>
441
d94c2b06
LP
442 <varlistentry>
443 <term><command>clean</command></term>
444
445 <listitem><para>Remove hidden VM or container images (or all). This command removes all hidden machine images
3b121157 446 from <filename>/var/lib/machines/</filename>, i.e. those whose name begins with a dot. Use <command>machinectl
d94c2b06
LP
447 list-images --all</command> to see a list of all machine images, including the hidden ones.</para>
448
449 <para>When combined with the <option>--all</option> switch removes all images, not just hidden ones. This
3b121157 450 command effectively empties <filename>/var/lib/machines/</filename>.</para>
d94c2b06
LP
451
452 <para>Note that commands such as <command>machinectl pull-tar</command> or <command>machinectl
453 pull-raw</command> usually create hidden, read-only, unmodified machine images from the downloaded image first,
454 before cloning a writable working copy of it, in order to avoid duplicate downloads in case of images that are
455 reused multiple times. Use <command>machinectl clean</command> to remove old, hidden images created this
456 way.</para></listitem>
457 </varlistentry>
458
798d3a52
ZJS
459 </variablelist></refsect2>
460
461 <refsect2><title>Image Transfer Commands</title><variablelist>
462
463 <varlistentry>
464 <term><command>pull-tar</command> <replaceable>URL</replaceable> [<replaceable>NAME</replaceable>]</term>
465
466 <listitem><para>Downloads a <filename>.tar</filename>
467 container image from the specified URL, and makes it available
468 under the specified local machine name. The URL must be of
469 type <literal>http://</literal> or
470 <literal>https://</literal>, and must refer to a
471 <filename>.tar</filename>, <filename>.tar.gz</filename>,
472 <filename>.tar.xz</filename> or <filename>.tar.bz2</filename>
b938cb90 473 archive file. If the local machine name is omitted, it
798d3a52
ZJS
474 is automatically derived from the last component of the URL,
475 with its suffix removed.</para>
476
697be0be
TB
477 <para>The image is verified before it is made available, unless
478 <option>--verify=no</option> is specified.
479 Verification is done either via an inline signed file with the name
480 of the image and the suffix <filename>.sha256</filename> or via
481 separate <filename>SHA256SUMS</filename> and
482 <filename>SHA256SUMS.gpg</filename> files.
483 The signature files need to be made available on the same web
484 server, under the same URL as the <filename>.tar</filename> file.
485 With <option>--verify=checksum</option>, only the SHA256 checksum
486 for the file is verified, based on the <filename>.sha256</filename>
abdc57df 487 suffixed file or the <filename>SHA256SUMS</filename> file.
697be0be
TB
488 With <option>--verify=signature</option>, the sha checksum file is
489 first verified with the inline signature in the
490 <filename>.sha256</filename> file or the detached GPG signature file
491 <filename>SHA256SUMS.gpg</filename>.
492 The public key for this verification step needs to be available in
12b42c76
TG
493 <filename>/usr/lib/systemd/import-pubring.gpg</filename> or
494 <filename>/etc/systemd/import-pubring.gpg</filename>.</para>
798d3a52
ZJS
495
496 <para>The container image will be downloaded and stored in a
497 read-only subvolume in
b938cb90 498 <filename>/var/lib/machines/</filename> that is named after
798d3a52
ZJS
499 the specified URL and its HTTP etag. A writable snapshot is
500 then taken from this subvolume, and named after the specified
dd2b607b 501 local name. This behavior ensures that creating multiple
798d3a52
ZJS
502 container instances of the same URL is efficient, as multiple
503 downloads are not necessary. In order to create only the
504 read-only image, and avoid creating its writable snapshot,
505 specify <literal>-</literal> as local machine name.</para>
506
507 <para>Note that the read-only subvolume is prefixed with
6b94875f 508 <filename>.tar-</filename>, and is thus not shown by
798d3a52
ZJS
509 <command>list-images</command>, unless <option>--all</option>
510 is passed.</para>
511
512 <para>Note that pressing C-c during execution of this command
513 will not abort the download. Use
514 <command>cancel-transfer</command>, described
515 below.</para></listitem>
516 </varlistentry>
517
518 <varlistentry>
519 <term><command>pull-raw</command> <replaceable>URL</replaceable> [<replaceable>NAME</replaceable>]</term>
520
521 <listitem><para>Downloads a <filename>.raw</filename>
522 container or VM disk image from the specified URL, and makes
523 it available under the specified local machine name. The URL
524 must be of type <literal>http://</literal> or
525 <literal>https://</literal>. The container image must either
526 be a <filename>.qcow2</filename> or raw disk image, optionally
527 compressed as <filename>.gz</filename>,
528 <filename>.xz</filename>, or <filename>.bz2</filename>. If the
b938cb90 529 local machine name is omitted, it is automatically
798d3a52
ZJS
530 derived from the last component of the URL, with its suffix
531 removed.</para>
532
533 <para>Image verification is identical for raw and tar images
534 (see above).</para>
535
1d3eaa93 536 <para>If the downloaded image is in
6b94875f 537 <filename>.qcow2</filename> format it is converted into a raw
798d3a52
ZJS
538 image file before it is made available.</para>
539
540 <para>Downloaded images of this type will be placed as
541 read-only <filename>.raw</filename> file in
542 <filename>/var/lib/machines/</filename>. A local, writable
543 (reflinked) copy is then made under the specified local
544 machine name. To omit creation of the local, writable copy
545 pass <literal>-</literal> as local machine name.</para>
546
dd2b607b 547 <para>Similar to the behavior of <command>pull-tar</command>,
798d3a52 548 the read-only image is prefixed with
6b94875f 549 <filename>.raw-</filename>, and thus not shown by
798d3a52
ZJS
550 <command>list-images</command>, unless <option>--all</option>
551 is passed.</para>
552
553 <para>Note that pressing C-c during execution of this command
554 will not abort the download. Use
555 <command>cancel-transfer</command>, described
556 below.</para></listitem>
557 </varlistentry>
558
af40e5d3
LP
559 <varlistentry>
560 <term><command>import-tar</command> <replaceable>FILE</replaceable> [<replaceable>NAME</replaceable>]</term>
561 <term><command>import-raw</command> <replaceable>FILE</replaceable> [<replaceable>NAME</replaceable>]</term>
562 <listitem><para>Imports a TAR or RAW container or VM image,
563 and places it under the specified name in
564 <filename>/var/lib/machines/</filename>. When
b938cb90 565 <command>import-tar</command> is used, the file specified as
a8eaaee7 566 the first argument should be a tar archive, possibly compressed
af40e5d3 567 with xz, gzip or bzip2. It will then be unpacked into its own
3b121157 568 subvolume in <filename>/var/lib/machines/</filename>. When
b938cb90 569 <command>import-raw</command> is used, the file should be a
af40e5d3
LP
570 qcow2 or raw disk image, possibly compressed with xz, gzip or
571 bzip2. If the second argument (the resulting image name) is
b938cb90 572 not specified, it is automatically derived from the file
1245e413 573 name. If the filename is passed as <literal>-</literal>, the
af40e5d3
LP
574 image is read from standard input, in which case the second
575 argument is mandatory.</para>
576
5f7ecd61
LP
577 <para>Optionally, the <option>--read-only</option> switch may be used to create a read-only container or VM
578 image. No cryptographic validation is done when importing the images.</para>
af40e5d3
LP
579
580 <para>Much like image downloads, ongoing imports may be listed
581 with <command>list-transfers</command> and aborted with
582 <command>cancel-transfer</command>.</para></listitem>
583 </varlistentry>
584
1d7579c4
LP
585 <varlistentry>
586 <term><command>import-fs</command> <replaceable>DIRECTORY</replaceable> [<replaceable>NAME</replaceable>]</term>
587
588 <listitem><para>Imports a container image stored in a local directory into
589 <filename>/var/lib/machines/</filename>, operates similar to <command>import-tar</command> or
590 <command>import-raw</command>, but the first argument is the source directory. If supported, this command will
591 create btrfs snapshot or subvolume for the new image.</para></listitem>
592 </varlistentry>
593
6e9efa59
LP
594 <varlistentry>
595 <term><command>export-tar</command> <replaceable>NAME</replaceable> [<replaceable>FILE</replaceable>]</term>
596 <term><command>export-raw</command> <replaceable>NAME</replaceable> [<replaceable>FILE</replaceable>]</term>
597 <listitem><para>Exports a TAR or RAW container or VM image and
598 stores it in the specified file. The first parameter should be
599 a VM or container image name. The second parameter should be a
600 file path the TAR or RAW image is written to. If the path ends
b938cb90
JE
601 in <literal>.gz</literal>, the file is compressed with gzip, if
602 it ends in <literal>.xz</literal>, with xz, and if it ends in
603 <literal>.bz2</literal>, with bzip2. If the path ends in
604 neither, the file is left uncompressed. If the second argument
605 is missing, the image is written to standard output. The
6e9efa59
LP
606 compression may also be explicitly selected with the
607 <option>--format=</option> switch. This is in particular
608 useful if the second parameter is left unspecified.</para>
609
610 <para>Much like image downloads and imports, ongoing exports
611 may be listed with <command>list-transfers</command> and
612 aborted with
613 <command>cancel-transfer</command>.</para>
614
b938cb90 615 <para>Note that, currently, only directory and subvolume images
6e9efa59
LP
616 may be exported as TAR images, and only raw disk images as RAW
617 images.</para></listitem>
618 </varlistentry>
619
798d3a52
ZJS
620 <varlistentry>
621 <term><command>list-transfers</command></term>
622
623 <listitem><para>Shows a list of container or VM image
6e9efa59 624 downloads, imports and exports that are currently in
af40e5d3 625 progress.</para></listitem>
798d3a52
ZJS
626 </varlistentry>
627
628 <varlistentry>
ee156e8d 629 <term><command>cancel-transfer</command> <replaceable>ID</replaceable>…</term>
798d3a52 630
6e9efa59
LP
631 <listitem><para>Aborts a download, import or export of the
632 container or VM image with the specified ID. To list ongoing
633 transfers and their IDs, use
af40e5d3 634 <command>list-transfers</command>. </para></listitem>
798d3a52
ZJS
635 </varlistentry>
636
637 </variablelist></refsect2>
638
639 </refsect1>
640
e1fac8a6
ZJS
641 <refsect1>
642 <title>Options</title>
643
644 <para>The following options are understood:</para>
645
646 <variablelist>
647 <varlistentry>
648 <term><option>-p</option></term>
649 <term><option>--property=</option></term>
650
651 <listitem><para>When showing machine or image properties,
652 limit the output to certain properties as specified by the
653 argument. If not specified, all set properties are shown. The
654 argument should be a property name, such as
655 <literal>Name</literal>. If specified more than once, all
656 properties with the specified names are
657 shown.</para></listitem>
658 </varlistentry>
659
660 <varlistentry>
661 <term><option>-a</option></term>
662 <term><option>--all</option></term>
663
664 <listitem><para>When showing machine or image properties, show
665 all properties regardless of whether they are set or
666 not.</para>
667
668 <para>When listing VM or container images, do not suppress
669 images beginning in a dot character
670 (<literal>.</literal>).</para>
671
672 <para>When cleaning VM or container images, remove all images, not just hidden ones.</para></listitem>
673 </varlistentry>
674
675 <varlistentry>
676 <term><option>--value</option></term>
677
678 <listitem><para>When printing properties with <command>show</command>, only print the value,
679 and skip the property name and <literal>=</literal>.</para></listitem>
680 </varlistentry>
681
682 <varlistentry>
683 <term><option>-l</option></term>
684 <term><option>--full</option></term>
685
12845a91
YW
686 <listitem><para>Do not ellipsize process tree entries or table. This implies
687 <option>--max-addresses=full</option>.</para>
e1fac8a6
ZJS
688 </listitem>
689 </varlistentry>
690
691 <varlistentry>
692 <term><option>--kill-who=</option></term>
693
694 <listitem><para>When used with <command>kill</command>, choose
695 which processes to kill. Must be one of
696 <option>leader</option>, or <option>all</option> to select
697 whether to kill only the leader process of the machine or all
698 processes of the machine. If omitted, defaults to
699 <option>all</option>.</para></listitem>
700 </varlistentry>
701
702 <varlistentry>
703 <term><option>-s</option></term>
704 <term><option>--signal=</option></term>
705
706 <listitem><para>When used with <command>kill</command>, choose
707 which signal to send to selected processes. Must be one of the
708 well-known signal specifiers, such as
709 <constant>SIGTERM</constant>, <constant>SIGINT</constant> or
710 <constant>SIGSTOP</constant>. If omitted, defaults to
711 <constant>SIGTERM</constant>.</para></listitem>
712 </varlistentry>
713
714 <varlistentry>
715 <term><option>--uid=</option></term>
716
717 <listitem><para>When used with the <command>shell</command> command, chooses the user ID to
718 open the interactive shell session as. If the argument to the <command>shell</command>
719 command also specifies a user name, this option is ignored. If the name is not specified
720 in either way, <literal>root</literal> will be used by default. Note that this switch is
721 not supported for the <command>login</command> command (see below).</para></listitem>
722 </varlistentry>
723
724 <varlistentry>
725 <term><option>-E <replaceable>NAME</replaceable>=<replaceable>VALUE</replaceable></option></term>
726 <term><option>--setenv=<replaceable>NAME</replaceable>=<replaceable>VALUE</replaceable></option></term>
727
728 <listitem><para>When used with the <command>shell</command> command, sets an environment
729 variable to pass to the executed shell. Takes an environment variable name and value,
730 separated by <literal>=</literal>. This switch may be used multiple times to set multiple
731 environment variables. Note that this switch is not supported for the
732 <command>login</command> command (see below).</para></listitem>
733 </varlistentry>
734
735 <varlistentry>
736 <term><option>--mkdir</option></term>
737
738 <listitem><para>When used with <command>bind</command>, creates the destination file or directory before
739 applying the bind mount. Note that even though the name of this option suggests that it is suitable only for
740 directories, this option also creates the destination file node to mount over if the object to mount is not
741 a directory, but a regular file, device node, socket or FIFO.</para></listitem>
742 </varlistentry>
743
744 <varlistentry>
745 <term><option>--read-only</option></term>
746
747 <listitem><para>When used with <command>bind</command>, creates a read-only bind mount.</para>
748
749 <para>When used with <command>clone</command>, <command>import-raw</command> or <command>import-tar</command> a
750 read-only container or VM image is created.</para></listitem>
751 </varlistentry>
752
753 <varlistentry>
754 <term><option>-n</option></term>
755 <term><option>--lines=</option></term>
756
757 <listitem><para>When used with <command>status</command>,
758 controls the number of journal lines to show, counting from
759 the most recent ones. Takes a positive integer argument.
760 Defaults to 10.</para>
761 </listitem>
762 </varlistentry>
763
764 <varlistentry>
765 <term><option>-o</option></term>
766 <term><option>--output=</option></term>
767
768 <listitem><para>When used with <command>status</command>,
769 controls the formatting of the journal entries that are shown.
770 For the available choices, see
771 <citerefentry><refentrytitle>journalctl</refentrytitle><manvolnum>1</manvolnum></citerefentry>.
772 Defaults to <literal>short</literal>.</para></listitem>
773 </varlistentry>
774
775 <varlistentry>
776 <term><option>--verify=</option></term>
777
778 <listitem><para>When downloading a container or VM image,
779 specify whether the image shall be verified before it is made
780 available. Takes one of <literal>no</literal>,
781 <literal>checksum</literal> and <literal>signature</literal>.
782 If <literal>no</literal>, no verification is done. If
783 <literal>checksum</literal> is specified, the download is
784 checked for integrity after the transfer is complete, but no
785 signatures are verified. If <literal>signature</literal> is
786 specified, the checksum is verified and the image's signature
787 is checked against a local keyring of trustable vendors. It is
788 strongly recommended to set this option to
789 <literal>signature</literal> if the server and protocol
790 support this. Defaults to
791 <literal>signature</literal>.</para></listitem>
792 </varlistentry>
793
794 <varlistentry>
795 <term><option>--force</option></term>
796
797 <listitem><para>When downloading a container or VM image, and
798 a local copy by the specified local machine name already
799 exists, delete it first and replace it by the newly downloaded
800 image.</para></listitem>
801 </varlistentry>
802
803 <varlistentry>
804 <term><option>--format=</option></term>
805
806 <listitem><para>When used with the <option>export-tar</option>
807 or <option>export-raw</option> commands, specifies the
808 compression format to use for the resulting file. Takes one of
809 <literal>uncompressed</literal>, <literal>xz</literal>,
810 <literal>gzip</literal>, <literal>bzip2</literal>. By default,
811 the format is determined automatically from the image file
812 name passed.</para></listitem>
813 </varlistentry>
814
815 <varlistentry>
816 <term><option>--max-addresses=</option></term>
817
03f9228e
LP
818 <listitem><para>When used with the <option>list-machines</option> command, limits the number of ip
819 addresses output for every machine. Defaults to 1. All addresses can be requested with
820 <literal>all</literal> as argument to <option>--max-addresses=</option>. If the argument to
821 <option>--max-addresses=</option> is less than the actual number of addresses,
822 <literal>…</literal>follows the last address.</para></listitem>
e1fac8a6
ZJS
823 </varlistentry>
824
825 <varlistentry>
826 <term><option>-q</option></term>
827 <term><option>--quiet</option></term>
828
829 <listitem><para>Suppresses additional informational output while running.</para></listitem>
830 </varlistentry>
831
832 <xi:include href="user-system-options.xml" xpointer="host" />
833
834 <varlistentry>
835 <term><option>-M</option></term>
836 <term><option>--machine=</option></term>
837
838 <listitem><para>Connect to
839 <citerefentry><refentrytitle>systemd-machined.service</refentrytitle><manvolnum>8</manvolnum></citerefentry>
840 running in a local container, to perform the specified operation within
841 the container.</para></listitem>
842 </varlistentry>
843
844 <xi:include href="standard-options.xml" xpointer="no-pager" />
845 <xi:include href="standard-options.xml" xpointer="no-legend" />
846 <xi:include href="standard-options.xml" xpointer="no-ask-password" />
847 <xi:include href="standard-options.xml" xpointer="help" />
848 <xi:include href="standard-options.xml" xpointer="version" />
849 </variablelist>
850 </refsect1>
851
91913f58
LP
852 <refsect1>
853 <title>Machine and Image Names</title>
854
855 <para>The <command>machinectl</command> tool operates on machines
b938cb90 856 and images whose names must be chosen following strict
38b38500 857 rules. Machine names must be suitable for use as hostnames
91913f58
LP
858 following a conservative subset of DNS and UNIX/Linux
859 semantics. Specifically, they must consist of one or more
860 non-empty label strings, separated by dots. No leading or trailing
861 dots are allowed. No sequences of multiple dots are allowed. The
a8eaaee7 862 label strings may only consist of alphanumeric characters as well
91913f58
LP
863 as the dash and underscore. The maximum length of a machine name
864 is 64 characters.</para>
865
866 <para>A special machine with the name <literal>.host</literal>
867 refers to the running host system itself. This is useful for execution
a8eaaee7 868 operations or inspecting the host system as well. Note that
91913f58
LP
869 <command>machinectl list</command> will not show this special
870 machine unless the <option>--all</option> switch is specified.</para>
871
a8eaaee7 872 <para>Requirements on image names are less strict, however, they must be
91913f58
LP
873 valid UTF-8, must be suitable as file names (hence not be the
874 single or double dot, and not include a slash), and may not
875 contain control characters. Since many operations search for an
b938cb90 876 image by the name of a requested machine, it is recommended to name
91913f58
LP
877 images in the same strict fashion as machines.</para>
878
879 <para>A special image with the name <literal>.host</literal>
a8eaaee7 880 refers to the image of the running host system. It hence
91913f58
LP
881 conceptually maps to the special <literal>.host</literal> machine
882 name described above. Note that <command>machinectl
7ca41557 883 list-images</command> will not show this special image either, unless
91913f58
LP
884 <option>--all</option> is specified.</para>
885 </refsect1>
886
798d3a52
ZJS
887 <refsect1>
888 <title>Files and Directories</title>
889
890 <para>Machine images are preferably stored in
891 <filename>/var/lib/machines/</filename>, but are also searched for
892 in <filename>/usr/local/lib/machines/</filename> and
b938cb90 893 <filename>/usr/lib/machines/</filename>. For compatibility reasons,
798d3a52
ZJS
894 the directory <filename>/var/lib/container/</filename> is
895 searched, too. Note that images stored below
3b121157 896 <filename>/usr/</filename> are always considered read-only. It is
798d3a52
ZJS
897 possible to symlink machines images from other directories into
898 <filename>/var/lib/machines/</filename> to make them available for
899 control with <command>machinectl</command>.</para>
900
5f7ecd61 901 <para>Note that some image operations are only supported, efficient or atomic on btrfs file systems.</para>
7de30452 902
798d3a52
ZJS
903 <para>Disk images are understood by
904 <citerefentry><refentrytitle>systemd-nspawn</refentrytitle><manvolnum>1</manvolnum></citerefentry>
905 and <command>machinectl</command> in three formats:</para>
906
907 <itemizedlist>
908 <listitem><para>A simple directory tree, containing the files
909 and directories of the container to boot.</para></listitem>
910
a8eaaee7 911 <listitem><para>Subvolumes (on btrfs file systems), which are
798d3a52
ZJS
912 similar to the simple directories, described above. However,
913 they have additional benefits, such as efficient cloning and
914 quota reporting.</para></listitem>
915
916 <listitem><para>"Raw" disk images, i.e. binary images of disks
917 with a GPT or MBR partition table. Images of this type are
918 regular files with the suffix
919 <literal>.raw</literal>.</para></listitem>
920 </itemizedlist>
921
922 <para>See
923 <citerefentry><refentrytitle>systemd-nspawn</refentrytitle><manvolnum>1</manvolnum></citerefentry>
a8eaaee7 924 for more information on image formats, in particular its
798d3a52
ZJS
925 <option>--directory=</option> and <option>--image=</option>
926 options.</para>
927 </refsect1>
928
929 <refsect1>
930 <title>Examples</title>
931 <example>
932 <title>Download an Ubuntu image and open a shell in it</title>
933
934 <programlisting># machinectl pull-tar https://cloud-images.ubuntu.com/trusty/current/trusty-server-cloudimg-amd64-root.tar.gz
e0ea94c1
LP
935# systemd-nspawn -M trusty-server-cloudimg-amd64-root</programlisting>
936
798d3a52
ZJS
937 <para>This downloads and verifies the specified
938 <filename>.tar</filename> image, and then uses
939 <citerefentry><refentrytitle>systemd-nspawn</refentrytitle><manvolnum>1</manvolnum></citerefentry>
940 to open a shell in it.</para>
941 </example>
942
943 <example>
944 <title>Download a Fedora image, set a root password in it, start
5fadff33 945 it as a service</title>
798d3a52 946
5fadff33
ZJS
947 <programlisting># machinectl pull-raw --verify=no \
948 https://download.fedoraproject.org/pub/fedora/linux/releases/&fedora_latest_version;/Cloud/x86_64/images/Fedora-Cloud-Base-&fedora_latest_version;-&fedora_cloud_release;.x86_64.raw.xz \
949 Fedora-Cloud-Base-&fedora_latest_version;-&fedora_cloud_release;.x86-64
950# systemd-nspawn -M Fedora-Cloud-Base-&fedora_latest_version;-&fedora_cloud_release;.x86-64
ac92ced5
BF
951# passwd
952# exit
5fadff33
ZJS
953# machinectl start Fedora-Cloud-Base-&fedora_latest_version;-&fedora_cloud_release;.x86-64
954# machinectl login Fedora-Cloud-Base-&fedora_latest_version;-&fedora_cloud_release;.x86-64</programlisting>
798d3a52
ZJS
955
956 <para>This downloads the specified <filename>.raw</filename>
b938cb90 957 image with verification disabled. Then, a shell is opened in it
798d3a52
ZJS
958 and a root password is set. Afterwards the shell is left, and
959 the machine started as system service. With the last command a
960 login prompt into the container is requested.</para>
961 </example>
962
6e9efa59
LP
963 <example>
964 <title>Exports a container image as tar file</title>
965
966 <programlisting># machinectl export-tar fedora myfedora.tar.xz</programlisting>
967
a8eaaee7
JE
968 <para>Exports the container <literal>fedora</literal> as an
969 xz-compressed tar file <filename>myfedora.tar.xz</filename> into the
6e9efa59
LP
970 current directory.</para>
971 </example>
972
ef3100e9
LP
973 <example>
974 <title>Create a new shell session</title>
975
976 <programlisting># machinectl shell --uid=lennart</programlisting>
977
b938cb90 978 <para>This creates a new shell session on the local host for
ef3100e9
LP
979 the user ID <literal>lennart</literal>, in a <citerefentry
980 project='die-net'><refentrytitle>su</refentrytitle><manvolnum>1</manvolnum></citerefentry>-like
981 fashion.</para>
982 </example>
983
798d3a52
ZJS
984 </refsect1>
985
986 <refsect1>
987 <title>Exit status</title>
988
989 <para>On success, 0 is returned, a non-zero failure code
990 otherwise.</para>
991 </refsect1>
992
993 <xi:include href="less-variables.xml" />
994
995 <refsect1>
996 <title>See Also</title>
997 <para>
d47410f3 998 <citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
798d3a52
ZJS
999 <citerefentry><refentrytitle>systemd-machined.service</refentrytitle><manvolnum>8</manvolnum></citerefentry>,
1000 <citerefentry><refentrytitle>systemd-nspawn</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
6e9efa59 1001 <citerefentry><refentrytitle>systemd.special</refentrytitle><manvolnum>7</manvolnum></citerefentry>,
16eb4024
ZJS
1002 <citerefentry project='die-net'><refentrytitle>tar</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
1003 <citerefentry project='die-net'><refentrytitle>xz</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
1004 <citerefentry project='die-net'><refentrytitle>gzip</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
1005 <citerefentry project='die-net'><refentrytitle>bzip2</refentrytitle><manvolnum>1</manvolnum></citerefentry>
798d3a52
ZJS
1006 </para>
1007 </refsect1>
19887cd0
ZJS
1008
1009</refentry>