![如何在 ubuntu 16.04 上永久设置设备读写权限?](https://linux22.com/image/115907/%E5%A6%82%E4%BD%95%E5%9C%A8%20ubuntu%2016.04%20%E4%B8%8A%E6%B0%B8%E4%B9%85%E8%AE%BE%E7%BD%AE%E8%AE%BE%E5%A4%87%E8%AF%BB%E5%86%99%E6%9D%83%E9%99%90%EF%BC%9F.png)
我正在使用运行 ubuntu 的嵌入式设备。
通常只有root才有i2c设备的读写权限。
我使用此命令为普通用户(我)添加 i2c r/w 权限:
sudo chmod 777 /dev/i2c-*
但我想制定一个udev
规则。我在/etc/udev/rules.d/
名为的文件中创建了一个文件60-i2c-tools.rules
,并将以下行放入其中。
KERNEL==”i2c-[0-9]*”, MODE=”0660”
但是,当我重新启动设备时,我无法访问 I2C 设备。这些是权限:
crwxrwxrwx 1 root root 89, 0 Aug 10 12:59 /dev/i2c-0
crwxrwxrwx 1 root root 89, 1 Aug 10 12:59 /dev/i2c-1
crw------- 1 root root 89, 10 Aug 10 12:59 /dev/i2c-10
crw------- 1 root root 89, 11 Aug 10 12:59 /dev/i2c-11
crwxrwxrwx 1 root root 89, 2 Aug 10 12:59 /dev/i2c-2
crwxrwxrwx 1 root root 89, 3 Aug 10 12:59 /dev/i2c-3
crw------- 1 root root 89, 4 Aug 10 12:59 /dev/i2c-4
crw------- 1 root root 89, 5 Aug 10 12:59 /dev/i2c-5
crw------- 1 root root 89, 6 Aug 10 12:59 /dev/i2c-6
crw------- 1 root root 89, 7 Aug 10 12:59 /dev/i2c-7
crw------- 1 root root 89, 8 Aug 10 12:59 /dev/i2c-8
crw------- 1 root root 89, 9 Aug 10 12:59 /dev/i2c-9
我需要运行sudo chmod 777 /dev/i2c-*
并将权限更改为:
crwxrwxrwx 1 root root 89, 0 Aug 10 12:59 /dev/i2c-0
crwxrwxrwx 1 root root 89, 1 Aug 10 12:59 /dev/i2c-1
crwxrwxrwx 1 root root 89, 10 Aug 10 12:59 /dev/i2c-10
crwxrwxrwx 1 root root 89, 11 Aug 10 12:59 /dev/i2c-11
crwxrwxrwx 1 root root 89, 2 Aug 10 12:59 /dev/i2c-2
crwxrwxrwx 1 root root 89, 3 Aug 10 12:59 /dev/i2c-3
crwxrwxrwx 1 root root 89, 4 Aug 10 12:59 /dev/i2c-4
crwxrwxrwx 1 root root 89, 5 Aug 10 12:59 /dev/i2c-5
crwxrwxrwx 1 root root 89, 6 Aug 10 12:59 /dev/i2c-6
crwxrwxrwx 1 root root 89, 7 Aug 10 12:59 /dev/i2c-7
crwxrwxrwx 1 root root 89, 8 Aug 10 12:59 /dev/i2c-8
crwxrwxrwx 1 root root 89, 9 Aug 10 12:59 /dev/i2c-9