Compile error in Ubuntu 18.04
This is likely a permission problem.  The user likely does not have permission to read from and write to the port created when plugging in the Arduino.  This can be temporally fixed using the following command:

sudo chmod 666 /dev/ttyACM0


However, this procedure is only temporary as the port is recreated every time the Arduino is reconnected to the computer.  And upon recreation the permissions are reset to their defaults for security reasons.

A better solution is to determine the group which the port belongs to and to add the users expected to access these connected devices to that group.  

Plugin and list the port to determine its group:

ls -l /dev/ttyACM*


or

ls -l /dev/ttyUSB*


The group the ports belong to will likely be "dialout".  Add the user to that group:

usermod -a -G dialout user_name


...where user_name is replaced by the name of the user who needs access to the port.  If you don't know the name of the current user you can use this command:

whoami