how to change the default mode of a linux device
来源:互联网 发布:学唱歌入门教程软件 编辑:程序博客网 时间:2024/05/18 02:31
加载完你自己开发的设备驱动之后,生成的设备在用户空间往往需要以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 /etc/udev/rules.d
First try this:
In the file /etc/udev/udev.conf
, add this line:
# My default permissionsdefault_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 mode of a linux device
- How to change the default run level of a RedHat 9.0 or Fedora Core Linux system
- How to Change the Hostname of a Linux System
- How to Change the Hostname of a Linux System
- How to Change Default Audio Device
- How to Change the Default Boot Device by Using the Boot PROM
- How to Change the Default System Fonts
- How To Change the Background Color of a Tab Control
- How to change the color of a CEikLabel
- How to change the default location of the Office 2010 Document Cache
- How to Accept/Reject the Transfer of a Device
- How to programmatically change the default view of an InfoPath form
- how to change the port of tomcat
- How to change the SQL Server 2008 default install path
- How to change the SQL Server 2008 default install path
- How to change the default browser in Visual Studio
- how to change the implicit default settings in django 1.6
- How to change the default stack size on different platforms
- 进程间的通信
- Android下如何理解onMeasure,onLayout的过程
- Linux网络安全技术与实现
- Java多态(利用向上向下转型和反射机理)
- android 用Pull 读取XML
- how to change the default mode of a linux device
- linux串口编程
- spring security 自定义验证
- java中的比较器
- Win32中新增的GDI对象——路径
- 读取配置文件随记
- Java垃圾回收机制
- java 实现视频转换通用工具类:视频截图-Ffmpeg(四)
- Gp Linux--常用命令备忘