In addition to @zengr's answer above, for this those running into Device or resource busy
when using this Ralink RT5370 dongle, i.e.:
~ $ sudo iwconfig wlan0 mode Monitor
Error for wireless request "Set Mode" (8B06) :
SET failed on device wlan0 ; Device or resource busy.
There is, PCMIIW, [no generic way][1] to find out which process is using device wlan0
, but chances are it's ifplugd
:
[1]: https://unix.stackexchange.com/questions/165697/how-to-kill-processes-using-a-network-interface)
~ $ service ifplugd status
...
[...] wlan0: ifplugd process for device wlan0 running as pid 1234
~ $ sudo ifplugd -k -i wlan0 # kill ifplugd for wlan0
~ $ sudo ifconfig wlan0 down # iFconfig
~ $ sudo iwconfig wlan0 mode Monitor # iWconfig
~ $ sudo ifconfig wlan0 up
~ $ iwconfig
wlan0 IEEE 802.11bgn Mode:Monitor Frequency:2.412 GHz Tx-Power=20 dBm
Retry short limit:7 RTS thr:off Fragment thr:off
Power Management:off