{"id":3327,"date":"2018-08-12T17:03:08","date_gmt":"2018-08-12T22:03:08","guid":{"rendered":"http:\/\/lisa.rushworth.us\/?p=3327"},"modified":"2018-08-12T21:43:18","modified_gmt":"2018-08-13T02:43:18","slug":"testing-udev-rules","status":"publish","type":"post","link":"https:\/\/www.rushworth.us\/lisa\/?p=3327","title":{"rendered":"Testing udev Rules"},"content":{"rendered":"<p>The first step of testing a udev rule is to determine the actual device you want to test. Get the info for the \/dev\/thing and find the real \/device\/path\/&#8230;. (note, make sure you&#8217;re not in a &#8220;looking at parent&#8221; section &#8212; you want the one all the way at the top)<\/p>\n<pre>[lisa@linuxhost dev]# udevadm info -a \/dev\/ttyUSB0 | more\r\n...\r\nlooking at device '\/devices\/pci0000:00\/0000:00:02.0\/usb2\/2-1\/2-1:1.0\/ttyUSB0\/tty\/ttyUSB0':\r\n...<\/pre>\n<p>Once you have the device, use udevadm in test mode and you will see the results from all of your udev rules. Including group &amp; permission mask applied to the device.<\/p>\n<pre>[lisa@linuxhost dev]# udevadm test \/devices\/pci0000:00\/0000:00:02.0\/usb2\/2-1\/2-1:1.0\/ttyUSB0\/tty\/ttyUSB0 | more\r\ncalling: test\r\nversion 238\r\nLoad module index\r\nParsed configuration file \/usr\/lib\/systemd\/network\/99-default.link\r\n...\r\n47437 strings (385590 bytes), 43385 de-duplicated (347383 bytes), 4053 trie nodes used\r\nPROGRAM 'usb_modeswitch --symlink-name \/devices\/pci0000:00\/0000:00:02.0\/usb2\/2-1\/2-1:1.0\/ttyUSB0\/tty\/ttyUSB0 10c4 8a2a ' \/usr\/lib\/udev\/rules.d\/40-usb_modeswitch.rules:10\r\nstarting 'usb_modeswitch --symlink-name \/devices\/pci0000:00\/0000:00:02.0\/usb2\/2-1\/2-1:1.0\/ttyUSB0\/tty\/ttyUSB0 10c4 8a2a '\r\nProcess 'usb_modeswitch --symlink-name \/devices\/pci0000:00\/0000:00:02.0\/usb2\/2-1\/2-1:1.0\/ttyUSB0\/tty\/ttyUSB0 10c4 8a2a ' succeeded.\r\nGROUP 18 \/usr\/lib\/udev\/rules.d\/50-udev-default.rules:25\r\nIMPORT builtin 'hwdb' \/usr\/lib\/udev\/rules.d\/60-serial.rules:7\r\nIMPORT builtin 'usb_id' \/usr\/lib\/udev\/rules.d\/60-serial.rules:8\r\n\/sys\/devices\/pci0000:00\/0000:00:02.0\/usb2\/2-1\/2-1:1.0: if_class 255 protocol 0\r\nIMPORT builtin 'hwdb' \/usr\/lib\/udev\/rules.d\/60-serial.rules:8\r\nIMPORT builtin 'path_id' \/usr\/lib\/udev\/rules.d\/60-serial.rules:15\r\nLINK 'serial\/by-path\/pci-0000:00:02.0-usb-0:1:1.0-port0' \/usr\/lib\/udev\/rules.d\/60-serial.rules:17\r\nIMPORT builtin skip 'usb_id' \/usr\/lib\/udev\/rules.d\/60-serial.rules:19\r\nLINK 'serial\/by-id\/usb-Silicon_Labs_HubZ_Smart_Home_Controller_90F0016B-if00-port0' \/usr\/lib\/udev\/rules.d\/60-serial.rules:24\r\nGROUP 18 \/etc\/udev\/rules.d\/99-server.rules:5\r\nMODE 0666 \/etc\/udev\/rules.d\/99-server.rules:5\r\nLINK 'ttyUSB-5' \/etc\/udev\/rules.d\/99-server.rules:5\r\nhandling device node '\/dev\/ttyUSB0', devnum=c188:0, mode=0666, uid=0, gid=18\r\npreserve permissions \/dev\/ttyUSB0, 020666, uid=0, gid=18\r\npreserve already existing symlink '\/dev\/char\/188:0' to '..\/ttyUSB0'\r\nfound 'c188:0' claiming '\/run\/udev\/links\/\\x2fserial\\x2fby-id\\x2fusb-Silicon_Labs_HubZ_Smart_Home_Controller_90F0016B-if00-port0'\r\ncreating link '\/dev\/serial\/by-id\/usb-Silicon_Labs_HubZ_Smart_Home_Controller_90F0016B-if00-port0' to '\/dev\/ttyUSB0'\r\npreserve already existing symlink '\/dev\/serial\/by-id\/usb-Silicon_Labs_HubZ_Smart_Home_Controller_90F0016B-if00-port0' to '..\/..\/ttyUSB0'\r\nfound 'c188:0' claiming '\/run\/udev\/links\/\\x2fserial\\x2fby-path\\x2fpci-0000:00:02.0-usb-0:1:1.0-port0'\r\ncreating link '\/dev\/serial\/by-path\/pci-0000:00:02.0-usb-0:1:1.0-port0' to '\/dev\/ttyUSB0'\r\npreserve already existing symlink '\/dev\/serial\/by-path\/pci-0000:00:02.0-usb-0:1:1.0-port0' to '..\/..\/ttyUSB0'\r\nfound 'c188:0' claiming '\/run\/udev\/links\/\\x2fttyUSB-5'\r\ncreating link '\/dev\/ttyUSB-5' to '\/dev\/ttyUSB0'\r\npreserve already existing symlink '\/dev\/ttyUSB-5' to 'ttyUSB0'\r\n...<\/pre>\n<p>Or as a one-liner:<\/p>\n<pre>\r\nudevadm test `udevadm info -a \/dev\/ttyUSB0 | grep \"looking at device\" | sed \"s\/looking at device '\/\/\" | sed \"s\/':\/\/\"`\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>The first step of testing a udev rule is to determine the actual device you want to test. Get the info for the \/dev\/thing and find the real \/device\/path\/&#8230;. (note, make sure you&#8217;re not in a &#8220;looking at parent&#8221; section &#8212; you want the one all the way at the top) [lisa@linuxhost dev]# udevadm info &hellip;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[30],"tags":[577],"class_list":["post-3327","post","type-post","status-publish","format-standard","hentry","category-system-administration","tag-udev"],"_links":{"self":[{"href":"https:\/\/www.rushworth.us\/lisa\/index.php?rest_route=\/wp\/v2\/posts\/3327","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.rushworth.us\/lisa\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.rushworth.us\/lisa\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.rushworth.us\/lisa\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.rushworth.us\/lisa\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=3327"}],"version-history":[{"count":2,"href":"https:\/\/www.rushworth.us\/lisa\/index.php?rest_route=\/wp\/v2\/posts\/3327\/revisions"}],"predecessor-version":[{"id":3330,"href":"https:\/\/www.rushworth.us\/lisa\/index.php?rest_route=\/wp\/v2\/posts\/3327\/revisions\/3330"}],"wp:attachment":[{"href":"https:\/\/www.rushworth.us\/lisa\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=3327"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.rushworth.us\/lisa\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=3327"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.rushworth.us\/lisa\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=3327"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}