Solving Arduino IDE upload problem, and serial monitor error on Ubuntu

Update: The same applies to arduino 1.8.9, on Ubuntu 18.04 LTS...
Clarification: This applies to downloaded arduino IDE not the one installed from software center! The one in the software center may be outdated, and I know there's probably a ppa repository that contains the lastest, but I found it easier to just download and run it, and have all the files in one easily accessible place since I may wanna look into the source code occasionally...

Can't upload sketch

I've just downloaded the current latest version of arduino IDE(1.8.5), and unpacked, configured it to my serial programmer and arduino pro-mini, and tried uploading the blink example to test it but it couldn't...
It doesn't matter if I just run, or run the install.sh first(with or without sudo), then run it, it just doesn't work!
It produces this output: (If you launch the arduino IDE from terminal, you get the same message in the terminal as in the IDE, it's just easier to show as the terminal is not limited to a few lines.)

or with verbose output enabled:

I've tried running arduino with sudo in fromt I get this message:

So I've took a look at the verbose output, and I see this:
/home/rpbcacueaiibh/Programs/arduino-1.8.5/hardware/tools/avr/bin/avrdude -C/home/rpbcacueaiibh/Programs/arduino-1.8.5/hardware/tools/avr/etc/avrdude.conf -v -patmega328p -carduino -P/dev/ttyUSB0 -b57600 -D -Uflash:w:/tmp/arduino_build_168730/Blink.ino.hex:i
and I've checked the permissions of the "avrdude" file, and I found this:

The "avrdude" file that the IDE was executing to upload the script can't access the USB port as it is owned by me, and executed as me.

The solution lies in making the "avrdude" file owned by "root" and setting permission to 4755 so that the file gets executed as root whenever "avrdude" is called.
to do that you need to be a sudo user and run the following commands:
- Enter the directory in which the avrdude file is located: cd Programs/arduino-1.8.5/hardware/tools/avr/bin
- Make avrdude owned by root: sudo chown root:root avrdude
- Make it execute as root: sudo chmod 4755 avrdude
- Check it with: ls -l
It should look like this:

Now try again it should work now.

Seial monitor can't open ttyUSB0

Now check the serial monitor that also tends to not work.
This is a common problem: Error opening serial port '/dev/ttyUSB0'. Try consulting the documentation at http://playground.arduino.cc/Linux/All#Permission
By default even as a super user you're not a member of the dialout group, therefore arduino can't use ttyUSB0 unless you start it with sudo in front.
If your username is not on the dialout list that you can check with this command: grep dialout /etc/group
Then add yourself with this command: sudo usermod -a -G dialout yourusername
Reboot to load the new config then check again the serial monitor.

Suggestion(s)

You may also be interested in my Arduino-DataLink project! - A very light weight terminal option for serial communication with your arduino, which works even without the Arduino IDE installed.
          --> It can be interfaced with your own program for communicating with an arduino.
          --> It's also the only thing I know capable of receiving a continuous stream of data on a raspberry pi even at 115200 baud rate without freezing.

SVG Arrow SVG Sun
Open Source Research Center
Research In Progress . . .