Skip to content

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:

  1. Add the unprivileged user to the libvirt group by executing the following command:

    sudo usermod -aG libvirt username

  2. 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.