$linuxjunkies
>

machinectl(1)

Control the systemd machine registry and manage virtual machines and containers.

UbuntuDebianFedoraArch

Synopsis

machinectl [OPTIONS...] COMMAND [ARGS...]

Description

machinectl is used to introspect and control the state of virtual machines and containers registered with systemd-machined. It can list running machines, check their status, start and stop them, and access their consoles or shells.

The tool operates on machines registered with systemd's machine manager, which includes VMs managed by systemd-nspawn, libvirt, and other container runtimes that integrate with systemd.

Common options

FlagWhat it does
-a, --allshow all machines, including those not running
-p, --property=NAMEshow specific properties of machines
-M, --machine=NAMEoperate on the specified machine
-n, --lines=INTEGERnumber of journal lines to show (default 10)
--no-pagerdo not pipe output into a pager
-l, --fulldo not truncate output
--output=FORMAToutput format: table, tree, json, or json-seq
-q, --quietsuppress informational messages
--no-legenddo not print header and footer

Examples

list all registered machines and their status

machinectl list

show detailed status of a specific container

machinectl status mycontainer

start a registered machine or container

machinectl start mycontainer

stop a running machine gracefully

machinectl stop mycontainer

open an interactive shell in the specified machine

machinectl shell mycontainer

open an interactive login session in the machine

machinectl login mycontainer

list all machines including stopped ones in JSON format

machinectl list -a -o json

copy a file into a running machine

machinectl copy-to mycontainer /tmp/file /root/

Related commands