← Back to blog
bpdubuntu
Managing VMs with `virsh`: The Ultimate Command-Line Tool
23 January 2026bpd · ubuntu
Script and Automate Every Aspect of Your Virtual Machines
For powerful, scriptable control over your KVM virtual machines, the ‘Ubuntu System Administration Guide’ introduces `virsh`. This command-line interface is the backbone of KVM management and allows you to perform any task you could do in the graphical interfaces, and more.
Common `virsh` Commands
With `virsh`, you can:
- List all running or defined VMs (`virsh list –all`).
- Start, stop, and reboot VMs (`virsh start vm-name`).
- Connect to a VM’s console (`virsh console vm-name`).
- Create and revert to snapshots.
- Clone existing VMs to create new ones.
Because `virsh` is a command-line tool, you can easily incorporate these commands into shell scripts to automate complex workflows, such as creating a new VM, provisioning it, and then taking a snapshot, all without any manual intervention.
This post is based from content of the book Ubuntu System adminstration guide. And the book can be found here https://www.amazon.com/stores/Mattias-Hemmingsson/author/B0FF5CQX13