is there any shell command, can let me know, current open device or device already in operation.

For example, I use minicom to open a device /dev/ttyUSB0 or /dev/ttyS0, after I use program open this device, how can I check it under shell it already open? I tried dmesg but seems doesn't work for me


lsof <your devices> to show the processes that use your device. or strace -p pid to trace a process that you know is supposed to use your device.


Block devices

The examples given in the question are not block devices, but the question is asked generically, so if yours is a block device, use:

badblocks -n -c1 /dev/device-name 0 0

This will try to do a non-destructive re-write of the first 1024 bytes of the device

If it's in use, you'll see:

/dev/device-name is apparently in use by the system; it's not safe to run badblocks!

I think lsof is the tool that should be used for. It will list all the files that are being used by a process.

May be fuser can also be used if you want do not know the process id.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.