Install the Arduino IDE in Ubuntu 12.04

Installing the Arduino IDE in Ubuntu only takes a few minutes. As usual, it’s a better idea to install the Arduino straight from the source, instead of relying on the version in Ubuntu’s repository. While it wasn’t hard to install the Arduino IDE, I noticed that the Arduino GUI was really slow and laggy. This is because the startup script tells Java to use Ubuntu’s GTK look and feel, which makes everything run slowly. It’s easily fixed by changing a single line in the startup script.

Update: In the Arduino 1.0.1 update, “Serial Port” is greyed out. The fix is outlined in the troubleshooting section.

Install the Arduino IDE in Ubuntuarduino logo

  1. Install gcc-avr, avr-libc and openjdk-6-jre if you don’t have it already.
  2. Plug in the board, see where it’s connected
  3. Download and unpack the Arduino IDEtarball
  4. Run the IDE
  5. Select your board model and serial port
  6. Run a sample program
  7. Fix the buggy interface (optional)
  8. Troubleshooting

Everything worked out of the box, other than the interface.

Install gcc-avr and avr-libc

Gcc-avr and avr-libc give your system the tools it needs to compile c into AVR machine code:

If you don’t have openjdk-6-jre already, install and configure that too:

Once those are installed plug in your board and type  $ dmesg . It will print the kernel’s ring buffer and show you what USB port your Arduino is plugged into:

According to dmesg, our board is plugged into ttyACM0.

Download and Run the Arduino IDE

Go to the downloads page on Arduino’s download page to get the latest Arduino IDE tarball (.tgz file) for your architecture. My laptop is 64-bit, so I chose accordingly. Once the file was finished downloading, I unzipped and ran it with the following command:

./arduino launches the Arduino IDE.

Select your board model and serial port

I’m using an Arduino MEGA 2560, so I went to Tools>Board>”Arduino Mega 2560 or Mega ADK.” At this point, I noticed that the GUI was really slow and hard to use. If you want to fix it before proceeding, exit the IDE and skip to the  ”Fixing the Interface” section before proceeding.

The IDE flashed an error about how my board wasn’t accessible over the COM1 port. COM1 usually refers to a 9-pin serial port, and my laptop doesn’t even have one. I went to Tools>Serial Port and selected /dev/ttyACM0, which reflected the output I saw when I checked dmesg.

The errors went away, and I went to File>Examples>Basics>Blink and clicked upload. Sure enough, the LED started blinking. You should be ready to start writing and running Arduino programs!

Fix the Arduino IDE to make it run more smoothly in Ubuntu

Exit the Arduino IDE and go to the installation folder (the folder you unzipped from the .tgz file). Edit the “arduino” script in your favorite text editor. To make Arduino use the native Swing windowing instead of forcing the GTK look and feel, which is the cause of the bugginess, change the following line:

Just delete the -D flag and its argument. Personally, I get nostalgic about the old-school Swing look and feel, but either way, it fixed all of the lagginess issues I was experiencing.

install arduino in ubuntu

My Arduino IDE, running in Ubuntu (using SWT instead of GTK)

Troubleshooting USB and the grayed out Serial Port

When I got the Arduino 1.0.1 update, “Serial Port” was grayed out in the tools menu. Running arduino as root ( sudo ./arduino) resolved the issue, but it’s not an acceptable solution. In my case, serial port was grayed out because my user didn’t have permission to read and write to the device.

I added my user to the dialout group with the command  sudo usermod -a -G dialout mark . Usually, that would have fixed it but iserial port was still grayed out.

Changing the permissions on /dev/ttyACM0 to world readable and writeable fixed the grayed out serial port. I ran  sudo chmod a+rw /dev/ttyACM0 and the serial port menu worked again.

I’ve noticed that running programs that send lots of data over USB can cause issues with the arduino programming software, making it give errors while uploading code. Holding down the reset button fixed my upload and USB errors in most cases.

Further Reading

If you read nothing else before you start writing programs, look at the official Arduino Reference page. It might be the most concise, complete language reference I’ve ever seen.

Also take a look at DIY Drones.

Incoming search terms:

46 thoughts on “Install the Arduino IDE in Ubuntu 12.04

  1. Thanks a lot! I couldn’t make my arduino interface work with GTK/ Ubuntu! That’s such a relief.

  2. Thank you very much, mark, for your help. I was able to fix the USB port access. Great!
    Thanks also to Reppad for his advice on the dangers of the command “usermod-G dialout”

    Thanks to all

  3. I did it twice …. And couldn’t come back because I didn’t know why it was doing so !
    Thanks for explaining this issue

  4. Hi.
    Run ./arduino , serial port is not grayed, but getting error
    avrdude: stk500v2_ReceiveMessage(): timeout
    avrdude: stk500v2_getsync(): timeout communicating with programmer

    If run sudo ./arduino works successful.

  5. Thanks very much for this – my Arduino Uno is now working perfectly with ubuntu.

  6. Thanks alot! I was trying to get my usb port to work and couldn’t figure it out. I’m gonna post your site on lifehacker

  7. Ieeee, i needed to make a symbolic link

    sudo ln -s /dev/ttyACM0 /dev/ttyUSB0

    I think that is because the RXTX library that i’m using. I’m using a different one than the Arduino IDE because i needed for work with java communication.

    Hope that this will be usefull for somebody!

  8. Thank you for this. All the other “tutorials” about this problem were essentially gibberish.

  9. The serial port for me was still grayed out even after adding the username to dialout so after some Internet searching I discovered if you add the username to the “uucp” group and then log out and back in, the serial port works as it should.

  10. The grayed out Serial Port might also be due to a stale lock file: You can get a hint by starting the Arduino IDE from a command promt – any error messages will show up here.
    Lock files are created in /var/lock/ and are named like LCK..ttyUSB0 after the tty device they are locking (/dev/ttyUSB0 in my case).

    If you find a lock file in /var/lock named like the port your Arduino board normally uses (use dmesg as shown above), simply delete the file (requires root access). In my case:

    sudo rm /var/lock/LCK..ttyUSB0

    Thans to all for making Arduino real!

  11. The Leonardo causes, say, /dev/ttyACM0 to be recreated after each reset, so using a udev rule such as

    ATTRS{product}==”Arduino Leonardo”, MODE=”0666″

    in a file like /etc/udev/rules.d/10-local.rules

    was necessary for me.

  12. You are a lifesaver! I had to adapt your instructions, though, as of this writing. I merely installed the Arduino IDE from the Ubuntu Software Center, ran dmesg, and then fixed the grayed-out Serial Port option in the menu. But you saved me hours of troubleshooting!

  13. Muchas Gracias !!
    casi que no puedo lograr q el arduino leyera los puertos !!
    saludos desde Colombia

  14. Pingback: Install Arduino IDE in Ubuntu | Simon Bennett

  15. Pingback: Ciao, Mondo | Pkafei: Grown Women Open Source

  16. Thank you for this, I was freaking out when the serial port was grayed out. But after reading, your tutorial I was able to move on to bigger and worthier problems. Your explanation was so good that I included a link to this page on my blog.

  17. Aaaaawesome tutorial. The greyed out serial port was bugging me, but luckily its resolved now! Thank you so much :)

  18. Thanks so much.  Got the LED blinking in just a few minutes.  I installed the Arduino IDE from the software center in Ubuntu 12.10.  Best regards.


  19. Excellent, helped out immensely with solving the ‘greyed out’ Serial Port on Ubuntu btw

  20. Hello.

    I have spent all day trying to fix this. I ran into the stale lock error while trying to get RXTX to work with Eclipse. This post has been the most useful resource and now my IDE is back up and serial comm is working just fine. Thanks.


  21. Great post.  Thanks for all the useful info.

    There is at least one potential thing to add: 64-bit machines do not like the Beta software without another library at least “ia32-libs” or something else must be used.  I found this explanation for using ia32-libs:

    (You can just jump to the bottom of the post for explanation. >> )

    Bottom line: I was working on a totally fresh Ubuntu 12.04 and arduino IDE install (both installed that day)  and got the exact same error as the person on that forum.  The 64-bit Beta Arduino for Due will not work without a library to aid the cross-compiler. The IDE refused to compile to DUE.  The ia32-libs fixed it…but at a price of crashing during install from Synaptic and I’m going to redo everything just to see if I can get ia32-libs installed without crashing.  It makes other system changes on install (according to Synaptic).

    Your guide here is absolutely fantastic.  It’s the concisest and simplest explanation I’ve found for working with Arduino on 12.04 Ubuntu on 64-bit…and does a great job.  Thanks a million for sharing it.

  22. después de que se ejecutan las lineas para el puerto serial, solo queda reiniciar el equipo. MUCHAS GRACIAS

  23. Thanks a lot Sir.

    I was having hard time setting up mu Ubuntu with FTDI. This cleared up a lot of things.


  24. Hi,

    I don’t think the installation of avr-libc and gcc-avr is mandatory.

    I have issues to compile some code and, while trying to solving them, I removed those packages : the IDE didn’t complaint at all.

    Inside the installation directory (../hardware/tools/avr/bin),  there are the shell scripts used, I guess.

    I have ubuntu 12.04 and IDE 1.0.5.
    Now, for those interested in my compiling problems, you can check and try to save my day   week ^^

  25. Another thankful visitor here, running Ubuntu 12.04 LTS with Trinity desktop. Couldn’t get Arduino to run at all until that GTK line was edited out.