Error loading code onto Arduino UNO board

I'm on Linux Manjaro and when I press the button on the IDE to upload the code to the Arduino UNO board I get this error:

avrdude: ser_open(): can't open device "/dev/ttyACM0": Permission denied

I tried to fix the problem using the following command:

sudo chmod a+rw /dev/ttyACM0

except that after a few hours the initial problem returns and I don't feel like running this command every time.

Arduino IDE version: 2.2.1

Is your user a member of the dialout group?

If I use the command ls -l /dev/ttyACM0 I get this:

crw-rw-rw- 1 root uucp 166, 0  9 ott 00.49 /dev/ttyACM0

so the correct group should be uucp but I tried using the command sudo usermod -a -G uucp $USER and it still doesn't work correctly. (Now there are the right permissions because I used the command sudo chmod a+rw /dev/ttyACM0)

Did you log out and back in again after adding your user to the group?

I just tried it and it seems to work, thanks so much for the help!