Use virt-manager as a non-root user on Linux
First check if group already exist, if not create it
sudo getent group | grep libvirt
If it doesn’t exist, add it as a system group.
sudo groupadd --system libvirt
Add your user account to the group and log onto that group (without logging off and back onto the machine)
sudo usermod -a -G libvirt $(whoami)
newgrp libvirt
Verify that user is added to libvirt group.
$ id $(whoami)
uid=1000(myusername) gid=1000(myusername) groups=1000(myusername),10(wheel),982(libvirt)
Open the file /etc/libvirt/libvirtd.conf for editing.
sudo vim /etc/libvirt/libvirtd.conf
Set the UNIX domain socket group ownership to libvirt – by removing the # at the begining of the following line
unix_sock_group = "libvirt"
Set the UNIX socket permissions for the R/W socket – by removing the # at the begining of the following line
unix_sock_rw_perms = "0770"
Restart libvirt daemon after making the change.
sudo systemctl restart libvirtd.service
Check service status.
$ systemctl status libvirtd.service
● libvirtd.service - Virtualization daemon
Loaded: loaded (/usr/lib/systemd/system/libvirtd.service; enabled; vendor preset: disabled)
Active: active (running) since Fri 2019-04-19 08:48:13 EAT; 1h 16min ago
Docs: man:libvirtd(8)
https://libvirt.org
Main PID: 31709 (libvirtd)
Tasks: 26 (limit: 32768)
Memory: 64.7M
CGroup: /system.slice/libvirtd.service
├─ 754 /usr/bin/dnsmasq --conf-file=/var/lib/libvirt/dnsmasq/default.conf --leasefile-ro --dhcp-script=/usr/lib/libvirt/libvirt_leases>
├─ 755 /usr/bin/dnsmasq --conf-file=/var/lib/libvirt/dnsmasq/default.conf --leasefile-ro --dhcp-script=/usr/lib/libvirt/libvirt_leases>
├─ 777 /usr/bin/dnsmasq --conf-file=/var/lib/libvirt/dnsmasq/docker-machines.conf --leasefile-ro --dhcp-script=/usr/lib/libvirt/libvir>
├─ 778 /usr/bin/dnsmasq --conf-file=/var/lib/libvirt/dnsmasq/docker-machines.conf --leasefile-ro --dhcp-script=/usr/lib/libvirt/libvir>
├─25924 /usr/bin/dnsmasq --conf-file=/var/lib/libvirt/dnsmasq/vagrant-libvirt.conf --leasefile-ro --dhcp-script=/usr/lib/libvirt/libvir>
├─25925 /usr/bin/dnsmasq --conf-file=/var/lib/libvirt/dnsmasq/vagrant-libvirt.conf --leasefile-ro --dhcp-script=/usr/lib/libvirt/libvir>
├─25959 /usr/bin/dnsmasq --conf-file=/var/lib/libvirt/dnsmasq/fed290.conf --leasefile-ro --dhcp-script=/usr/lib/libvirt/libvirt_leasesh>
├─25960 /usr/bin/dnsmasq --conf-file=/var/lib/libvirt/dnsmasq/fed290.conf --leasefile-ro --dhcp-script=/usr/lib/libvirt/libvirt_leasesh>
└─31709 /usr/bin/libvirtd
Start Virtual Machine Manager from the command line or your Start menu.
$ virt-manager
You should be able to create a VM without getting a permission error.
Tested on Rocky 8, Rocky 9 and Fedora 39