Путеводитель по Руководству Linux

  User  |  Syst  |  Libr  |  Device  |  Files  |  Other  |  Admin  |  Head  |



   machinectl    ( 1 )

управляйте системным менеджером машины (Control the systemd machine manager)

Примеры (Examples)

Example 1. Download an Ubuntu image and open a shell in it

# 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

This downloads and verifies the specified .tar image, and then uses systemd-nspawn(1) to open a shell in it.

Example 2. Download a Fedora image, set a root password in it, start it as a service

# machinectl pull-raw --verify=no \ https://download.fedoraproject.org/pub/fedora/linux/releases/34/Cloud/x86_64/images/Fedora-Cloud-Base-34-1.2.x86_64.raw.xz \ Fedora-Cloud-Base-34-1.2.x86-64 # systemd-nspawn -M Fedora-Cloud-Base-34-1.2.x86-64 # passwd # exit # machinectl start Fedora-Cloud-Base-34-1.2.x86-64 # machinectl login Fedora-Cloud-Base-34-1.2.x86-64

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.

Example 3. Exports a container image as tar file

# machinectl export-tar fedora myfedora.tar.xz

Exports the container "fedora" as an xz-compressed tar file myfedora.tar.xz into the current directory.

Example 4. Create a new shell session

# machinectl shell --uid=lennart

This creates a new shell session on the local host for the user ID "lennart", in a su(1)-like fashion.