您的位置:首页 > 其它

Ubuntu udev rules 设置方法

2015-02-08 08:54 225 查看
还是国外资料有用,需要在Linux(Ubuntu)普通用户下访问原本要在root下才能访问的usb设备可以参考本文。

SUBSYSTEMS=="usb",ATTRS{idProduct}=="xxxx",ATTRS{idVendor}=="xxxx",MODE="666",OWNER=“xxxx",GROUP="xxxx"

原文:http://pigeonsnest.co.uk/stuff/ubuntu-udev-scanner.html ;

Ubuntu: udev rules for USB scanner 

How to create a udev rule to get a USB scanner working in Ubuntu jaunty. 

Assumes that: (1) user is a member of group "scanner", (2) sane is installed. 

Symptoms of problem: "sane-find-scanner" detects the existence of the scanner, but "scanimage -L" does not report it when run with user permissions, only when run with root permissions. Scanning works as root, but not as a normal user. 

1) Run "lsusb" to find the scanner's manufacturer and device IDs. Example output: 

$ lsusb

Bus 003 Device 014: ID 04b8:012e Seiko Epson Corp. 

Bus 003 Device 012: ID 046d:c408 Logitech, Inc. Marble Mouse (4-button)

Bus 003 Device 011: ID 05e3:0608 Genesys Logic, Inc. USB-2.0 4-Port HUB

Bus 003 Device 001: ID 0000:0000  

Bus 002 Device 001: ID 0000:0000  

Bus 001 Device 013: ID 04b8:0005 Seiko Epson Corp. Stylus Printer

Bus 001 Device 001: ID 0000:0000

$

In the above example, the first line relates to the scanner... in this case an Epson Perfection V200... it is somewhat unhelpful that this particular scanner's text ID string is nothing more than "Seiko Epson Corp.", but it is easy to determine that that device
is indeed the scanner by running "lsusb" both with and without the scanner plugged in. 

The four-digit hex number "04b8" is the manufacturer ID (observe that the Epson printer on the penultimate line has the same manufacturer ID), and "012e" is the device ID. 

2) Create a file /etc/udev/rules.d/40-scanner.rules containing the following (your browser may have wrapped this; it should be all on one line): 

SUBSYSTEMS=="usb", ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="012e", ENV{libsane_matched}="yes", GROUP="scanner"

Of course you will substitute the appropriate values for your scanner, obtained from "lsusb", for the idVendor and idProduct entries. 

The SUBSYSTEMS and ATTRS entries have double == signs whereas the ENV and GROUP entries have single = signs. This is not a typo. 

3) Restart udev: 

$ sudo /etc/init.d/udev restart

* Stopping kernel event manager... [ OK ] 

* Starting kernel event manager... [ OK ] 

$

4) Unplug the scanner and plug it in again. 

5) Check that it has obtained the correct permissions. Run "lsusb" again to determine the bus and device IDs - they will have changed due to the unplugging and replugging. Then check the appropriate device node in /dev/bus/usb: 

$ lsusb

Bus 003 Device 015: ID 04b8:012e Seiko Epson Corp. 

Bus 003 Device 012: ID 046d:c408 Logitech, Inc. Marble Mouse (4-button)

Bus 003 Device 011: ID 05e3:0608 Genesys Logic, Inc. USB-2.0 4-Port HUB

Bus 003 Device 001: ID 0000:0000  

Bus 002 Device 001: ID 0000:0000  

Bus 001 Device 013: ID 04b8:0005 Seiko Epson Corp. Stylus Printer

Bus 001 Device 001: ID 0000:0000

$ ls -l /dev/bus/usb/003/015

crw-rw-r-- 1 root scanner 189, 269 Apr 24 19:10 /dev/bus/usb/003/015

$

If the output corresponds with the above, all should be well, and running "scanimage -L" with user permissions should now pick the scanner up: 

$ scanimage -L

device `epkowa:libusb:003:015' is a Epson Perfection V200 flatbed scanner

$

Note that the V200 requires a driver; this document does not cover that, only the setting of the permissions.

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  udev rules.d