how to change the default mode of a linux device
2013-09-12 10:05
671 查看
加载完你自己开发的设备驱动之后,生成的设备在用户空间往往需要以root方式才能访问,这样在用gui程序进行设备访问之前,必须改变设备的权限(chmod),或者所属用户和组(chown),gui程序才能有权限去打开那个设备,或者就需要在终端中将GUI程序以sudo方式运行,这样稍显麻烦,下面介绍一种直接修改生成设备默认属性的方式实现。
在/etc/udev/rules.d目录下创建规则文件10-myrule.rules
文件内容如下:
KERNEL=="pdusb0", NAME="pdusb0", MODE="0777"
其中KERNEL是匹配键,NAME和MODE是赋值键。
重新插上设备,出现设备pdusb0,权限为777,用户空间app能顺利访问该设备
参考文章:
udev has rules for permissions, you need to create them under
First try this:
In the file
add this line:
If this doesn't work add a rule in /etc/udev/rules.d, more on that here :http://www.reactivated.net/writing_udev_rules.html
(http://stackoverflow.com/questions/11846594/how-can-i-programmatically-set-permissions-on-my-char-device)
在/etc/udev/rules.d目录下创建规则文件10-myrule.rules
文件内容如下:
KERNEL=="pdusb0", NAME="pdusb0", MODE="0777"
其中KERNEL是匹配键,NAME和MODE是赋值键。
重新插上设备,出现设备pdusb0,权限为777,用户空间app能顺利访问该设备
参考文章:
udev has rules for permissions, you need to create them under
/etc/udev/rules.d
First try this:
In the file
/etc/udev/udev.conf,
add this line:
# My default permissions default_mode="0660"
If this doesn't work add a rule in /etc/udev/rules.d, more on that here :http://www.reactivated.net/writing_udev_rules.html
(http://stackoverflow.com/questions/11846594/how-can-i-programmatically-set-permissions-on-my-char-device)
相关文章推荐
- How to change the default run level of a RedHat 9.0 or Fedora Core Linux system
- How to change the default location of the Office 2010 Document Cache
- HOW TO CHANGE THE DEFAULT KEY-VALUE SEPARATOR OF A MAPREDUCE JOB
- How to Change the Hostname of a Linux System
- How to programmatically change the default view of an InfoPath form
- How to change the resolution in text mode for Linux5+
- How to Change the Hostname of a Linux System
- How to change the output color of echo in Linux
- How to Change the Default Boot Device by Using the Boot PROM
- How to change the language of oracle sqlplus from chinese to english in windows(如何将oracle sql plus中的中文变成英文版)
- How to change the status of Prepayment invoice
- How to change the text color of the selected property sheet tab in Visual C++
- How to change the URL of your SVN repository
- How to change the background color of an Edit Box
- the diary of how to backup one more files in linux
- how to edit the grub to change the sequance of system
- How to Change the Default Theme Appearance [editing with no theme]
- How to Change the language of a site template
- How to change the URL of your SVN repository
- how to change the port of tomcat