Last Updated: April 19, 2016
· fginez

Finding out "who" is using a serial port preventing you from using it @linux

Sometimes, specially when developing embedded software or hardware focused software, you may face some problems such as "unable to connect to /dev/ttySx or /dev/ttyACMx" serial port. So, the main question is: how to quickly find out who is using the serial port?

In the following example we are looking for which process is using our /dev/ttyS0 (COM1). To do this, we can use the lsof command.

lsof /dev/ttyS0

lsof output

The command output tell us that process id 9238 is using our port. We can now politely try to terminate it, or use extreme ways such as the kill command.

I hope this information may help you!