I am running Ubuntu Server 20.04.02 LTS in my RPi 4b. I ran into the problem that I couldn't access the GPIO without sudo/root with my python scripts so I changed the /dev/gpiomem group ownership to my user's groups with
sudo chown root:$USER /dev/gpiomem
and allowed read and write access to /dev/gpiomem with
sudo chmod g+rw /dev/gpiomem
which solved the problem. However once I reboot these changes somehow get undone and I have to redo them in order to run my code without root access. Can someone help me with this? Thanks!