'\" t
.TH "MACHINECTL" "1" "" "systemd 219" "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)\&.
.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 ("\&.")\&.
.RE
.PP
\fB\-l\fR, \fB\-\-full\fR
.RS 4
Do not ellipsize process tree entries\&.
.RE
.PP
\fB\-\-no\-ask\-password\fR
.RS 4
Do not query the user for authentication for privileged operations\&.
.RE
.PP
\fB\-\-kill\-who=\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\&.
.RE
.PP
\fB\-\-mkdir\fR
.RS 4
When used with
\fBbind\fR
creates the destination directory before applying the bind mount\&.
.RE
.PP
\fB\-\-read\-only\fR
.RS 4
When used with
\fBbind\fR
applies a read\-only bind mount\&.
.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 transfer is complete, but no signatures are verified\&. If
"signature"
is specified, the checksum is verified and the images\*(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\-\-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\-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 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\&.
.RE
.PP
\fB\-M\fR, \fB\-\-machine=\fR
.RS 4
Execute operation on a local container\&. Specify a container name to connect to\&.
.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\-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 "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 container images that can be started, use
\fBlist\-images\fR
(see below)\&.
.RE
.PP
\fBstatus\fR \fINAME\fR\&.\&.\&.
.RS 4
Show terse 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 an 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\&. 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, see below\&.
.RE
.PP
\fBlogin\fR \fINAME\fR
.RS 4
Open an interactive terminal login session to a container\&. This will create a TTY connection to a specific container 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, which then asks for username and password\&. Use
\fBsystemd-run\fR(1)
with the
\fB\-\-machine=\fR
switch to invoke a single command, either interactively or in the background within a local container\&.
.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, similar to the effect of
\fBsystemctl enable\fR
or
\fBsystemctl disable\fR
on the service name\&.
.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\&. 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\-who=\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 directory from the host into the specified container\&. The first directory argument is the source directory on the host, the second directory argument the source directory on the host\&. 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\&.
.RE
.PP
\fBcopy\-to\fR \fINAME\fR \fIPATH\fR [\fIPATH\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\&.
.RE
.PP
\fBcopy\-from\fR \fINAME\fR \fIPATH\fR [\fIPATH\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 the destination path on the host\&. If the destination path is omitted the same as the source path is used\&.
.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 an 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
\fBclone\fR \fINAME\fR \fINAME\fR
.RS 4
Clones a container or disk 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 subvolume images with this command\&. Note that cloning a container or VM image is optimized for btrfs file systems, and might not be efficient on others, due to file system limitations\&.
.RE
.PP
\fBrename\fR \fINAME\fR \fINAME\fR
.RS 4
Renames a container or disk 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 disk 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 disk images\&. The special image
"\&.host", which refers to the host\*(Aqs own directory tree may not be removed\&.
.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 the name 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 via SHA256SUMS and SHA256SUMS\&.gpg files, that need to be made available on the same web server, under the same URL as the
\&.tar
file, but with the last component (the filename) of the URL replaced\&. With
\fB\-\-verify=checksum\fR
only the SHA256 checksum for the file is verified, based on the
SHA256SUMS
file\&. With
\fB\-\-verify=signature\fR
the SHA256SUMS file is first verified with 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 behaviour 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 now 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 the name 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 the downloaded image is in
\&.qcow2
format it es 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
Similar to the behaviour of
\fBpull\-tar\fR, the read\-only image is prefixed with
\&.raw\-, and thus now 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
\fBlist\-transfers\fR
.RS 4
Shows a list of container or VM image downloads that are currently in progress\&.
.RE
.PP
\fBcancel\-transfers\fR \fIID\fR\&.\&.\&.
.RS 4
Aborts download of the container or VM image with the specified ID\&. To list ongoing transfers and their IDs, use
\fBlist\-transfers\fR\&.
.RE
.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
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
.\}
A subvolume (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 it\*(Aqs
\fB\-\-directory=\fR
and
\fB\-\-image=\fR
options\&.
.SH "EXAMPLES"
.PP
\fBExample\ \&1.\ \&Download an 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 service\fR
.sp
.if n \{\
.RS 4
.\}
.nf
# machinectl pull\-raw \-\-verify=no http://ftp\&.halifax\&.rwth\-aachen\&.de/fedora/linux/releases/21/Cloud/Images/x86_64/Fedora\-Cloud\-Base\-20141203\-21\&.x86_64\&.raw\&.xz
# systemd\-nspawn \-M Fedora\-Cloud\-Base\-20141203\-21
# passwd
# exit
# machinectl start Fedora\-Cloud\-Base\-20141203\-21
# machinectl login Fedora\-Cloud\-Base\-20141203\-21
.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\&.
.SH "EXIT STATUS"
.PP
On success, 0 is returned, a non\-zero failure code otherwise\&.
.SH "ENVIRONMENT"
.PP
\fI$SYSTEMD_PAGER\fR
.RS 4
Pager to use when
\fB\-\-no\-pager\fR
is not given; overrides
\fI$PAGER\fR\&. Setting this to an empty string or the value
"cat"
is equivalent to passing
\fB\-\-no\-pager\fR\&.
.RE
.PP
\fI$SYSTEMD_LESS\fR
.RS 4
Override the default options passed to
\fBless\fR
("FRSXMK")\&.
.RE
.SH "SEE ALSO"
.PP
\fBsystemd-machined.service\fR(8),
\fBsystemd-nspawn\fR(1),
\fBsystemd.special\fR(7)
