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