So I'm currently trying to get udev to do some things (start airmon-ng) after I've connected a specific USB wifi network card. But I am having troubles getting inline scripts to work. The problem can be reproduced using the following simple example:

Create the following executable script /test.sh:

echo hello > /tmp/test.txt

Create the following file /etc/udev/rules.d/85-auto-monitor.rules:

# This works:
ACTION=="move", KERNEL=="wlx8416f91a5ed3", RUN+="/test.sh"

# This does not work:
# ACTION=="move", KERNEL=="wlx8416f91a5ed3", RUN+="sh -c 'echo hello > /tmp/test.txt'"

Use the following command to reload the .rules file:

sudo udevadm control --reload 

I simply can't understand why the external script works but not the inline one. The inline scripts works if I run it in my terminal.

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Browse other questions tagged or ask your own question.