Debian Codegraph @

upstream/debian-trixie/man1/machinectl.1

raw
1 '\" t
2 .TH "MACHINECTL" "1" "" "systemd 257.13" "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 ready\-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, or
547 \fBall\fR
548 to select whether to kill only the leader process of the machine or all processes of the machine\&. If omitted, defaults to
549 \fBall\fR\&.
550 .sp
551 Added in version 206\&.
552 .RE
553 .PP
554 \fB\-s\fR, \fB\-\-signal=\fR
555 .RS 4
556 When used with
557 \fBkill\fR, choose which signal to send to selected processes\&. Must be one of the well\-known signal specifiers such as
558 \fBSIGTERM\fR,
559 \fBSIGINT\fR
560 or
561 \fBSIGSTOP\fR\&. If omitted, defaults to
562 \fBSIGTERM\fR\&.
563 .sp
564 The special value
565 "help"
566 will list the known values and the program will exit immediately, and the special value
567 "list"
568 will list known values along with the numerical signal numbers and the program will exit immediately\&.
569 .RE
570 .PP
571 \fB\-\-uid=\fR
572 .RS 4
573 When used with the
574 \fBshell\fR
575 command, chooses the user ID to open the interactive shell session as\&. If the argument to the
576 \fBshell\fR
577 command also specifies a user name, this option is ignored\&. If the name is not specified in either way,
578 "root"
579 will be used by default\&. Note that this switch is not supported for the
580 \fBlogin\fR
581 command (see below)\&.
582 .sp
583 Added in version 225\&.
584 .RE
585 .PP
586 \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
587 .RS 4
588 When used with the
589 \fBshell\fR
590 command, sets an environment variable for the executed shell\&. This option may be used more than once to set multiple variables\&. When
591 "="
592 and
593 \fIVALUE\fR
594 are omitted, the value of the variable with the same name in the program environment will be used\&.
595 .sp
596 Note that this option is not supported for the
597 \fBlogin\fR
598 command\&.
599 .sp
600 Added in version 230\&.
601 .RE
602 .PP
603 \fB\-\-mkdir\fR
604 .RS 4
605 When used with
606 \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\&.
607 .sp
608 Added in version 219\&.
609 .RE
610 .PP
611 \fB\-\-read\-only\fR
612 .RS 4
613 When used with
614 \fBbind\fR, creates a read\-only bind mount\&.
615 .sp
616 When used with
617 \fBclone\fR
618 a read\-only container or VM image is created\&.
619 .sp
620 Added in version 219\&.
621 .RE
622 .PP
623 \fB\-n\fR, \fB\-\-lines=\fR
624 .RS 4
625 When used with
626 \fBstatus\fR, controls the number of journal lines to show, counting from the most recent ones\&. Takes a positive integer argument\&. Defaults to 10\&.
627 .sp
628 Added in version 219\&.
629 .RE
630 .PP
631 \fB\-o\fR, \fB\-\-output=\fR
632 .RS 4
633 When used with
634 \fBstatus\fR, controls the formatting of the journal entries that are shown\&. For the available choices, see
635 \fBjournalctl\fR(1)\&. Defaults to
636 "short"\&.
637 .sp
638 Added in version 219\&.
639 .RE
640 .PP
641 \fB\-\-runner=\fR\fBnspawn\fR|\fBvmspawn\fR
642 .RS 4
643 When operating on machines choose whether to use
644 \fBsystemd-nspawn\fR(1)
645 or
646 \fBsystemd-vmspawn\fR(1)\&. By default
647 \fBsystemd-nspawn\fR(1)
648 is used\&.
649 .sp
650 Added in version 256\&.
651 .RE
652 .PP
653 \fB\-V\fR
654 .RS 4
655 \fB\-V\fR
656 is a shorthand for
657 \fB\-\-runner=vmspawn\fR\&.
658 .sp
659 Added in version 256\&.
660 .RE
661 .PP
662 \fB\-\-now\fR
663 .RS 4
664 When used with
665 \fBenable\fR
666 or
667 \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\&.
668 .sp
669 Added in version 253\&.
670 .RE
671 .PP
672 \fB\-\-force\fR
673 .RS 4
674 Replace target file when copying files\&.
675 .sp
676 Added in version 219\&.
677 .RE
678 .PP
679 \fB\-\-max\-addresses=\fR
680 .RS 4
681 When used with the
682 \fBlist\-machines\fR
683 command, limits the number of IP addresses shown for every machine\&. Defaults to 1\&. All addresses can be requested with
684 "all"\&. If the limit is 0, the address column is not shown\&. Otherwise, if the machine has more addresses than shown,
685 "\&..."
686 follows the last address\&.
687 .sp
688 Added in version 232\&.
689 .RE
690 .PP
691 \fB\-q\fR, \fB\-\-quiet\fR
692 .RS 4
693 Suppresses additional informational output while running\&.
694 .sp
695 Added in version 236\&.
696 .RE
697 .PP
698 \fB\-H\fR, \fB\-\-host=\fR
699 .RS 4
700 Execute the operation remotely\&. Specify a hostname, or a username and hostname separated by
701 "@", to connect to\&. The hostname may optionally be suffixed by a port ssh is listening on, separated by
702 ":", and then a container name, separated by
703 "/", 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
704 \fBmachinectl \-H \fR\fB\fIHOST\fR\fR\&. Put IPv6 addresses in brackets\&.
705 .RE
706 .PP
707 \fB\-M\fR, \fB\-\-machine=\fR
708 .RS 4
709 Connect to
710 \fBsystemd-machined.service\fR(8)
711 running in a local container, to perform the specified operation within the container\&.
712 .sp
713 Added in version 235\&.
714 .RE
715 .PP
716 \fB\-\-no\-pager\fR
717 .RS 4
718 Do not pipe output into a pager\&.
719 .RE
720 .PP
721 \fB\-\-no\-legend\fR
722 .RS 4
723 Do not print the legend, i\&.e\&. column headers and the footer with hints\&.
724 .RE
725 .PP
726 \fB\-\-no\-ask\-password\fR
727 .RS 4
728 Do not query the user for authentication for privileged operations\&.
729 .RE
730 .PP
731 \fB\-h\fR, \fB\-\-help\fR
732 .RS 4
733 Print a short help text and exit\&.
734 .RE
735 .PP
736 \fB\-\-version\fR
737 .RS 4
738 Print a short version string and exit\&.
739 .RE
740 .SH "MACHINE AND IMAGE NAMES"
741 .PP
742 The
743 \fBmachinectl\fR
744 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 and underscore\&. The maximum length of a machine name is 64 characters\&.
745 .PP
746 A special machine with the name
747 "\&.host"
748 refers to the running host system itself\&. This is useful for execution operations or inspecting the host system as well\&. Note that
749 \fBmachinectl list\fR
750 will not show this special machine unless the
751 \fB\-\-all\fR
752 switch is specified\&.
753 .PP
754 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\&.
755 .PP
756 A special image with the name
757 "\&.host"
758 refers to the image of the running host system\&. It hence conceptually maps to the special
759 "\&.host"
760 machine name described above\&. Note that
761 \fBmachinectl list\-images\fR
762 will not show this special image either, unless
763 \fB\-\-all\fR
764 is specified\&.
765 .SH "FILES AND DIRECTORIES"
766 .PP
767 Machine images are preferably stored in
768 /var/lib/machines/, but are also searched for in
769 /usr/local/lib/machines/
770 and
771 /usr/lib/machines/\&. For compatibility reasons, the directory
772 /var/lib/container/
773 is searched, too\&. Note that images stored below
774 /usr/
775 are always considered read\-only\&. It is possible to symlink machines images from other directories into
776 /var/lib/machines/
777 to make them available for control with
778 \fBmachinectl\fR\&.
779 .PP
780 Note that some image operations are only supported, efficient or atomic on btrfs file systems\&.
781 .PP
782 Disk images are understood by
783 \fBsystemd-nspawn\fR(1)
784 and
785 \fBmachinectl\fR
786 in three formats:
787 .sp
788 .RS 4
789 .ie n \{\
790 \h'-04'\(bu\h'+03'\c
791 .\}
792 .el \{\
793 .sp -1
794 .IP \(bu 2.3
795 .\}
796 A simple directory tree, containing the files and directories of the container to boot\&.
797 .RE
798 .sp
799 .RS 4
800 .ie n \{\
801 \h'-04'\(bu\h'+03'\c
802 .\}
803 .el \{\
804 .sp -1
805 .IP \(bu 2.3
806 .\}
807 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\&.
808 .RE
809 .sp
810 .RS 4
811 .ie n \{\
812 \h'-04'\(bu\h'+03'\c
813 .\}
814 .el \{\
815 .sp -1
816 .IP \(bu 2.3
817 .\}
818 "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
819 "\&.raw"\&.
820 .RE
821 .PP
822 See
823 \fBsystemd-nspawn\fR(1)
824 for more information on image formats, in particular its
825 \fB\-\-directory=\fR
826 and
827 \fB\-\-image=\fR
828 options\&.
829 .SH "EXAMPLES"
830 .PP
831 \fBExample\ \&1.\ \&Download an Ubuntu RAW image, set a root password in it, start it as a service\fR
832 .sp
833 .if n \{\
834 .RS 4
835 .\}
836 .nf
837 # importctl pull\-raw \-mN \e
838 https://cloud\-images\&.ubuntu\&.com/jammy/current/jammy\-server\-cloudimg\-amd64\-disk\-kvm\&.img \e
839 jammy
840 # systemd\-firstboot \-\-image=/var/lib/machines/jammy\&.raw \-\-prompt\-root\-password \-\-force
841 # machinectl start jammy
842 # machinectl login jammy
843 .fi
844 .if n \{\
845 .RE
846 .\}
847 .PP
848 This downloads the specified
849 \&.raw
850 image and makes it available under the local name
851 "jammy"\&. Then, a root password is set with
852 \fBsystemd-firstboot\fR(1)\&. Afterwards the machine is started as system service\&. With the last command a login prompt into the container is requested\&.
853 .SH "EXIT STATUS"
854 .PP
855 On success, 0 is returned, a non\-zero failure code otherwise\&.
856 .SH "ENVIRONMENT"
857 .PP
858 \fI$SYSTEMD_LOG_LEVEL\fR
859 .RS 4
860 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)
861 \fBemerg\fR,
862 \fBalert\fR,
863 \fBcrit\fR,
864 \fBerr\fR,
865 \fBwarning\fR,
866 \fBnotice\fR,
867 \fBinfo\fR,
868 \fBdebug\fR, or an integer in the range 0\&...7\&. See
869 \fBsyslog\fR(3)
870 for more information\&. Each value may optionally be prefixed with one of
871 \fBconsole\fR,
872 \fBsyslog\fR,
873 \fBkmsg\fR
874 or
875 \fBjournal\fR
876 followed by a colon to set the maximum log level for that specific log target (e\&.g\&.
877 \fBSYSTEMD_LOG_LEVEL=debug,console:info\fR
878 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\&.
879 .RE
880 .PP
881 \fI$SYSTEMD_LOG_COLOR\fR
882 .RS 4
883 A boolean\&. If true, messages written to the tty will be colored according to priority\&.
884 .sp
885 This setting is only useful when messages are written directly to the terminal, because
886 \fBjournalctl\fR(1)
887 and other tools that display logs will color messages based on the log level on their own\&.
888 .RE
889 .PP
890 \fI$SYSTEMD_LOG_TIME\fR
891 .RS 4
892 A boolean\&. If true, console log messages will be prefixed with a timestamp\&.
893 .sp
894 This setting is only useful when messages are written directly to the terminal or a file, because
895 \fBjournalctl\fR(1)
896 and other tools that display logs will attach timestamps based on the entry metadata on their own\&.
897 .RE
898 .PP
899 \fI$SYSTEMD_LOG_LOCATION\fR
900 .RS 4
901 A boolean\&. If true, messages will be prefixed with a filename and line number in the source code where the message originates\&.
902 .sp
903 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\&.
904 .RE
905 .PP
906 \fI$SYSTEMD_LOG_TID\fR
907 .RS 4
908 A boolean\&. If true, messages will be prefixed with the current numerical thread ID (TID)\&.
909 .sp
910 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\&.
911 .RE
912 .PP
913 \fI$SYSTEMD_LOG_TARGET\fR
914 .RS 4
915 The destination for log messages\&. One of
916 \fBconsole\fR
917 (log to the attached tty),
918 \fBconsole\-prefixed\fR
919 (log to the attached tty but with prefixes encoding the log level and "facility", see
920 \fBsyslog\fR(3),
921 \fBkmsg\fR
922 (log to the kernel circular log buffer),
923 \fBjournal\fR
924 (log to the journal),
925 \fBjournal\-or\-kmsg\fR
926 (log to the journal if available, and to kmsg otherwise),
927 \fBauto\fR
928 (determine the appropriate log target automatically, the default),
929 \fBnull\fR
930 (disable log output)\&.
931 .RE
932 .PP
933 \fI$SYSTEMD_LOG_RATELIMIT_KMSG\fR
934 .RS 4
935 Whether to ratelimit kmsg or not\&. Takes a boolean\&. Defaults to
936 "true"\&. If disabled, systemd will not ratelimit messages written to kmsg\&.
937 .RE
938 .PP
939 \fI$SYSTEMD_PAGER\fR, \fI$PAGER\fR
940 .RS 4
941 Pager to use when
942 \fB\-\-no\-pager\fR
943 is not given\&.
944 \fI$SYSTEMD_PAGER\fR
945 is used if set; otherwise
946 \fI$PAGER\fR
947 is used\&. If neither
948 \fI$SYSTEMD_PAGER\fR
949 nor
950 \fI$PAGER\fR
951 are set, a set of well\-known pager implementations is tried in turn, including
952 \fBless\fR(1)
953 and
954 \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
955 "cat"
956 is equivalent to passing
957 \fB\-\-no\-pager\fR\&.
958 .sp
959 Note: if
960 \fI$SYSTEMD_PAGERSECURE\fR
961 is not set,
962 \fI$SYSTEMD_PAGER\fR
963 and
964 \fI$PAGER\fR
965 can only be used to disable the pager (with
966 "cat"
967 or
968 ""), and are otherwise ignored\&.
969 .RE
970 .PP
971 \fI$SYSTEMD_LESS\fR
972 .RS 4
973 Override the options passed to
974 \fBless\fR
975 (by default
976 "FRSXMK")\&.
977 .sp
978 Users might want to change two options in particular:
979 .PP
980 \fBK\fR
981 .RS 4
982 This option instructs the pager to exit immediately when
983 Ctrl+C
984 is pressed\&. To allow
985 \fBless\fR
986 to handle
987 Ctrl+C
988 itself to switch back to the pager command prompt, unset this option\&.
989 .sp
990 If the value of
991 \fI$SYSTEMD_LESS\fR
992 does not include
993 "K", and the pager that is invoked is
994 \fBless\fR,
995 Ctrl+C
996 will be ignored by the executable, and needs to be handled by the pager\&.
997 .RE
998 .PP
999 \fBX\fR
1000 .RS 4
1001 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\&.
1002 .RE
1003 .sp
1004 Note that setting the regular
1005 \fI$LESS\fR
1006 environment variable has no effect for
1007 \fBless\fR
1008 invocations by systemd tools\&.
1009 .sp
1010 See
1011 \fBless\fR(1)
1012 for more discussion\&.
1013 .RE
1014 .PP
1015 \fI$SYSTEMD_LESSCHARSET\fR
1016 .RS 4
1017 Override the charset passed to
1018 \fBless\fR
1019 (by default
1020 "utf\-8", if the invoking terminal is determined to be UTF\-8 compatible)\&.
1021 .sp
1022 Note that setting the regular
1023 \fI$LESSCHARSET\fR
1024 environment variable has no effect for
1025 \fBless\fR
1026 invocations by systemd tools\&.
1027 .RE
1028 .PP
1029 \fI$SYSTEMD_PAGERSECURE\fR
1030 .RS 4
1031 Common pager commands like
1032 \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
1033 \fBsudo\fR(8)
1034 or
1035 \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,
1036 \fIif the pager supports that\fR
1037 (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
1038 \fB\-\-no\-pager\fR
1039 or
1040 \fIPAGER=cat\fR
1041 when allowing untrusted users to execute commands with elevated privileges\&.
1042 .sp
1043 This option takes a boolean argument\&. When set to true, the "secure mode" of the pager is enabled\&. In "secure mode",
1044 \fBLESSSECURE=1\fR
1045 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
1046 \fBless\fR(1)
1047 is known to understand this variable and implement "secure mode"\&.
1048 .sp
1049 When set to false, no limitation is placed on the pager\&. Setting
1050 \fISYSTEMD_PAGERSECURE=0\fR
1051 or not removing it from the inherited environment may allow the user to invoke arbitrary commands\&.
1052 .sp
1053 When
1054 \fI$SYSTEMD_PAGERSECURE\fR
1055 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
1056 \fBgeteuid\fR(2)
1057 and
1058 \fBsd_pid_get_owner_uid\fR(3), or when running under
1059 \fBsudo\fR(8)
1060 or similar tools (\fI$SUDO_UID\fR
1061 is set
1062 \&\s-2\u[1]\d\s+2)\&. In those cases,
1063 \fISYSTEMD_PAGERSECURE=1\fR
1064 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
1065 \fI$SYSTEMD_PAGERSECURE\fR
1066 or disable the pager\&.
1067 .sp
1068 Note that if the
1069 \fI$SYSTEMD_PAGER\fR
1070 or
1071 \fI$PAGER\fR
1072 variables are to be honoured, other than to disable the pager,
1073 \fI$SYSTEMD_PAGERSECURE\fR
1074 must be set too\&.
1075 .RE
1076 .PP
1077 \fI$SYSTEMD_COLORS\fR
1078 .RS 4
1079 Takes a boolean argument\&. When true,
1080 \fBsystemd\fR
1081 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:
1082 "16",
1083 "256"
1084 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
1085 \fI$TERM\fR
1086 and what the console is connected to\&.
1087 .RE
1088 .PP
1089 \fI$SYSTEMD_URLIFY\fR
1090 .RS 4
1091 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
1092 \fBsystemd\fR
1093 makes based on
1094 \fI$TERM\fR
1095 and other conditions\&.
1096 .RE
1097 .SH "SEE ALSO"
1098 .PP
1099 \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)
1100 .SH "NOTES"
1101 .IP " 1." 4
1102 It is recommended for other tools to set and check
1103 \fI$SUDO_UID\fR
1104 as appropriate, treating it is a common interface.
1105