Linux – Start, stop and reboot your KVM guests from command line

virtual-desktop-2-iconI prefer using a gui when controlling my virtual machines. Learning how to control them in the most basic way from the command line or terminal is easy. It is very self explanatory once you know about the virsh command. I have made some examples below on how to use these commands.

Here is the list of basic commands to start, stop and reboot your virtual machines.

List your running guests

virsh list
[sourcecode language=”text”]
Id Name State
2 apt-cacher.home running

List all guests:

virsh list –all
[sourcecode language=”text”]
Id Name State
2 apt-cacher.home running
– db1.home shut off
– db2.home shut off
– devlab.home shut off
– minecraft.home shut off
– vault.home shut off
– web.home shut off

To start a vm

we can only use their vm name to start them.
virsh start db1.home

To reboot a vm

We can use name or id to reboot the vm.
virsh reboot 2
virsh reboot apt-cacher.home

To stop or shutdown a vm

virsh shutdown 2
virsh shutdown apt-cacher.home

To shutdown or stop an unresponsive or crashed vm

virsh destroy 2
virsh destroy apt-cacher.home

To get information about your vm

virsh dominfo 2
virsh dominfo apt-cacher.home
[sourcecode language=”text”]
Id: 2
Name: apt-cacher.home
UUID: f194bb17-5f0e-21f5-f712-8a98edd4f1d8
OS Type: hvm
State: running
CPU(s): 1
CPU time: 332.8s
Max memory: 262144 KiB
Used memory: 262144 KiB
Persistent: yes
Autostart: enable
Managed save: no
Security model: apparmor
Security DOI: 0
Security label: libvirt-f194bb17-5f0e-21f5-f712-8a98edd4f1d8 (enforcing)
Happy controlling!

Related Posts

4 Best Free Nas Software That Is Open Source

Free NAS software or operating systems that are free to use and will turn a computer into a NAS more advanced than the dedicated boxes sold. What…

Raspbian default password

Raspbian default password

Looking for the Raspbian default password? It is the most essential username and password that you will need for your raspberry. At least if you are running…

OpenMediaVault default password

OpenMediaVault default password

OpenMediaVault default password is printed in the documentation. I did not see it the first time I installed it either. So I had to do some detective…

Debian change dns

Debian change DNS settings to a new DNS

Debian change DNS settings for speed improvement or privacy. It is really easy to do. So let us see how it’s done and get to it. The…

Upgrade debian 9 to debian 10

Upgrade Debian 9 to Debian 10

Upgrade Debian 9 to Debian 10 is very similar to upgrading previous versions. The only you need to do is change the sources to Buster instead of…

Debian 10 Static IP

Debian 10 Static IP

Debian 10 static IP works just like the previous version. They changed the naming of the network interfaces in Debian 9. However if you have upgraded from…

Leave a Reply