How to fix Incus Error: You don't have the needed permissions to talk to the incus daemon

Problem

When you try to run an incus command such as

incus image list

you see an error message such as

Error: You don't have the needed permissions to talk to the incus daemon (socket path: /var/lib/incus/unix.socket)

or

Error: Get "http://unix.socket/1.0": dial unix /var/lib/incus/unix.socket: connect: permission denied

Solution 1: Preferred:

Add your user to the incus-admin group:

sudo usermod -aG incus-admin $USER

You need to log out and back in for the group change to take effect.

Solution 2: Workaround:

Run the command as root:

sudo incus image list

This works since the root user has access to the incus daemon by default.