TIP: Serial port locked while using minicom
I general use the program minicom to use my serial ports in Debian Linux. Many program including the likes of X server, create a “temporary lock” file in some of the temporary directory in Linux like /tmp or /var/tmp/, so that there is no access violation in case if another user is trying to use the same program. Many times these program have to be quit or exited in an un-graceful fashion as a result of which the “temporary lock” file is never deleted. While using minicom, you may have seen messages like the following:
# minicom
Device /dev/ttyS0 is locked.
No matter what you try, you still get the same message. This usually happens when your terminal window quits unexpectedly or it hangs for some reasons. In such a case the minicom program does not exits graciously and hence the temporary locked file is not delete.
Solution
The easiest way to resolve this problem is to give the following command:
# rm /var/tmp/LCK..ttyS0
Basically what we are doing above is manually removing the temporary lock file. Now you can start using your minicom program as you would do normally. The name of the temporary lock file might differ on your system but it should generally start with “LCK” and should will “ttyS<n>” somewhere in it’s name.
Please report if your experience have been different and I will update this post.


Email Subscription









December 4th, 2009 at 2:07 am
sir
i am facing problem to installing minicom on ubuntu os .
problem 1 : Device /dev/ttyS0 is locked.
so solve this problem i type this command.
# rm /var/tmp/LOCK..ttyS0
then i got one more problem .
cannot remove `/var/tmp/LOCK..ttyS0′: No such file or directory
SO Please help me
Reply to this comment
siskalandre Reply:
April 17th, 2010 at 1:11 am
please change your command to
#rm /var/lock/LOCK..ttyS0
Reply to this comment
May 12th, 2010 at 4:40 am
you can also try just for
pkill minicom
Reply to this comment
July 12th, 2010 at 1:03 pm
[...] error is the result of a lock file hanging around. If you don’t know the location of the lock file, it might be helpful to check your local [...]
September 16th, 2011 at 3:46 pm
pkill minicom worked for me.
Reply to this comment
December 6th, 2011 at 7:46 pm
I have a permanent lock file created in /usr/lock, how to remove that?
Reply to this comment
December 15th, 2011 at 4:58 am
pkill minicom works fine.
My terminal quit unexpectedly so my devices were locked, but pkill solved it
Reply to this comment
February 21st, 2012 at 9:24 am
Thanks. Informative although I’m using Fedora 16, it explains and gives me some ideas of approaching the problem therein. Cheers, Sanders
Reply to this comment
March 30th, 2012 at 2:04 pm
type
1 sudo minicom -s
2 select serial port setup
3 press
4 press b to select row B – Lockfile Location
5 change /var/lock to /var/unlock
6 press
7 select Exit (not Exit from minicom)
8.best wishes
Reply to this comment
October 7th, 2012 at 2:08 am
I have a similar problem. I have removed everything in my /var/lock and /temp/lock. But it still gives error
Device /dev/ttyUSB0 lock failed: No such file or directory.
I have tried everything that was mentioned so far. What I am wondering is, is there a way that I can just completely remove minicom including the previous settings and reinstall completely fresh
Reply to this comment
May 8th, 2013 at 7:18 am
if
/ttyS0 is locked…
try
pkill minicom.log
Reply to this comment