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!
/dev
aren't real files. They only exist in memory, which is to say, when the system is running. When you (re)boot, the kernel creates them appropriately (we hope). So you have to automate the change you want.