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
[/sourcecode]

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
[/sourcecode]

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)
[/sourcecode]
Happy controlling!

About Author

Related Posts

php8 gd

PHP8 gd Activate after installation

PHP8 GD activate after installation. GD doesn’t get activated by default. Not even a reboot after installation will activate it. So how do we do it? In…

Debian 12: linux-image-6.1.0-10amd64

Troubleshooting dependency issues in Debian 12: Resolving linux-image-6.1.0-10amd64 package dependency problems. If you installed the Debian 12 from the live image the issue is the raspi-firmware. Even…

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…

Leave a Reply