Arduino IDE error avrdude

I realize that in Ubuntu 14.04 and when I want to compile in the arduino sketch I get this little error

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

To fix this we do the following:

sudo usermod -a -G dialout $USER (1)
sudo chmod a+rw /dev/ttyACM0 (2)
1 Add our user to the dialout group
2 Permissions to all users thanks to parameter a, plus read(r) and write(w) for port ttyACM0

then reboot and it should work.