Reputation: 1127
I was playing around with a router earlier this evening using minicom and I must not have closed it cleanly. Here is the error message that I get when I try to open minicom:
device /dev/ttyusb0 lock failed: operation not permitted
I have two questions, 1) how would I go about getting out of this state, and 2) how do I exit minicom cleanly so that I can avoid this happening again.
Upvotes: 12
Views: 66452
Reputation: 376
The canonical way is to use lockdev. This manages the lock files on a per-device basis in /run/lock/lockdev/
(at least under CentOS 7.x).
lockdev <device>
can be used without being root, and returns non-zero if the device has already been locked, in which case it can be unlocked with lockdev -u <device>
.
This is apparently obsolete these days, but minicom
(at least as of version 2.6.2) still uses it.
Upvotes: 0
Reputation: 41
/dev/ttyUSB0: 18328
Upvotes: 4
Reputation:
I ran into a similar issue with using gtkterm
from a remote terminal. I had shutdown the terminal without explicitly terminating gtkterm
. The result was that subsequent gtkterm sessions gave me the error:
Device /dev/ttyUSB0 is locked.
Checking the process list via ps
did not show any gtkterm
processes still running.
I corrected this by simply deleting /run/lock/LCK..ttyUSB0
. After doing that, gtkterm was able to open ttyUSB0 successfully.
Upvotes: 10
Reputation: 276
I found I was able to fix the situation on my CentOS box by running minicom -S <device> -o
and the do the normal exit key sequence (CTRL-a, x).
In your situation it would have been
sudo minicom -S ttyusb0 -o
This cleared the lock files minicom had placed in /var/lock/
Good luck Ash
Upvotes: 26