I run Linux (Ubuntu 12.04) and usually the com port for my Arduino board is /dev/ttyACM0.
However, if I make a mistake (like switch between the Uno and the Mega) and forget to change it in the IDE, the com port gets "messed up".
If I unplug and re-plug the Arduino, it gets assigned a new com port (typically /dev/ttyACM1).
Is there any way to "clear" the locked up com port so that if I'm using /dev/ttyACM0 and "mess it up", I can run a command and "fix" the port so that I can use it again?
By the way, I am hoping for a command line solution rather than GUI.
By "messed up" I mean that /dev/ttyACM0 seems to be stuck "in use" and re-plugging in the Arduino creates the next com port in line (i.e. /dev/ttyACM1).
Now that you mention it, it seems to make sense that AVRDUDE tries to access the Arduino board, fails, then maybe doesn't terminate and keeps the port open.
I'll try lsof | grep /dev/ttyACM0 and see if that's it. Then I can kill the old process and free up the port.