Debian Codegraph @

upstream/mageia-cauldron/man1/machinectl.1

raw
1 '\" t
2 .TH "MACHINECTL" "1" "" "systemd 258.7" "machinectl"
3 .\" -----------------------------------------------------------------
4 .\" * Define some portability stuff
5 .\" -----------------------------------------------------------------
6 .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
7 .\" http://bugs.debian.org/507673
8 .\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html
9 .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
10 .ie \n(.g .ds Aq \(aq
11 .el .ds Aq '
12 .\" -----------------------------------------------------------------
13 .\" * set default formatting
14 .\" -----------------------------------------------------------------
15 .\" disable hyphenation
16 .nh
17 .\" disable justification (adjust text to left margin only)
18 .ad l
19 .\" -----------------------------------------------------------------
20 .\" * MAIN CONTENT STARTS HERE *
21 .\" -----------------------------------------------------------------
22 .SH "NAME"
23 machinectl \- Control the systemd machine manager
24 .SH "SYNOPSIS"
25 .HP \w'\fBmachinectl\fR\ 'u
26 \fBmachinectl\fR [OPTIONS...] {COMMAND} [NAME...]
27 .SH "DESCRIPTION"
28 .PP
29 \fBmachinectl\fR
30 may be used to introspect and control the state of the
31 \fBsystemd\fR(1)
32 virtual machine and container registration manager
33 \fBsystemd-machined.service\fR(8)\&.
34 .PP
35 \fBmachinectl\fR
36 may be used to execute operations on machines and images\&. Machines in this sense are considered running instances of:
37 .sp
38 .RS 4
39 .ie n \{\
40 \h'-04'\(bu\h'+03'\c
41 .\}
42 .el \{\
43 .sp -1
44 .IP \(bu 2.3
45 .\}
46 Virtual Machines (VMs) that virtualize hardware to run full operating system (OS) instances (including their kernels) in a virtualized environment on top of the host OS\&.
47 .RE
48 .sp
49 .RS 4
50 .ie n \{\
51 \h'-04'\(bu\h'+03'\c
52 .\}
53 .el \{\
54 .sp -1
55 .IP \(bu 2.3
56 .\}
57 Containers that share the hardware and OS kernel with the host OS, in order to run OS userspace instances on top the host OS\&.
58 .RE
59 .sp
60 .RS 4
61 .ie n \{\
62 \h'-04'\(bu\h'+03'\c
63 .\}
64 .el \{\
65 .sp -1
66 .IP \(bu 2.3
67 .\}
68 The host system itself\&.
69 .RE
70 .PP
71 Machines are identified by names that follow the same rules as UNIX and DNS hostnames\&. For details, see below\&.
72 .PP
73 Machines are instantiated from disk or file system images that frequently\ \&\(em but not necessarily\ \&\(em carry the same name as machines running from them\&. Images in this sense may be:
74 .sp
75 .RS 4
76 .ie n \{\
77 \h'-04'\(bu\h'+03'\c
78 .\}
79 .el \{\
80 .sp -1
81 .IP \(bu 2.3
82 .\}
83 Directory trees containing an OS, including the top\-level directories
84 /usr/,
85 /etc/, and so on\&.
86 .RE
87 .sp
88 .RS 4
89 .ie n \{\
90 \h'-04'\(bu\h'+03'\c
91 .\}
92 .el \{\
93 .sp -1
94 .IP \(bu 2.3
95 .\}
96 btrfs subvolumes containing OS trees, similar to regular directory trees\&.
97 .RE
98 .sp
99 .RS 4
100 .ie n \{\
101 \h'-04'\(bu\h'+03'\c
102 .\}
103 .el \{\
104 .sp -1
105 .IP \(bu 2.3
106 .\}
107 Binary "raw" disk image files containing MBR or GPT partition tables and Linux file systems\&.
108 .RE
109 .sp
110 .RS 4
111 .ie n \{\
112 \h'-04'\(bu\h'+03'\c
113 .\}
114 .el \{\
115 .sp -1
116 .IP \(bu 2.3
117 .\}
118 Similarly, block devices containing MBR or GPT partition tables and file systems\&.
119 .RE
120 .sp
121 .RS 4
122 .ie n \{\
123 \h'-04'\(bu\h'+03'\c
124 .\}
125 .el \{\
126 .sp -1
127 .IP \(bu 2.3
128 .\}
129 The file system tree of the host OS itself\&.
130 .RE
131 .PP
132 Images may be downloaded, imported and exported via the
133 \fBimportctl\fR(1)
134 tool\&.
135 .SH "COMMANDS"
136 .PP
137 The following commands are understood:
138 .SS "Machine Commands"
139 .PP
140 \fBlist\fR
141 .RS 4
142 List currently running (online) virtual machines and containers\&. To enumerate machine images that can be started, use
143 \fBlist\-images\fR
144 (see below)\&. Note that this command hides the special
145 "\&.host"
146 machine by default\&. Use the
147 \fB\-\-all\fR
148 switch to show it\&.
149 .sp
150 Added in version 206\&.
151 .RE
152 .PP
153 \fBstatus\fR \fINAME\fR\&...
154 .RS 4
155 Show runtime status information about one or more virtual machines and containers, followed by the most recent log data from the journal\&. This function is intended to generate human\-readable output\&. If you are looking for computer\-parsable output, use
156 \fBshow\fR
157 instead\&. Note that the log data shown is reported by the virtual machine or container manager, and frequently contains console output of the machine, but not necessarily journal contents of the machine itself\&.
158 .sp
159 Added in version 206\&.
160 .RE
161 .PP
162 \fBshow\fR [\fINAME\fR\&...]
163 .RS 4
164 Show properties of one or more registered virtual machines or containers or the manager itself\&. If no argument is specified, properties of the manager will be shown\&. If a NAME is specified, properties of this virtual machine or container are shown\&. By default, empty properties are suppressed\&. Use
165 \fB\-\-all\fR
166 to show those too\&. To select specific properties to show, use
167 \fB\-\-property=\fR\&. This command is intended to be used whenever computer\-parsable output is required, and does not print the control group tree or journal entries\&. Use
168 \fBstatus\fR
169 if you are looking for formatted human\-readable output\&.
170 .sp
171 Added in version 206\&.
172 .RE
173 .PP
174 \fBstart\fR \fINAME\fR\&...
175 .RS 4
176 Start a container as a system service, using
177 \fBsystemd-nspawn\fR(1)\&. This starts
178 systemd\-nspawn@\&.service, instantiated for the specified machine name, similar to the effect of
179 \fBsystemctl start\fR
180 on the service name\&.
181 \fBsystemd\-nspawn\fR
182 looks for a container image by the specified name in
183 /var/lib/machines/
184 (and other search paths, see below) and runs it\&. Use
185 \fBlist\-images\fR
186 (see below) for listing available container images to start\&.
187 .sp
188 Note that
189 \fBsystemd-machined.service\fR(8)
190 also interfaces with a variety of other container and VM managers,
191 \fBsystemd\-nspawn\fR
192 is just one implementation of it\&. Most of the commands available in
193 \fBmachinectl\fR
194 may be used on containers or VMs controlled by other managers, not just
195 \fBsystemd\-nspawn\fR\&. Starting VMs and container images on those managers requires manager\-specific tools\&.
196 .sp
197 To interactively start a container on the command line with full access to the container\*(Aqs console, please invoke
198 \fBsystemd\-nspawn\fR
199 directly\&. To stop a running container use
200 \fBmachinectl poweroff\fR\&.
201 .sp
202 Added in version 219\&.
203 .RE
204 .PP
205 \fBlogin\fR [\fINAME\fR]
206 .RS 4
207 Open an interactive terminal login session in a container or on the local host\&. If an argument is supplied, it refers to the container machine to connect to\&. If none is specified, or the container name is specified as the empty string, or the special machine name
208 "\&.host"
209 (see below) is specified, the connection is made to the local host instead\&. This will create a TTY connection to a specific container or the local host and asks for the execution of a getty on it\&. Note that this is only supported for containers running
210 \fBsystemd\fR(1)
211 as init system\&.
212 .sp
213 This command will open a full login prompt on the container or the local host, which then asks for username and password\&. Use
214 \fBshell\fR
215 (see below) or
216 \fBsystemd-run\fR(1)
217 with the
218 \fB\-\-machine=\fR
219 switch to directly invoke a single command, either interactively or in the background\&.
220 .sp
221 Added in version 209\&.
222 .RE
223 .PP
224 \fBshell\fR [[\fINAME\fR@]\fINAME\fR [\fIPATH\fR [\fIARGUMENTS\fR\&...]]]
225 .RS 4
226 Open an interactive shell session in a container or on the local host\&. The first argument refers to the container machine to connect to\&. If none is specified, or the machine name is specified as the empty string, or the special machine name
227 "\&.host"
228 (see below) is specified, the connection is made to the local host instead\&. This works similarly to
229 \fBlogin\fR, but immediately invokes a user process\&. This command runs the specified executable with the specified arguments, or the default shell for the user if none is specified, or
230 /bin/sh
231 if no default shell is found\&. By default,
232 \fB\-\-uid=\fR, or by prefixing the machine name with a username and an
233 "@"
234 character, a different user may be selected\&. Use
235 \fB\-\-setenv=\fR
236 to set environment variables for the executed process\&.
237 .sp
238 Note that
239 \fBmachinectl shell\fR
240 does not propagate the exit code/status of the invoked shell process\&. Use
241 \fBsystemd\-run\fR
242 instead if that information is required (see below)\&.
243 .sp
244 Using the
245 \fBshell\fR
246 command without arguments (thus invoking the executed shell or command on the local host), is in many ways similar to a
247 \fBsu\fR(1)
248 session, but, unlike
249 \fBsu\fR, completely isolates the new session from the originating session, so that it shares no process or session properties and is in a clean well\-defined state\&. It will be tracked in a new utmp, login, audit, security, and keyring sessions, and will not inherit any environment variables or resource limits, among other properties\&.
250 .sp
251 Note that
252 \fBsystemd-run\fR(1)
253 with its
254 \fB\-\-machine=\fR
255 switch may be used in place of the
256 \fBmachinectl shell\fR
257 command, and allows non\-interactive operation, more detailed and low\-level configuration of the invoked unit, as well as access to runtime and exit code/status information of the invoked shell process\&. In particular, use
258 \fBsystemd\-run\fR\*(Aqs
259 \fB\-\-wait\fR
260 switch to propagate exit status information of the invoked process\&. Use
261 \fBsystemd\-run\fR\*(Aqs
262 \fB\-\-pty\fR
263 switch to acquire an interactive shell, similarly to
264 \fBmachinectl shell\fR\&. In general,
265 \fBsystemd\-run\fR
266 is preferable for scripting purposes\&. However, note that
267 \fBsystemd\-run\fR
268 might require higher privileges than
269 \fBmachinectl shell\fR\&.
270 .sp
271 Added in version 225\&.
272 .RE
273 .PP
274 \fBenable\fR \fINAME\fR\&..., \fBdisable\fR \fINAME\fR\&...
275 .RS 4
276 Enable or disable a container as a system service to start at system boot, using
277 \fBsystemd-nspawn\fR(1)\&. This enables or disables
278 systemd\-nspawn@\&.service, instantiated for the specified machine name, similarly to the effect of
279 \fBsystemctl enable\fR
280 or
281 \fBsystemctl disable\fR
282 on the service name\&.
283 .sp
284 This command implicitly reloads the system manager configuration after completing the operation\&. Note that this command does not implicitly start or power off the containers that are being operated on\&. If this is desired, combine the command with the
285 \fB\-\-now\fR
286 switch\&.
287 .sp
288 Added in version 219\&.
289 .RE
290 .PP
291 \fBpoweroff\fR \fINAME\fR\&...
292 .RS 4
293 Power off one or more containers\&. This will trigger a shutdown by sending SIGRTMIN+4 to the container\*(Aqs init process, which causes systemd\-compatible init systems to shut down cleanly\&. Use
294 \fBstop\fR
295 as alias for
296 \fBpoweroff\fR\&. This operation does not work on containers that do not run a
297 \fBsystemd\fR(1)\-compatible init system, such as sysvinit\&. Use
298 \fBterminate\fR
299 (see below) to immediately terminate a container or VM, without cleanly shutting it down\&.
300 .sp
301 Added in version 212\&.
302 .RE
303 .PP
304 \fBreboot\fR \fINAME\fR\&...
305 .RS 4
306 Reboot one or more containers\&. This will trigger a reboot by sending SIGINT to the container\*(Aqs init process, which is roughly equivalent to pressing Ctrl+Alt+Del on a non\-containerized system, and is compatible with containers running any system manager\&. Use
307 \fBrestart\fR
308 as alias for
309 \fBreboot\fR\&.
310 .sp
311 Added in version 209\&.
312 .RE
313 .PP
314 \fBterminate\fR \fINAME\fR\&...
315 .RS 4
316 Immediately terminates a virtual machine or container, without cleanly shutting it down\&. This kills all processes of the virtual machine or container and deallocates all resources attached to that instance\&. Use
317 \fBpoweroff\fR
318 to issue a clean shutdown request\&.
319 .sp
320 Added in version 206\&.
321 .RE
322 .PP
323 \fBkill\fR \fINAME\fR\&...
324 .RS 4
325 Send a signal to one or more processes of the virtual machine or container\&. This means processes as seen by the host, not the processes inside the virtual machine or container\&. Use
326 \fB\-\-kill\-whom=\fR
327 to select which process to kill\&. Use
328 \fB\-\-signal=\fR
329 to select the signal to send\&.
330 .sp
331 Added in version 206\&.
332 .RE
333 .PP
334 \fBbind\fR \fINAME\fR \fIPATH\fR [\fIPATH\fR]
335 .RS 4
336 Bind mounts a file or directory from the host into the specified container\&. The first path argument is the source file or directory on the host, the second path argument is the destination file or directory in the container\&. When the latter is omitted, the destination path in the container is the same as the source path on the host\&. When combined with the
337 \fB\-\-read\-only\fR
338 switch, a read\-only bind mount is created\&. When combined with the
339 \fB\-\-mkdir\fR
340 switch, the destination path is first created before the mount is applied\&. Note that this option is currently only supported for
341 \fBsystemd-nspawn\fR(1)
342 containers, and only if user namespacing (\fB\-\-private\-users\fR) is not used\&. This command supports bind mounting directories, regular files, device nodes,
343 \fBAF_UNIX\fR
344 socket nodes, as well as FIFOs\&.
345 .sp
346 Added in version 219\&.
347 .RE
348 .PP
349 \fBcopy\-to\fR \fINAME\fR \fIPATH\fR [\fIPATH\fR] \fB\-\-force\fR
350 .RS 4
351 Copies files or directories from the host system into a running container\&. Takes a container name, followed by the source path on the host and the destination path in the container\&. If the destination path is omitted, the same as the source path is used\&.
352 .sp
353 If host and container share the same user and group namespace, file ownership by numeric user ID and group ID is preserved for the copy, otherwise all files and directories in the copy will be owned by the root user and group (UID/GID 0)\&.
354 .sp
355 Added in version 219\&.
356 .RE
357 .PP
358 \fBcopy\-from\fR \fINAME\fR \fIPATH\fR [\fIPATH\fR] \fB\-\-force\fR
359 .RS 4
360 Copies files or directories from a container into the host system\&. Takes a container name, followed by the source path in the container and the destination path on the host\&. If the destination path is omitted, the same as the source path is used\&.
361 .sp
362 If host and container share the same user and group namespace, file ownership by numeric user ID and group ID is preserved for the copy, otherwise all files and directories in the copy will be owned by the root user and group (UID/GID 0)\&.
363 .sp
364 Added in version 219\&.
365 .RE
366 .SS "Image Commands"
367 .PP
368 \fBlist\-images\fR
369 .RS 4
370 Show a list of locally installed container and VM images\&. This enumerates all raw disk images and container directories and subvolumes in
371 /var/lib/machines/
372 (and other search paths, see below)\&. Use
373 \fBstart\fR
374 (see above) to run a container off one of the listed images\&. Note that, by default, containers whose name begins with a dot ("\&.") are not shown\&. To show these too, specify
375 \fB\-\-all\fR\&. Note that a special image
376 "\&.host"
377 always implicitly exists and refers to the image the host itself is booted from\&.
378 .sp
379 Added in version 219\&.
380 .RE
381 .PP
382 \fBimage\-status\fR [\fINAME\fR\&...]
383 .RS 4
384 Show terse status information about one or more container or VM images\&. This function is intended to generate human\-readable output\&. Use
385 \fBshow\-image\fR
386 (see below) to generate computer\-parsable output instead\&.
387 .sp
388 Added in version 219\&.
389 .RE
390 .PP
391 \fBshow\-image\fR [\fINAME\fR\&...]
392 .RS 4
393 Show properties of one or more registered virtual machine or container images, or the manager itself\&. If no argument is specified, properties of the manager will be shown\&. If a NAME is specified, properties of this virtual machine or container image are shown\&. By default, empty properties are suppressed\&. Use
394 \fB\-\-all\fR
395 to show those too\&. To select specific properties to show, use
396 \fB\-\-property=\fR\&. This command is intended to be used whenever computer\-parsable output is required\&. Use
397 \fBimage\-status\fR
398 if you are looking for formatted human\-readable output\&.
399 .sp
400 Added in version 219\&.
401 .RE
402 .PP
403 \fBedit\fR \fINAME|FILE\fR
404 .RS 4
405 Edit the settings file of the specified machines\&. For the format of the settings file, refer to
406 \fBsystemd.nspawn\fR(5)\&. If an existing settings file of the given machine cannot be found,
407 \fBedit\fR
408 automatically create a new settings file from scratch under
409 /etc/systemd/nspawn/\&.
410 .sp
411 Added in version 254\&.
412 .RE
413 .PP
414 \fBcat\fR \fINAME|FILE\fR
415 .RS 4
416 Show the settings file of the specified machines\&.
417 .sp
418 Added in version 254\&.
419 .RE
420 .PP
421 \fBclone\fR \fINAME\fR \fINAME\fR
422 .RS 4
423 Clones a container or VM image\&. The arguments specify the name of the image to clone and the name of the newly cloned image\&. Note that plain directory container images are cloned into btrfs subvolume images with this command, if the underlying file system supports this\&. Note that cloning a container or VM image is optimized for file systems that support copy\-on\-write, and might not be efficient on others, due to file system limitations\&.
424 .sp
425 Note that this command leaves hostname, machine ID and all other settings that could identify the instance unmodified\&. The original image and the cloned copy will hence share these credentials, and it might be necessary to manually change them in the copy\&.
426 .sp
427 If combined with the
428 \fB\-\-read\-only\fR
429 switch a read\-only cloned image is created\&.
430 .sp
431 Added in version 219\&.
432 .RE
433 .PP
434 \fBrename\fR \fINAME\fR \fINAME\fR
435 .RS 4
436 Renames a container or VM image\&. The arguments specify the name of the image to rename and the new name of the image\&.
437 .sp
438 Added in version 219\&.
439 .RE
440 .PP
441 \fBread\-only\fR \fINAME\fR [\fIBOOL\fR]
442 .RS 4
443 Marks or (unmarks) a container or VM image read\-only\&. Takes a VM or container image name, followed by a boolean as arguments\&. If the boolean is omitted, positive is implied, i\&.e\&. the image is marked read\-only\&.
444 .sp
445 Added in version 219\&.
446 .RE
447 .PP
448 \fBremove\fR \fINAME\fR\&...
449 .RS 4
450 Removes one or more container or VM images\&. The special image
451 "\&.host", which refers to the host\*(Aqs own directory tree, may not be removed\&.
452 .sp
453 Added in version 219\&.
454 .RE
455 .PP
456 \fBset\-limit\fR [\fINAME\fR] \fIBYTES\fR
457 .RS 4
458 Sets the maximum size in bytes that a specific container or VM image, or all images, may grow up to on disk (disk quota)\&. Takes either one or two parameters\&. The first, optional parameter refers to a container or VM image name\&. If specified, the size limit of the specified image is changed\&. If omitted, the overall size limit of the sum of all images stored locally is changed\&. The final argument specifies the size limit in bytes, possibly suffixed by the usual K, M, G, T units\&. If the size limit shall be disabled, specify
459 "\-"
460 as size\&.
461 .sp
462 Note that per\-container size limits are only supported on btrfs file systems\&.
463 .sp
464 Added in version 220\&.
465 .RE
466 .PP
467 \fBclean\fR
468 .RS 4
469 Remove hidden VM or container images (or all)\&. This command removes all hidden machine images from
470 /var/lib/machines/, i\&.e\&. those whose name begins with a dot\&. Use
471 \fBmachinectl list\-images \-\-all\fR
472 to see a list of all machine images, including the hidden ones\&.
473 .sp
474 When combined with the
475 \fB\-\-all\fR
476 switch removes all images, not just hidden ones\&. This command effectively empties
477 /var/lib/machines/\&.
478 .sp
479 Note that commands such as
480 \fBimportctl pull\-tar\fR
481 or
482 \fBimportctl pull\-raw\fR
483 usually create hidden, read\-only, unmodified machine images from the downloaded image first, before cloning a writable working copy of it, in order to avoid duplicate downloads in case of images that are reused multiple times\&. Use
484 \fBmachinectl clean\fR
485 to remove old, hidden images created this way\&.
486 .sp
487 Added in version 230\&.
488 .RE
489 .SH "OPTIONS"
490 .PP
491 The following options are understood:
492 .PP
493 \fB\-p\fR, \fB\-\-property=\fR
494 .RS 4
495 When showing machine or image properties, limit the output to certain properties as specified by the argument\&. If not specified, all set properties are shown\&. The argument should be a property name, such as
496 "Name"\&. If specified more than once, all properties with the specified names are shown\&.
497 .sp
498 Added in version 206\&.
499 .RE
500 .PP
501 \fB\-\-value\fR
502 .RS 4
503 When printing properties with
504 \fBshow\fR, only print the value, and skip the property name and
505 "="\&.
506 .sp
507 Added in version 230\&.
508 .RE
509 .PP
510 \fB\-P\fR
511 .RS 4
512 Equivalent to
513 \fB\-\-value\fR
514 \fB\-\-property=\fR, i\&.e\&. shows the value of the property without the property name or
515 "="\&. Note that using
516 \fB\-P\fR
517 once will also affect all properties listed with
518 \fB\-p\fR/\fB\-\-property=\fR\&.
519 .sp
520 Added in version 256\&.
521 .RE
522 .PP
523 \fB\-a\fR, \fB\-\-all\fR
524 .RS 4
525 When showing machine or image properties, show all properties regardless of whether they are set or not\&.
526 .sp
527 When listing VM or container images, do not suppress images beginning in a dot character ("\&.")\&.
528 .sp
529 When cleaning VM or container images, remove all images, not just hidden ones\&.
530 .sp
531 Added in version 206\&.
532 .RE
533 .PP
534 \fB\-l\fR, \fB\-\-full\fR
535 .RS 4
536 Do not ellipsize process tree entries or table\&. This implies
537 \fB\-\-max\-addresses=full\fR\&.
538 .sp
539 Added in version 206\&.
540 .RE
541 .PP
542 \fB\-\-kill\-whom=\fR
543 .RS 4
544 When used with
545 \fBkill\fR, choose which processes to kill\&. Must be one of
546 \fBleader\fR,
547 \fBsupervisor\fR, or
548 \fBall\fR
549 to select whether to kill only the leader process of the machine, the supervisor process of the machine, or all processes of the machine\&. If omitted, defaults to
550 \fBall\fR\&.
551 .sp
552 Added in version 206\&.
553 .RE
554 .PP
555 \fB\-s\fR, \fB\-\-signal=\fR
556 .RS 4
557 When used with
558 \fBkill\fR, choose which signal to send to selected processes\&. Must be one of the well\-known signal specifiers such as
559 \fBSIGTERM\fR,
560 \fBSIGINT\fR
561 or
562 \fBSIGSTOP\fR\&. If omitted, defaults to
563 \fBSIGTERM\fR\&.
564 .sp
565 The special value
566 "help"
567 will list the known values and the program will exit immediately, and the special value
568 "list"
569 will list known values along with the numerical signal numbers and the program will exit immediately\&.
570 .RE
571 .PP
572 \fB\-\-uid=\fR
573 .RS 4
574 When used with the
575 \fBshell\fR
576 command, chooses the user ID to open the interactive shell session as\&. If the argument to the
577 \fBshell\fR
578 command also specifies a user name, this option is ignored\&. If the name is not specified in either way,
579 "root"
580 will be used by default\&. Note that this switch is not supported for the
581 \fBlogin\fR
582 command (see below)\&.
583 .sp
584 Added in version 225\&.
585 .RE
586 .PP
587 \fB\-E \fR\fB\fINAME\fR\fR\fB[=\fR\fB\fIVALUE\fR\fR\fB]\fR, \fB\-\-setenv=\fR\fB\fINAME\fR\fR\fB[=\fR\fB\fIVALUE\fR\fR\fB]\fR
588 .RS 4
589 When used with the
590 \fBshell\fR
591 command, sets an environment variable for the executed shell\&. This option may be used more than once to set multiple variables\&. When
592 "="
593 and
594 \fIVALUE\fR
595 are omitted, the value of the variable with the same name in the program environment will be used\&.
596 .sp
597 Note that this option is not supported for the
598 \fBlogin\fR
599 command\&.
600 .sp
601 Added in version 230\&.
602 .RE
603 .PP
604 \fB\-\-mkdir\fR
605 .RS 4
606 When used with
607 \fBbind\fR, creates the destination file or directory before applying the bind mount\&. Note that even though the name of this option suggests that it is suitable only for directories, this option also creates the destination file node to mount over if the object to mount is not a directory, but a regular file, device node, socket or FIFO\&.
608 .sp
609 Added in version 219\&.
610 .RE
611 .PP
612 \fB\-\-read\-only\fR
613 .RS 4
614 When used with
615 \fBbind\fR, creates a read\-only bind mount\&.
616 .sp
617 When used with
618 \fBclone\fR
619 a read\-only container or VM image is created\&.
620 .sp
621 Added in version 219\&.
622 .RE
623 .PP
624 \fB\-n\fR, \fB\-\-lines=\fR
625 .RS 4
626 When used with
627 \fBstatus\fR, controls the number of journal lines to show, counting from the most recent ones\&. Takes a positive integer argument\&. Defaults to 10\&.
628 .sp
629 Added in version 219\&.
630 .RE
631 .PP
632 \fB\-o\fR, \fB\-\-output=\fR
633 .RS 4
634 When used with
635 \fBstatus\fR, controls the formatting of the journal entries that are shown\&. For the available choices, see
636 \fBjournalctl\fR(1)\&. Defaults to
637 "short"\&.
638 .sp
639 Added in version 219\&.
640 .RE
641 .PP
642 \fB\-\-runner=\fR\fBnspawn\fR|\fBvmspawn\fR
643 .RS 4
644 When operating on machines choose whether to use
645 \fBsystemd-nspawn\fR(1)
646 or
647 \fBsystemd-vmspawn\fR(1)\&. By default
648 \fBsystemd-nspawn\fR(1)
649 is used\&.
650 .sp
651 Added in version 256\&.
652 .RE
653 .PP
654 \fB\-V\fR
655 .RS 4
656 \fB\-V\fR
657 is a shorthand for
658 \fB\-\-runner=vmspawn\fR\&.
659 .sp
660 Added in version 256\&.
661 .RE
662 .PP
663 \fB\-\-now\fR
664 .RS 4
665 When used with
666 \fBenable\fR
667 or
668 \fBdisable\fR, the containers will also be started or powered off\&. The start or poweroff operation is only carried out when the respective enable or disable operation has been successful\&.
669 .sp
670 Added in version 253\&.
671 .RE
672 .PP
673 \fB\-\-force\fR
674 .RS 4
675 Replace target file when copying files\&.
676 .sp
677 Added in version 219\&.
678 .RE
679 .PP
680 \fB\-\-max\-addresses=\fR
681 .RS 4
682 When used with the
683 \fBlist\-machines\fR
684 command, limits the number of IP addresses shown for every machine\&. Defaults to 1\&. All addresses can be requested with
685 "all"\&. If the limit is 0, the address column is not shown\&. Otherwise, if the machine has more addresses than shown,
686 "\&..."
687 follows the last address\&.
688 .sp
689 Added in version 232\&.
690 .RE
691 .PP
692 \fB\-q\fR, \fB\-\-quiet\fR
693 .RS 4
694 Suppresses additional informational output while running\&.
695 .sp
696 Added in version 236\&.
697 .RE
698 .PP
699 \fB\-H\fR, \fB\-\-host=\fR
700 .RS 4
701 Execute the operation remotely\&. Specify a hostname, or a username and hostname separated by
702 "@", to connect to\&. The hostname may optionally be suffixed by a port ssh is listening on, separated by
703 ":", and then a container name, separated by
704 "/", which connects directly to a specific container on the specified host\&. This will use SSH to talk to the remote machine manager instance\&. Container names may be enumerated with
705 \fBmachinectl \-H \fR\fB\fIHOST\fR\fR\&. Put IPv6 addresses in brackets\&.
706 .RE
707 .PP
708 \fB\-M\fR, \fB\-\-machine=\fR
709 .RS 4
710 Connect to
711 \fBsystemd-machined.service\fR(8)
712 running in a local container, to perform the specified operation within the container\&.
713 .sp
714 Added in version 235\&.
715 .RE
716 .PP
717 \fB\-\-no\-pager\fR
718 .RS 4
719 Do not pipe output into a pager\&.
720 .RE
721 .PP
722 \fB\-\-no\-legend\fR
723 .RS 4
724 Do not print the legend, i\&.e\&. column headers and the footer with hints\&.
725 .RE
726 .PP
727 \fB\-\-no\-ask\-password\fR
728 .RS 4
729 Do not query the user for authentication for privileged operations\&.
730 .RE
731 .PP
732 \fB\-h\fR, \fB\-\-help\fR
733 .RS 4
734 Print a short help text and exit\&.
735 .RE
736 .PP
737 \fB\-\-version\fR
738 .RS 4
739 Print a short version string and exit\&.
740 .RE
741 .SH "MACHINE AND IMAGE NAMES"
742 .PP
743 The
744 \fBmachinectl\fR
745 tool operates on machines and images whose names must be chosen following strict rules\&. Machine names must be suitable for use as hostnames following a conservative subset of DNS and UNIX/Linux semantics\&. Specifically, they must consist of one or more non\-empty label strings, separated by dots\&. No leading or trailing dots are allowed\&. No sequences of multiple dots are allowed\&. The label strings may only consist of alphanumeric characters as well as the dash\&. The maximum length of a machine name is 64 characters\&.
746 .PP
747 A special machine with the name
748 "\&.host"
749 refers to the running host system itself\&. This is useful for execution operations or inspecting the host system as well\&. Note that
750 \fBmachinectl list\fR
751 will not show this special machine unless the
752 \fB\-\-all\fR
753 switch is specified\&.
754 .PP
755 Requirements on image names are less strict, however, they must be valid UTF\-8, must be suitable as file names (hence not be the single or double dot, and not include a slash), and may not contain control characters\&. Since many operations search for an image by the name of a requested machine, it is recommended to name images in the same strict fashion as machines\&.
756 .PP
757 A special image with the name
758 "\&.host"
759 refers to the image of the running host system\&. It hence conceptually maps to the special
760 "\&.host"
761 machine name described above\&. Note that
762 \fBmachinectl list\-images\fR
763 will not show this special image either, unless
764 \fB\-\-all\fR
765 is specified\&.
766 .SH "FILES AND DIRECTORIES"
767 .PP
768 Machine images are preferably stored in
769 /var/lib/machines/, but are also searched for in
770 /usr/local/lib/machines/
771 and
772 /usr/lib/machines/\&. For compatibility reasons, the directory
773 /var/lib/container/
774 is searched, too\&. Note that images stored below
775 /usr/
776 are always considered read\-only\&. It is possible to symlink machines images from other directories into
777 /var/lib/machines/
778 to make them available for control with
779 \fBmachinectl\fR\&.
780 .PP
781 Note that some image operations are only supported, efficient or atomic on btrfs file systems\&.
782 .PP
783 Disk images are understood by
784 \fBsystemd-nspawn\fR(1)
785 and
786 \fBmachinectl\fR
787 in three formats:
788 .sp
789 .RS 4
790 .ie n \{\
791 \h'-04'\(bu\h'+03'\c
792 .\}
793 .el \{\
794 .sp -1
795 .IP \(bu 2.3
796 .\}
797 A simple directory tree, containing the files and directories of the container to boot\&.
798 .RE
799 .sp
800 .RS 4
801 .ie n \{\
802 \h'-04'\(bu\h'+03'\c
803 .\}
804 .el \{\
805 .sp -1
806 .IP \(bu 2.3
807 .\}
808 Subvolumes (on btrfs file systems), which are similar to the simple directories, described above\&. However, they have additional benefits, such as efficient cloning and quota reporting\&.
809 .RE
810 .sp
811 .RS 4
812 .ie n \{\
813 \h'-04'\(bu\h'+03'\c
814 .\}
815 .el \{\
816 .sp -1
817 .IP \(bu 2.3
818 .\}
819 "Raw" disk images, i\&.e\&. binary images of disks with a GPT or MBR partition table\&. Images of this type are regular files with the suffix
820 "\&.raw"\&.
821 .RE
822 .PP
823 See
824 \fBsystemd-nspawn\fR(1)
825 for more information on image formats, in particular its
826 \fB\-\-directory=\fR
827 and
828 \fB\-\-image=\fR
829 options\&.
830 .SH "EXAMPLES"
831 .PP
832 \fBExample\ \&1.\ \&Download an Ubuntu RAW image, set a root password in it, start it as a service\fR
833 .sp
834 .if n \{\
835 .RS 4
836 .\}
837 .nf
838 # importctl pull\-raw \-mN \e
839 https://cloud\-images\&.ubuntu\&.com/jammy/current/jammy\-server\-cloudimg\-amd64\-disk\-kvm\&.img \e
840 jammy
841 # systemd\-firstboot \-\-image=/var/lib/machines/jammy\&.raw \-\-prompt\-root\-password \-\-force
842 # machinectl start jammy
843 # machinectl login jammy
844 .fi
845 .if n \{\
846 .RE
847 .\}
848 .PP
849 This downloads the specified
850 \&.raw
851 image and makes it available under the local name
852 "jammy"\&. Then, a root password is set with
853 \fBsystemd-firstboot\fR(1)\&. Afterwards the machine is started as system service\&. With the last command a login prompt into the container is requested\&.
854 .SH "EXIT STATUS"
855 .PP
856 On success, 0 is returned, a non\-zero failure code otherwise\&.
857 .SH "ENVIRONMENT"
858 .PP
859 \fI$SYSTEMD_LOG_LEVEL\fR
860 .RS 4
861 The maximum log level of emitted messages (messages with a higher log level, i\&.e\&. less important ones, will be suppressed)\&. Takes a comma\-separated list of values\&. A value may be either one of (in order of decreasing importance)
862 \fBemerg\fR,
863 \fBalert\fR,
864 \fBcrit\fR,
865 \fBerr\fR,
866 \fBwarning\fR,
867 \fBnotice\fR,
868 \fBinfo\fR,
869 \fBdebug\fR, or an integer in the range 0\&...7\&. See
870 \fBsyslog\fR(3)
871 for more information\&. Each value may optionally be prefixed with one of
872 \fBconsole\fR,
873 \fBsyslog\fR,
874 \fBkmsg\fR
875 or
876 \fBjournal\fR
877 followed by a colon to set the maximum log level for that specific log target (e\&.g\&.
878 \fBSYSTEMD_LOG_LEVEL=debug,console:info\fR
879 specifies to log at debug level except when logging to the console which should be at info level)\&. Note that the global maximum log level takes priority over any per target maximum log levels\&.
880 .RE
881 .PP
882 \fI$SYSTEMD_LOG_COLOR\fR
883 .RS 4
884 A boolean\&. If true, messages written to the tty will be colored according to priority\&.
885 .sp
886 This setting is only useful when messages are written directly to the terminal, because
887 \fBjournalctl\fR(1)
888 and other tools that display logs will color messages based on the log level on their own\&.
889 .RE
890 .PP
891 \fI$SYSTEMD_LOG_TIME\fR
892 .RS 4
893 A boolean\&. If true, console log messages will be prefixed with a timestamp\&.
894 .sp
895 This setting is only useful when messages are written directly to the terminal or a file, because
896 \fBjournalctl\fR(1)
897 and other tools that display logs will attach timestamps based on the entry metadata on their own\&.
898 .RE
899 .PP
900 \fI$SYSTEMD_LOG_LOCATION\fR
901 .RS 4
902 A boolean\&. If true, messages will be prefixed with a filename and line number in the source code where the message originates\&.
903 .sp
904 Note that the log location is often attached as metadata to journal entries anyway\&. Including it directly in the message text can nevertheless be convenient when debugging programs\&.
905 .RE
906 .PP
907 \fI$SYSTEMD_LOG_TID\fR
908 .RS 4
909 A boolean\&. If true, messages will be prefixed with the current numerical thread ID (TID)\&.
910 .sp
911 Note that the this information is attached as metadata to journal entries anyway\&. Including it directly in the message text can nevertheless be convenient when debugging programs\&.
912 .RE
913 .PP
914 \fI$SYSTEMD_LOG_TARGET\fR
915 .RS 4
916 The destination for log messages\&. One of
917 \fBconsole\fR
918 (log to the attached tty),
919 \fBconsole\-prefixed\fR
920 (log to the attached tty but with prefixes encoding the log level and "facility", see
921 \fBsyslog\fR(3),
922 \fBkmsg\fR
923 (log to the kernel circular log buffer),
924 \fBjournal\fR
925 (log to the journal),
926 \fBjournal\-or\-kmsg\fR
927 (log to the journal if available, and to kmsg otherwise),
928 \fBauto\fR
929 (determine the appropriate log target automatically, the default),
930 \fBnull\fR
931 (disable log output)\&.
932 .RE
933 .PP
934 \fI$SYSTEMD_LOG_RATELIMIT_KMSG\fR
935 .RS 4
936 Whether to ratelimit kmsg or not\&. Takes a boolean\&. Defaults to
937 "true"\&. If disabled, systemd will not ratelimit messages written to kmsg\&.
938 .RE
939 .PP
940 \fI$SYSTEMD_PAGER\fR, \fI$PAGER\fR
941 .RS 4
942 Pager to use when
943 \fB\-\-no\-pager\fR
944 is not given\&.
945 \fI$SYSTEMD_PAGER\fR
946 is used if set; otherwise
947 \fI$PAGER\fR
948 is used\&. If neither
949 \fI$SYSTEMD_PAGER\fR
950 nor
951 \fI$PAGER\fR
952 are set, a set of well\-known pager implementations is tried in turn, including
953 \fBless\fR(1)
954 and
955 \fBmore\fR(1), until one is found\&. If no pager implementation is discovered, no pager is invoked\&. Setting those environment variables to an empty string or the value
956 "cat"
957 is equivalent to passing
958 \fB\-\-no\-pager\fR\&.
959 .sp
960 Note: if
961 \fI$SYSTEMD_PAGERSECURE\fR
962 is not set,
963 \fI$SYSTEMD_PAGER\fR
964 and
965 \fI$PAGER\fR
966 can only be used to disable the pager (with
967 "cat"
968 or
969 ""), and are otherwise ignored\&.
970 .RE
971 .PP
972 \fI$SYSTEMD_LESS\fR
973 .RS 4
974 Override the options passed to
975 \fBless\fR
976 (by default
977 "FRSXMK")\&.
978 .sp
979 Users might want to change two options in particular:
980 .PP
981 \fBK\fR
982 .RS 4
983 This option instructs the pager to exit immediately when
984 Ctrl+C
985 is pressed\&. To allow
986 \fBless\fR
987 to handle
988 Ctrl+C
989 itself to switch back to the pager command prompt, unset this option\&.
990 .sp
991 If the value of
992 \fI$SYSTEMD_LESS\fR
993 does not include
994 "K", and the pager that is invoked is
995 \fBless\fR,
996 Ctrl+C
997 will be ignored by the executable, and needs to be handled by the pager\&.
998 .RE
999 .PP
1000 \fBX\fR
1001 .RS 4
1002 This option instructs the pager to not send termcap initialization and deinitialization strings to the terminal\&. It is set by default to allow command output to remain visible in the terminal even after the pager exits\&. Nevertheless, this prevents some pager functionality from working, in particular paged output cannot be scrolled with the mouse\&.
1003 .RE
1004 .sp
1005 Note that setting the regular
1006 \fI$LESS\fR
1007 environment variable has no effect for
1008 \fBless\fR
1009 invocations by systemd tools\&.
1010 .sp
1011 See
1012 \fBless\fR(1)
1013 for more discussion\&.
1014 .RE
1015 .PP
1016 \fI$SYSTEMD_LESSCHARSET\fR
1017 .RS 4
1018 Override the charset passed to
1019 \fBless\fR
1020 (by default
1021 "utf\-8", if the invoking terminal is determined to be UTF\-8 compatible)\&.
1022 .sp
1023 Note that setting the regular
1024 \fI$LESSCHARSET\fR
1025 environment variable has no effect for
1026 \fBless\fR
1027 invocations by systemd tools\&.
1028 .RE
1029 .PP
1030 \fI$SYSTEMD_PAGERSECURE\fR
1031 .RS 4
1032 Common pager commands like
1033 \fBless\fR(1), in addition to "paging", i\&.e\&. scrolling through the output, support opening of or writing to other files and running arbitrary shell commands\&. When commands are invoked with elevated privileges, for example under
1034 \fBsudo\fR(8)
1035 or
1036 \fBpkexec\fR(1), the pager becomes a security boundary\&. Care must be taken that only programs with strictly limited functionality are used as pagers, and unintended interactive features like opening or creation of new files or starting of subprocesses are not allowed\&. "Secure mode" for the pager may be enabled as described below,
1037 \fIif the pager supports that\fR
1038 (most pagers are not written in a way that takes this into consideration)\&. It is recommended to either explicitly enable "secure mode" or to completely disable the pager using
1039 \fB\-\-no\-pager\fR
1040 or
1041 \fIPAGER=cat\fR
1042 when allowing untrusted users to execute commands with elevated privileges\&.
1043 .sp
1044 This option takes a boolean argument\&. When set to true, the "secure mode" of the pager is enabled\&. In "secure mode",
1045 \fBLESSSECURE=1\fR
1046 will be set when invoking the pager, which instructs the pager to disable commands that open or create new files or start new subprocesses\&. Currently only
1047 \fBless\fR(1)
1048 is known to understand this variable and implement "secure mode"\&.
1049 .sp
1050 When set to false, no limitation is placed on the pager\&. Setting
1051 \fISYSTEMD_PAGERSECURE=0\fR
1052 or not removing it from the inherited environment may allow the user to invoke arbitrary commands\&.
1053 .sp
1054 When
1055 \fI$SYSTEMD_PAGERSECURE\fR
1056 is not set, systemd tools attempt to automatically figure out if "secure mode" should be enabled and whether the pager supports it\&. "Secure mode" is enabled if the effective UID is not the same as the owner of the login session, see
1057 \fBgeteuid\fR(2)
1058 and
1059 \fBsd_pid_get_owner_uid\fR(3), or when running under
1060 \fBsudo\fR(8)
1061 or similar tools (\fI$SUDO_UID\fR
1062 is set
1063 \&\s-2\u[1]\d\s+2)\&. In those cases,
1064 \fISYSTEMD_PAGERSECURE=1\fR
1065 will be set and pagers which are not known to implement "secure mode" will not be used at all\&. Note that this autodetection only covers the most common mechanisms to elevate privileges and is intended as convenience\&. It is recommended to explicitly set
1066 \fI$SYSTEMD_PAGERSECURE\fR
1067 or disable the pager\&.
1068 .sp
1069 Note that if the
1070 \fI$SYSTEMD_PAGER\fR
1071 or
1072 \fI$PAGER\fR
1073 variables are to be honoured, other than to disable the pager,
1074 \fI$SYSTEMD_PAGERSECURE\fR
1075 must be set too\&.
1076 .RE
1077 .PP
1078 \fI$SYSTEMD_COLORS\fR
1079 .RS 4
1080 Takes a boolean argument\&. When true,
1081 \fBsystemd\fR
1082 and related utilities will use colors in their output, otherwise the output will be monochrome\&. Additionally, the variable can take one of the following special values:
1083 "16",
1084 "256"
1085 to restrict the use of colors to the base 16 or 256 ANSI colors, respectively\&. This can be specified to override the automatic decision based on
1086 \fI$TERM\fR
1087 and what the console is connected to\&.
1088 .RE
1089 .PP
1090 \fI$SYSTEMD_URLIFY\fR
1091 .RS 4
1092 The value must be a boolean\&. Controls whether clickable links should be generated in the output for terminal emulators supporting this\&. This can be specified to override the decision that
1093 \fBsystemd\fR
1094 makes based on
1095 \fI$TERM\fR
1096 and other conditions\&.
1097 .RE
1098 .SH "SEE ALSO"
1099 .PP
1100 \fBsystemd\fR(1), \fBsystemd-machined.service\fR(8), \fBsystemd-nspawn\fR(1), \fBsystemd.special\fR(7), \fBimportctl\fR(1), \fBtar\fR(1), \fBxz\fR(1), \fBgzip\fR(1), \fBbzip2\fR(1), \fBzstd\fR(1)
1101 .SH "NOTES"
1102 .IP " 1." 4
1103 It is recommended for other tools to set and check
1104 \fI$SUDO_UID\fR
1105 as appropriate, treating it is a common interface.
1106