How to manage KVM virtual machines via the command line in Ubuntu 20.04

Louis SanchezAugust 15th 2021, 12:40

In this post, I showed you how to manage virtual machines with virt-manager. This is great if you have a secondary machine with a graphical user interface running Linux as its operating system. But what do you do if such a machine isn't available, and you'd like to perform simple tasks such as rebooting a virtual machine or checking to see which virtual machines are running on the server?

Step 1 : Showing running virtual machines with the virsh list command

virsh list

Step 2 : We can manage the state of our virtual machines with any of the following commands:

virsh start my_vm
virsh shutdown my_vm
virsh suspend my_vm
virsh resume my_vm
virsh destroy my_vm

Step 3 : That's not all virsh can do, however. We can actually create a virtual machine with the virsh suite of commands as well. Learning how to do so is a good idea if you don't use Linux as your workstation operating system, or you don't have access to virt-manager for some reason