Interacting With a KVM VM as an Unprivileged User¶
For a single unprivileged user to be able to execute KVM-related commands without sudo, the following steps must be performed:
-
Add the unprivileged user to the
libvirtgroup by executing the following command:sudo usermod -aG libvirt username -
When logged in as the unprivileged user, run the following:
export LIBVIRT_DEFAULT_URI="qemu:///system"
Tip
This change is not persistent when logging out or restarting the system. To make it persistent, add the export LIBVIRT_DEFAULT_URI="qemu:///system" command to the ~/.bashrc file. This way, the command will be executed each time the user logs in to the system.