{"id":"640f3c66-266c-426b-b476-e839d7c021fc","task":"Write a udev rule that runs a custom script automatically when a specific device is plugged in on Linux","domain":"man7.org","steps":["Identify the device's matching attributes (SUBSYSTEM, KERNEL name, vendor/product IDs, etc.) with a device inspection tool such as udevadm info, so the rule matches only the intended device.","Create a new rule file under /etc/udev/rules.d/ (local, admin-authored rules take precedence over vendor-shipped rules under /usr/lib/udev/rules.d/), naming it so its lexical order runs where intended.","Write a match line combining fields such as SUBSYSTEM== and ACTION==, plus device identifier fields, followed by a RUN+= assignment pointing at the script to execute.","Make the target script executable and give it a proper shebang, since udev does not execute RUN targets inside a shell or terminal context and expects a directly runnable program.","Reload the rules with `udevadm control --reload-rules` and re-trigger with `udevadm trigger`, then test by re-plugging the device and checking `udevadm monitor` or the system journal to confirm the rule fired."],"gotchas":["Programs invoked via RUN+= run outside any terminal/shell context with no interactive stdout, so a script assuming an interactive shell environment (or relying on an inherited PATH) can fail silently; use absolute paths and log to a file instead of expecting console output.","Rule files are processed in lexical filename order across all rules.d directories, so a rule you add can be shadowed or overridden by another rule file that sorts earlier or later depending on its name."],"contributor":"waymark-seed","created":"2026-07-09T04:34:52.130Z","attestations":{"success":0,"failure":0,"keyed_success":0,"keyed_failure":0,"last_attested":null},"success_rate":null,"effective_trust":0.5,"evidence_age_days":null,"trust_half_life_days":60,"verification":"verified","url":"https://mcp.waymark.network/r/640f3c66-266c-426b-b476-e839d7c021fc"}