'\" t .TH "MACHINECTL" "1" "" "systemd 254" "machinectl" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .\" http://bugs.debian.org/507673 .\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" ----------------------------------------------------------------- .\" * set default formatting .\" ----------------------------------------------------------------- .\" disable hyphenation .nh .\" disable justification (adjust text to left margin only) .ad l .\" ----------------------------------------------------------------- .\" * MAIN CONTENT STARTS HERE * .\" ----------------------------------------------------------------- .SH "NAME" machinectl \- Control the systemd machine manager .SH "SYNOPSIS" .HP \w'\fBmachinectl\fR\ 'u \fBmachinectl\fR [OPTIONS...] {COMMAND} [NAME...] .SH "DESCRIPTION" .PP \fBmachinectl\fR may be used to introspect and control the state of the \fBsystemd\fR(1) virtual machine and container registration manager \fBsystemd-machined.service\fR(8)\&. .PP \fBmachinectl\fR may be used to execute operations on machines and images\&. Machines in this sense are considered running instances of: .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} 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\&. .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} Containers that share the hardware and OS kernel with the host OS, in order to run OS userspace instances on top the host OS\&. .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} The host system itself\&. .RE .PP Machines are identified by names that follow the same rules as UNIX and DNS hostnames\&. For details, see below\&. .PP 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: .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} Directory trees containing an OS, including the top\-level directories /usr/, /etc/, and so on\&. .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} btrfs subvolumes containing OS trees, similar to regular directory trees\&. .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} Binary "raw" disk image files containing MBR or GPT partition tables and Linux file systems\&. .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} Similarly, block devices containing MBR or GPT partition tables and file systems\&. .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} The file system tree of the host OS itself\&. .RE .SH "COMMANDS" .PP The following commands are understood: .SS "Machine Commands" .PP \fBlist\fR .RS 4 List currently running (online) virtual machines and containers\&. To enumerate machine images that can be started, use \fBlist\-images\fR (see below)\&. Note that this command hides the special "\&.host" machine by default\&. Use the \fB\-\-all\fR switch to show it\&. .RE .PP \fBstatus\fR \fINAME\fR\&... .RS 4 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 \fBshow\fR 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\&. .RE .PP \fBshow\fR [\fINAME\fR\&...] .RS 4 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 \fB\-\-all\fR to show those too\&. To select specific properties to show, use \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 \fBstatus\fR if you are looking for formatted human\-readable output\&. .RE .PP \fBstart\fR \fINAME\fR\&... .RS 4 Start a container as a system service, using \fBsystemd-nspawn\fR(1)\&. This starts systemd\-nspawn@\&.service, instantiated for the specified machine name, similar to the effect of \fBsystemctl start\fR on the service name\&. \fBsystemd\-nspawn\fR looks for a container image by the specified name in /var/lib/machines/ (and other search paths, see below) and runs it\&. Use \fBlist\-images\fR (see below) for listing available container images to start\&. .sp Note that \fBsystemd-machined.service\fR(8) also interfaces with a variety of other container and VM managers, \fBsystemd\-nspawn\fR is just one implementation of it\&. Most of the commands available in \fBmachinectl\fR may be used on containers or VMs controlled by other managers, not just \fBsystemd\-nspawn\fR\&. Starting VMs and container images on those managers requires manager\-specific tools\&. .sp To interactively start a container on the command line with full access to the container\*(Aqs console, please invoke \fBsystemd\-nspawn\fR directly\&. To stop a running container use \fBmachinectl poweroff\fR\&. .RE .PP \fBlogin\fR [\fINAME\fR] .RS 4 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 "\&.host" (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 \fBsystemd\fR(1) as init system\&. .sp This command will open a full login prompt on the container or the local host, which then asks for username and password\&. Use \fBshell\fR (see below) or \fBsystemd-run\fR(1) with the \fB\-\-machine=\fR switch to directly invoke a single command, either interactively or in the background\&. .RE .PP \fBshell\fR [[\fINAME\fR@]\fINAME\fR [\fIPATH\fR [\fIARGUMENTS\fR\&...]]] .RS 4 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 "\&.host" (see below) is specified, the connection is made to the local host instead\&. This works similarly to \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 /bin/sh if no default shell is found\&. By default, \fB\-\-uid=\fR, or by prefixing the machine name with a username and an "@" character, a different user may be selected\&. Use \fB\-\-setenv=\fR to set environment variables for the executed process\&. .sp Note that \fBmachinectl shell\fR does not propagate the exit code/status of the invoked shell process\&. Use \fBsystemd\-run\fR instead if that information is required (see below)\&. .sp Using the \fBshell\fR command without arguments (thus invoking the executed shell or command on the local host), is in many ways similar to a \fBsu\fR(1) session, but, unlike \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\&. .sp Note that \fBsystemd-run\fR(1) with its \fB\-\-machine=\fR switch may be used in place of the \fBmachinectl shell\fR 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 \fBsystemd\-run\fR\*(Aqs \fB\-\-wait\fR switch to propagate exit status information of the invoked process\&. Use \fBsystemd\-run\fR\*(Aqs \fB\-\-pty\fR switch to acquire an interactive shell, similarly to \fBmachinectl shell\fR\&. In general, \fBsystemd\-run\fR is preferable for scripting purposes\&. However, note that \fBsystemd\-run\fR might require higher privileges than \fBmachinectl shell\fR\&. .RE .PP \fBenable\fR \fINAME\fR\&..., \fBdisable\fR \fINAME\fR\&... .RS 4 Enable or disable a container as a system service to start at system boot, using \fBsystemd-nspawn\fR(1)\&. This enables or disables systemd\-nspawn@\&.service, instantiated for the specified machine name, similarly to the effect of \fBsystemctl enable\fR or \fBsystemctl disable\fR on the service name\&. .sp 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 \fB\-\-now\fR switch\&. .RE .PP \fBpoweroff\fR \fINAME\fR\&... .RS 4 Power off one or more containers\&. This will trigger a reboot by sending SIGRTMIN+4 to the container\*(Aqs init process, which causes systemd\-compatible init systems to shut down cleanly\&. Use \fBstop\fR as alias for \fBpoweroff\fR\&. This operation does not work on containers that do not run a \fBsystemd\fR(1)\-compatible init system, such as sysvinit\&. Use \fBterminate\fR (see below) to immediately terminate a container or VM, without cleanly shutting it down\&. .RE .PP \fBreboot\fR \fINAME\fR\&... .RS 4 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\&. .RE .PP \fBterminate\fR \fINAME\fR\&... .RS 4 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 \fBpoweroff\fR to issue a clean shutdown request\&. .RE .PP \fBkill\fR \fINAME\fR\&... .RS 4 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 \fB\-\-kill\-whom=\fR to select which process to kill\&. Use \fB\-\-signal=\fR to select the signal to send\&. .RE .PP \fBbind\fR \fINAME\fR \fIPATH\fR [\fIPATH\fR] .RS 4 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 \fB\-\-read\-only\fR switch, a ready\-only bind mount is created\&. When combined with the \fB\-\-mkdir\fR switch, the destination path is first created before the mount is applied\&. Note that this option is currently only supported for \fBsystemd-nspawn\fR(1) containers, and only if user namespacing (\fB\-\-private\-users\fR) is not used\&. This command supports bind mounting directories, regular files, device nodes, \fBAF_UNIX\fR socket nodes, as well as FIFOs\&. .RE .PP \fBcopy\-to\fR \fINAME\fR \fIPATH\fR [\fIPATH\fR] \fB\-\-force\fR .RS 4 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\&. .sp 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)\&. .RE .PP \fBcopy\-from\fR \fINAME\fR \fIPATH\fR [\fIPATH\fR] \fB\-\-force\fR .RS 4 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\&. .sp 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)\&. .RE .SS "Image Commands" .PP \fBlist\-images\fR .RS 4 Show a list of locally installed container and VM images\&. This enumerates all raw disk images and container directories and subvolumes in /var/lib/machines/ (and other search paths, see below)\&. Use \fBstart\fR (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 \fB\-\-all\fR\&. Note that a special image "\&.host" always implicitly exists and refers to the image the host itself is booted from\&. .RE .PP \fBimage\-status\fR [\fINAME\fR\&...] .RS 4 Show terse status information about one or more container or VM images\&. This function is intended to generate human\-readable output\&. Use \fBshow\-image\fR (see below) to generate computer\-parsable output instead\&. .RE .PP \fBshow\-image\fR [\fINAME\fR\&...] .RS 4 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 \fB\-\-all\fR to show those too\&. To select specific properties to show, use \fB\-\-property=\fR\&. This command is intended to be used whenever computer\-parsable output is required\&. Use \fBimage\-status\fR if you are looking for formatted human\-readable output\&. .RE .PP \fBedit\fR \fINAME|FILE\fR .RS 4 Edit the settings file of the specified machines\&. For the format of the settings file, refer to \fBsystemd.nspawn\fR(5)\&. If an existing settings file of the given machine can\*(Aqt be found, \fBedit\fR automatically create a new settings file from scratch under /etc/systemd/nspawn/ .RE .PP \fBcat\fR \fINAME|FILE\fR .RS 4 Show the settings file of the specified machines\&. .RE .PP \fBclone\fR \fINAME\fR \fINAME\fR .RS 4 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\&. .sp 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\&. .sp If combined with the \fB\-\-read\-only\fR switch a read\-only cloned image is created\&. .RE .PP \fBrename\fR \fINAME\fR \fINAME\fR .RS 4 Renames a container or VM image\&. The arguments specify the name of the image to rename and the new name of the image\&. .RE .PP \fBread\-only\fR \fINAME\fR [\fIBOOL\fR] .RS 4 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\&. .RE .PP \fBremove\fR \fINAME\fR\&... .RS 4 Removes one or more container or VM images\&. The special image "\&.host", which refers to the host\*(Aqs own directory tree, may not be removed\&. .RE .PP \fBset\-limit\fR [\fINAME\fR] \fIBYTES\fR .RS 4 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 "\-" as size\&. .sp Note that per\-container size limits are only supported on btrfs file systems\&. .RE .PP \fBclean\fR .RS 4 Remove hidden VM or container images (or all)\&. This command removes all hidden machine images from /var/lib/machines/, i\&.e\&. those whose name begins with a dot\&. Use \fBmachinectl list\-images \-\-all\fR to see a list of all machine images, including the hidden ones\&. .sp When combined with the \fB\-\-all\fR switch removes all images, not just hidden ones\&. This command effectively empties /var/lib/machines/\&. .sp Note that commands such as \fBmachinectl pull\-tar\fR or \fBmachinectl pull\-raw\fR 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 \fBmachinectl clean\fR to remove old, hidden images created this way\&. .RE .SS "Image Transfer Commands" .PP \fBpull\-tar\fR \fIURL\fR [\fINAME\fR] .RS 4 Downloads a \&.tar container image from the specified URL, and makes it available under the specified local machine name\&. The URL must be of type "http://" or "https://", and must refer to a \&.tar, \&.tar\&.gz, \&.tar\&.xz or \&.tar\&.bz2 archive file\&. If the local machine name is omitted, it is automatically derived from the last component of the URL, with its suffix removed\&. .sp The image is verified before it is made available, unless \fB\-\-verify=no\fR is specified\&. Verification is done either via an inline signed file with the name of the image and the suffix \&.sha256 or via separate SHA256SUMS and SHA256SUMS\&.gpg files\&. The signature files need to be made available on the same web server, under the same URL as the \&.tar file\&. With \fB\-\-verify=checksum\fR, only the SHA256 checksum for the file is verified, based on the \&.sha256 suffixed file or the SHA256SUMS file\&. With \fB\-\-verify=signature\fR, the sha checksum file is first verified with the inline signature in the \&.sha256 file or the detached GPG signature file SHA256SUMS\&.gpg\&. The public key for this verification step needs to be available in /usr/lib/systemd/import\-pubring\&.gpg or /etc/systemd/import\-pubring\&.gpg\&. .sp The container image will be downloaded and stored in a read\-only subvolume in /var/lib/machines/ that is named after the specified URL and its HTTP etag\&. A writable snapshot is then taken from this subvolume, and named after the specified local name\&. This behavior ensures that creating multiple container instances of the same URL is efficient, as multiple downloads are not necessary\&. In order to create only the read\-only image, and avoid creating its writable snapshot, specify "\-" as local machine name\&. .sp Note that the read\-only subvolume is prefixed with \&.tar\-, and is thus not shown by \fBlist\-images\fR, unless \fB\-\-all\fR is passed\&. .sp Note that pressing C\-c during execution of this command will not abort the download\&. Use \fBcancel\-transfer\fR, described below\&. .RE .PP \fBpull\-raw\fR \fIURL\fR [\fINAME\fR] .RS 4 Downloads a \&.raw container or VM disk image from the specified URL, and makes it available under the specified local machine name\&. The URL must be of type "http://" or "https://"\&. The container image must either be a \&.qcow2 or raw disk image, optionally compressed as \&.gz, \&.xz, or \&.bz2\&. If the local machine name is omitted, it is automatically derived from the last component of the URL, with its suffix removed\&. .sp Image verification is identical for raw and tar images (see above)\&. .sp If the downloaded image is in \&.qcow2 format it is converted into a raw image file before it is made available\&. .sp Downloaded images of this type will be placed as read\-only \&.raw file in /var/lib/machines/\&. A local, writable (reflinked) copy is then made under the specified local machine name\&. To omit creation of the local, writable copy pass "\-" as local machine name\&. .sp Similarly to the behavior of \fBpull\-tar\fR, the read\-only image is prefixed with \&.raw\-, and thus not shown by \fBlist\-images\fR, unless \fB\-\-all\fR is passed\&. .sp Note that pressing C\-c during execution of this command will not abort the download\&. Use \fBcancel\-transfer\fR, described below\&. .RE .PP \fBimport\-tar\fR \fIFILE\fR [\fINAME\fR], \fBimport\-raw\fR \fIFILE\fR [\fINAME\fR] .RS 4 Imports a TAR or RAW container or VM image, and places it under the specified name in /var/lib/machines/\&. When \fBimport\-tar\fR is used, the file specified as the first argument should be a tar archive, possibly compressed with xz, gzip or bzip2\&. It will then be unpacked into its own subvolume in /var/lib/machines/\&. When \fBimport\-raw\fR is used, the file should be a qcow2 or raw disk image, possibly compressed with xz, gzip or bzip2\&. If the second argument (the resulting image name) is not specified, it is automatically derived from the file name\&. If the filename is passed as "\-", the image is read from standard input, in which case the second argument is mandatory\&. .sp Optionally, the \fB\-\-read\-only\fR switch may be used to create a read\-only container or VM image\&. No cryptographic validation is done when importing the images\&. .sp Much like image downloads, ongoing imports may be listed with \fBlist\-transfers\fR and aborted with \fBcancel\-transfer\fR\&. .RE .PP \fBimport\-fs\fR \fIDIRECTORY\fR [\fINAME\fR] .RS 4 Imports a container image stored in a local directory into /var/lib/machines/, operates similarly to \fBimport\-tar\fR or \fBimport\-raw\fR, but the first argument is the source directory\&. If supported, this command will create a btrfs snapshot or subvolume for the new image\&. .RE .PP \fBexport\-tar\fR \fINAME\fR [\fIFILE\fR], \fBexport\-raw\fR \fINAME\fR [\fIFILE\fR] .RS 4 Exports a TAR or RAW container or VM image and stores it in the specified file\&. The first parameter should be a VM or container image name\&. The second parameter should be a file path the TAR or RAW image is written to\&. If the path ends in "\&.gz", the file is compressed with gzip, if it ends in "\&.xz", with xz, and if it ends in "\&.bz2", with bzip2\&. If the path ends in neither, the file is left uncompressed\&. If the second argument is missing, the image is written to standard output\&. The compression may also be explicitly selected with the \fB\-\-format=\fR switch\&. This is in particular useful if the second parameter is left unspecified\&. .sp Much like image downloads and imports, ongoing exports may be listed with \fBlist\-transfers\fR and aborted with \fBcancel\-transfer\fR\&. .sp Note that, currently, only directory and subvolume images may be exported as TAR images, and only raw disk images as RAW images\&. .RE .PP \fBlist\-transfers\fR .RS 4 Shows a list of container or VM image downloads, imports and exports that are currently in progress\&. .RE .PP \fBcancel\-transfer\fR \fIID\fR\&... .RS 4 Aborts a download, import or export of the container or VM image with the specified ID\&. To list ongoing transfers and their IDs, use \fBlist\-transfers\fR\&. .RE .SH "OPTIONS" .PP The following options are understood: .PP \fB\-p\fR, \fB\-\-property=\fR .RS 4 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 "Name"\&. If specified more than once, all properties with the specified names are shown\&. .RE .PP \fB\-a\fR, \fB\-\-all\fR .RS 4 When showing machine or image properties, show all properties regardless of whether they are set or not\&. .sp When listing VM or container images, do not suppress images beginning in a dot character ("\&.")\&. .sp When cleaning VM or container images, remove all images, not just hidden ones\&. .RE .PP \fB\-\-value\fR .RS 4 When printing properties with \fBshow\fR, only print the value, and skip the property name and "="\&. .RE .PP \fB\-l\fR, \fB\-\-full\fR .RS 4 Do not ellipsize process tree entries or table\&. This implies \fB\-\-max\-addresses=full\fR\&. .RE .PP \fB\-\-kill\-whom=\fR .RS 4 When used with \fBkill\fR, choose which processes to kill\&. Must be one of \fBleader\fR, or \fBall\fR to select whether to kill only the leader process of the machine or all processes of the machine\&. If omitted, defaults to \fBall\fR\&. .RE .PP \fB\-s\fR, \fB\-\-signal=\fR .RS 4 When used with \fBkill\fR, choose which signal to send to selected processes\&. Must be one of the well\-known signal specifiers such as \fBSIGTERM\fR, \fBSIGINT\fR or \fBSIGSTOP\fR\&. If omitted, defaults to \fBSIGTERM\fR\&. .sp The special value "help" will list the known values and the program will exit immediately, and the special value "list" will list known values along with the numerical signal numbers and the program will exit immediately\&. .RE .PP \fB\-\-uid=\fR .RS 4 When used with the \fBshell\fR command, chooses the user ID to open the interactive shell session as\&. If the argument to the \fBshell\fR command also specifies a user name, this option is ignored\&. If the name is not specified in either way, "root" will be used by default\&. Note that this switch is not supported for the \fBlogin\fR command (see below)\&. .RE .PP \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 .RS 4 When used with the \fBshell\fR command, sets an environment variable for the executed shell\&. This option may be used more than once to set multiple variables\&. When "=" and \fIVALUE\fR are omitted, the value of the variable with the same name in the program environment will be used\&. .sp Note that this option is not supported for the \fBlogin\fR command\&. .RE .PP \fB\-\-mkdir\fR .RS 4 When used with \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\&. .RE .PP \fB\-\-read\-only\fR .RS 4 When used with \fBbind\fR, creates a read\-only bind mount\&. .sp When used with \fBclone\fR, \fBimport\-raw\fR or \fBimport\-tar\fR a read\-only container or VM image is created\&. .RE .PP \fB\-n\fR, \fB\-\-lines=\fR .RS 4 When used with \fBstatus\fR, controls the number of journal lines to show, counting from the most recent ones\&. Takes a positive integer argument\&. Defaults to 10\&. .RE .PP \fB\-o\fR, \fB\-\-output=\fR .RS 4 When used with \fBstatus\fR, controls the formatting of the journal entries that are shown\&. For the available choices, see \fBjournalctl\fR(1)\&. Defaults to "short"\&. .RE .PP \fB\-\-verify=\fR .RS 4 When downloading a container or VM image, specify whether the image shall be verified before it is made available\&. Takes one of "no", "checksum" and "signature"\&. If "no", no verification is done\&. If "checksum" is specified, the download is checked for integrity after the transfer is complete, but no signatures are verified\&. If "signature" is specified, the checksum is verified and the image\*(Aqs signature is checked against a local keyring of trustable vendors\&. It is strongly recommended to set this option to "signature" if the server and protocol support this\&. Defaults to "signature"\&. .RE .PP \fB\-\-now\fR .RS 4 When used with \fBenable\fR or \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\&. .RE .PP \fB\-\-force\fR .RS 4 When downloading a container or VM image, and a local copy by the specified local machine name already exists, delete it first and replace it by the newly downloaded image\&. .RE .PP \fB\-\-format=\fR .RS 4 When used with the \fBexport\-tar\fR or \fBexport\-raw\fR commands, specifies the compression format to use for the resulting file\&. Takes one of "uncompressed", "xz", "gzip", "bzip2"\&. By default, the format is determined automatically from the image file name passed\&. .RE .PP \fB\-\-max\-addresses=\fR .RS 4 When used with the \fBlist\-machines\fR command, limits the number of IP addresses shown for every machine\&. Defaults to 1\&. All addresses can be requested with "all"\&. If the limit is 0, the address column is not shown\&. Otherwise, if the machine has more addresses than shown, "\&..." follows the last address\&. .RE .PP \fB\-q\fR, \fB\-\-quiet\fR .RS 4 Suppresses additional informational output while running\&. .RE .PP \fB\-H\fR, \fB\-\-host=\fR .RS 4 Execute the operation remotely\&. Specify a hostname, or a username and hostname separated by "@", to connect to\&. The hostname may optionally be suffixed by a port ssh is listening on, separated by ":", and then a container name, separated by "/", 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 \fBmachinectl \-H \fR\fB\fIHOST\fR\fR\&. Put IPv6 addresses in brackets\&. .RE .PP \fB\-M\fR, \fB\-\-machine=\fR .RS 4 Connect to \fBsystemd-machined.service\fR(8) running in a local container, to perform the specified operation within the container\&. .RE .PP \fB\-\-no\-pager\fR .RS 4 Do not pipe output into a pager\&. .RE .PP \fB\-\-no\-legend\fR .RS 4 Do not print the legend, i\&.e\&. column headers and the footer with hints\&. .RE .PP \fB\-\-no\-ask\-password\fR .RS 4 Do not query the user for authentication for privileged operations\&. .RE .PP \fB\-h\fR, \fB\-\-help\fR .RS 4 Print a short help text and exit\&. .RE .PP \fB\-\-version\fR .RS 4 Print a short version string and exit\&. .RE .SH "MACHINE AND IMAGE NAMES" .PP The \fBmachinectl\fR 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\&. .PP A special machine with the name "\&.host" refers to the running host system itself\&. This is useful for execution operations or inspecting the host system as well\&. Note that \fBmachinectl list\fR will not show this special machine unless the \fB\-\-all\fR switch is specified\&. .PP 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\&. .PP A special image with the name "\&.host" refers to the image of the running host system\&. It hence conceptually maps to the special "\&.host" machine name described above\&. Note that \fBmachinectl list\-images\fR will not show this special image either, unless \fB\-\-all\fR is specified\&. .SH "FILES AND DIRECTORIES" .PP Machine images are preferably stored in /var/lib/machines/, but are also searched for in /usr/local/lib/machines/ and /usr/lib/machines/\&. For compatibility reasons, the directory /var/lib/container/ is searched, too\&. Note that images stored below /usr/ are always considered read\-only\&. It is possible to symlink machines images from other directories into /var/lib/machines/ to make them available for control with \fBmachinectl\fR\&. .PP Note that some image operations are only supported, efficient or atomic on btrfs file systems\&. .PP Disk images are understood by \fBsystemd-nspawn\fR(1) and \fBmachinectl\fR in three formats: .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} A simple directory tree, containing the files and directories of the container to boot\&. .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} 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\&. .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} "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 "\&.raw"\&. .RE .PP See \fBsystemd-nspawn\fR(1) for more information on image formats, in particular its \fB\-\-directory=\fR and \fB\-\-image=\fR options\&. .SH "EXAMPLES" .PP \fBExample\ \&1.\ \&Download a Ubuntu image and open a shell in it\fR .sp .if n \{\ .RS 4 .\} .nf # machinectl pull\-tar https://cloud\-images\&.ubuntu\&.com/trusty/current/trusty\-server\-cloudimg\-amd64\-root\&.tar\&.gz # systemd\-nspawn \-M trusty\-server\-cloudimg\-amd64\-root .fi .if n \{\ .RE .\} .PP This downloads and verifies the specified \&.tar image, and then uses \fBsystemd-nspawn\fR(1) to open a shell in it\&. .PP \fBExample\ \&2.\ \&Download a Fedora image, set a root password in it, start it as a service\fR .sp .if n \{\ .RS 4 .\} .nf # machinectl pull\-raw \-\-verify=no \e https://download\&.fedoraproject\&.org/pub/fedora/linux/releases/37/Cloud/x86_64/images/Fedora\-Cloud\-Base\-37\-1\&.7\&.x86_64\&.raw\&.xz \e Fedora\-Cloud\-Base\-37\-1\&.7\&.x86\-64 # systemd\-nspawn \-M Fedora\-Cloud\-Base\-37\-1\&.7\&.x86\-64 # passwd # exit # machinectl start Fedora\-Cloud\-Base\-37\-1\&.7\&.x86\-64 # machinectl login Fedora\-Cloud\-Base\-37\-1\&.7\&.x86\-64 .fi .if n \{\ .RE .\} .PP This downloads the specified \&.raw image with verification disabled\&. Then, a shell is opened in it and a root password is set\&. Afterwards the shell is left, and the machine started as system service\&. With the last command a login prompt into the container is requested\&. .PP \fBExample\ \&3.\ \&Exports a container image as tar file\fR .sp .if n \{\ .RS 4 .\} .nf # machinectl export\-tar fedora myfedora\&.tar\&.xz .fi .if n \{\ .RE .\} .PP Exports the container "fedora" as an xz\-compressed tar file myfedora\&.tar\&.xz into the current directory\&. .PP \fBExample\ \&4.\ \&Create a new shell session\fR .sp .if n \{\ .RS 4 .\} .nf # machinectl shell \-\-uid=lennart .fi .if n \{\ .RE .\} .PP This creates a new shell session on the local host for the user ID "lennart", in a \fBsu\fR(1)\-like fashion\&. .SH "EXIT STATUS" .PP On success, 0 is returned, a non\-zero failure code otherwise\&. .SH "ENVIRONMENT" .PP \fI$SYSTEMD_LOG_LEVEL\fR .RS 4 The maximum log level of emitted messages (messages with a higher log level, i\&.e\&. less important ones, will be suppressed)\&. Either one of (in order of decreasing importance) \fBemerg\fR, \fBalert\fR, \fBcrit\fR, \fBerr\fR, \fBwarning\fR, \fBnotice\fR, \fBinfo\fR, \fBdebug\fR, or an integer in the range 0\&...7\&. See \fBsyslog\fR(3) for more information\&. .RE .PP \fI$SYSTEMD_LOG_COLOR\fR .RS 4 A boolean\&. If true, messages written to the tty will be colored according to priority\&. .sp This setting is only useful when messages are written directly to the terminal, because \fBjournalctl\fR(1) and other tools that display logs will color messages based on the log level on their own\&. .RE .PP \fI$SYSTEMD_LOG_TIME\fR .RS 4 A boolean\&. If true, console log messages will be prefixed with a timestamp\&. .sp This setting is only useful when messages are written directly to the terminal or a file, because \fBjournalctl\fR(1) and other tools that display logs will attach timestamps based on the entry metadata on their own\&. .RE .PP \fI$SYSTEMD_LOG_LOCATION\fR .RS 4 A boolean\&. If true, messages will be prefixed with a filename and line number in the source code where the message originates\&. .sp 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\&. .RE .PP \fI$SYSTEMD_LOG_TID\fR .RS 4 A boolean\&. If true, messages will be prefixed with the current numerical thread ID (TID)\&. .sp 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\&. .RE .PP \fI$SYSTEMD_LOG_TARGET\fR .RS 4 The destination for log messages\&. One of \fBconsole\fR (log to the attached tty), \fBconsole\-prefixed\fR (log to the attached tty but with prefixes encoding the log level and "facility", see \fBsyslog\fR(3), \fBkmsg\fR (log to the kernel circular log buffer), \fBjournal\fR (log to the journal), \fBjournal\-or\-kmsg\fR (log to the journal if available, and to kmsg otherwise), \fBauto\fR (determine the appropriate log target automatically, the default), \fBnull\fR (disable log output)\&. .RE .PP \fI$SYSTEMD_LOG_RATELIMIT_KMSG\fR .RS 4 Whether to ratelimit kmsg or not\&. Takes a boolean\&. Defaults to "true"\&. If disabled, systemd will not ratelimit messages written to kmsg\&. .RE .PP \fI$SYSTEMD_PAGER\fR .RS 4 Pager to use when \fB\-\-no\-pager\fR is not given; overrides \fI$PAGER\fR\&. If neither \fI$SYSTEMD_PAGER\fR nor \fI$PAGER\fR are set, a set of well\-known pager implementations are tried in turn, including \fBless\fR(1) and \fBmore\fR(1), until one is found\&. If no pager implementation is discovered no pager is invoked\&. Setting this environment variable to an empty string or the value "cat" is equivalent to passing \fB\-\-no\-pager\fR\&. .sp Note: if \fI$SYSTEMD_PAGERSECURE\fR is not set, \fI$SYSTEMD_PAGER\fR (as well as \fI$PAGER\fR) will be silently ignored\&. .RE .PP \fI$SYSTEMD_LESS\fR .RS 4 Override the options passed to \fBless\fR (by default "FRSXMK")\&. .sp Users might want to change two options in particular: .PP \fBK\fR .RS 4 This option instructs the pager to exit immediately when Ctrl+C is pressed\&. To allow \fBless\fR to handle Ctrl+C itself to switch back to the pager command prompt, unset this option\&. .sp If the value of \fI$SYSTEMD_LESS\fR does not include "K", and the pager that is invoked is \fBless\fR, Ctrl+C will be ignored by the executable, and needs to be handled by the pager\&. .RE .PP \fBX\fR .RS 4 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\&. .RE .sp See \fBless\fR(1) for more discussion\&. .RE .PP \fI$SYSTEMD_LESSCHARSET\fR .RS 4 Override the charset passed to \fBless\fR (by default "utf\-8", if the invoking terminal is determined to be UTF\-8 compatible)\&. .RE .PP \fI$SYSTEMD_PAGERSECURE\fR .RS 4 Takes a boolean argument\&. When true, the "secure" mode of the pager is enabled; if false, disabled\&. If \fI$SYSTEMD_PAGERSECURE\fR is not set at all, secure mode is enabled if the effective UID is not the same as the owner of the login session, see \fBgeteuid\fR(2) and \fBsd_pid_get_owner_uid\fR(3)\&. In secure mode, \fBLESSSECURE=1\fR will be set when invoking the pager, and the pager shall disable commands that open or create new files or start new subprocesses\&. When \fI$SYSTEMD_PAGERSECURE\fR is not set at all, pagers which are not known to implement secure mode will not be used\&. (Currently only \fBless\fR(1) implements secure mode\&.) .sp Note: when commands are invoked with elevated privileges, for example under \fBsudo\fR(8) or \fBpkexec\fR(1), care must be taken to ensure that unintended interactive features are not enabled\&. "Secure" mode for the pager may be enabled automatically as describe above\&. Setting \fISYSTEMD_PAGERSECURE=0\fR or not removing it from the inherited environment allows the user to invoke arbitrary commands\&. Note that if the \fI$SYSTEMD_PAGER\fR or \fI$PAGER\fR variables are to be honoured, \fI$SYSTEMD_PAGERSECURE\fR must be set too\&. It might be reasonable to completely disable the pager using \fB\-\-no\-pager\fR instead\&. .RE .PP \fI$SYSTEMD_COLORS\fR .RS 4 Takes a boolean argument\&. When true, \fBsystemd\fR 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: "16", "256" 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 \fI$TERM\fR and what the console is connected to\&. .RE .PP \fI$SYSTEMD_URLIFY\fR .RS 4 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 \fBsystemd\fR makes based on \fI$TERM\fR and other conditions\&. .RE .SH "SEE ALSO" .PP \fBsystemd\fR(1), \fBsystemd-machined.service\fR(8), \fBsystemd-nspawn\fR(1), \fBsystemd.special\fR(7), \fBtar\fR(1), \fBxz\fR(1), \fBgzip\fR(1), \fBbzip2\fR(1)