Skip to content

Commit 26046af

Browse files
committed
Add udev rules for Linux sysfs power switching to README.md
The udev rules for the sysfs case are a bit more complex than those for the libusb based interface, as udev has built-in support for changing permissions on device files but not for sysfs attributes. Instead we have to use chmod / chown to set permissions and owners. Signed-off-by: Leonard Göhrs <[email protected]>
1 parent 1ff81af commit 26046af

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

README.md

+30
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,36 @@ USB device into the same physical USB port (this method is also used in Linux ke
211211
Linux USB permissions
212212
=====================
213213

214+
Kernels after 6.0
215+
-----------------
216+
217+
On Linux Kernel 6.0 and later (e.g. `uname -r` shows a version numer greater or equal to 6.0) there is
218+
a standard interface to turn USB hub ports on or off.
219+
To use it as non-root user add a udev rule like the following to the file `/etc/udev/rules.d/52-usb.rules`
220+
to allow any user on the system to turn hub ports on and off:
221+
222+
SUBSYSTEM=="usb", DRIVER=="hub", \
223+
RUN="/bin/sh -c \"chmod --silent 666 $sys$devpath/*-port*/disable\""
224+
225+
If you don't like wide open mode `0666`, you can restrict access by group by using a rule like the
226+
following instead:
227+
228+
SUBSYSTEM=="usb", DRIVER=="hub", \
229+
RUN+="/bin/sh -c \"chown root:dialout $sys$devpath/*-port*/disable\"" \
230+
RUN+="/bin/sh -c \"chmod 660 $sys$devpath/*-port*/disable\""
231+
232+
and then add permitted users to `dialout` group:
233+
234+
sudo usermod -a -G dialout $USER
235+
236+
For your `udev` rule changes to take effect, reboot or run:
237+
238+
sudo udevadm trigger --attr-match=subsystem=usb
239+
240+
241+
Kernels before 6.0
242+
------------------
243+
214244
On Linux, you should configure `udev` USB permissions (otherwise you will have to run it as root using `sudo uhubctl`).
215245
To fix USB permissions, first run `sudo uhubctl` and note all `vid:pid` for hubs you need to control.
216246
Then, add one or more udev rules like below to file `/etc/udev/rules.d/52-usb.rules` (replace 2001 with your vendor id):

0 commit comments

Comments
 (0)