Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to permanently modify USB device permissions in Linux

2025-04-10 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/01 Report--

This article is about how to permanently modify the permissions of USB devices in Linux. The editor thinks it is very practical, so share it with you as a reference and follow the editor to have a look.

problem

When I tried to run the USB GPS receiver in Linux, I encountered the following error from gpsd. It appears that gpsd does not have access to the USB device (/ dev/ttyUSB0). How do I permanently modify its permissions on Linux?

1. Gpsd [377]: gpsd:ERROR: read-only device open failed:Permission denied2. Gpsd [377]: gpsd:ERROR:/dev/ttyUSB0: device activation failed.3. Gpsd: gpsd:ERROR: device open failed:Permission denied-retrying read-only solution

When you are running a process that reads or writes to USB devices, the user / group of the process must have permission to do so. Of course, you can manually change the permissions of the USB device with the chmod command, but the manual permission changes are only temporary. The USB device restores its default permissions the next time it restarts.

As a permanent way, you can create a udev-based USB permission rule that can assign any permission mode according to your choice. Here's what to do.

1. Use the lsusb command to find out the vendorID and productID of the USB device

$lsusb-vvv

In the lsusb output above, find your USB device and find the "idVendor" and "idProduct" fields. In this case, our results are idVendor (0x067b) and idProduct (0x2303)

two。 Create a new udev rule

$sudovi/etc/udev/rules.d/50-myusb.rules

Replace the default values with your own "idVendor" and "idProduct". MODE= "0666" represents the permissions of the USB device.

SUBSYSTEMS== "usb", ATTRS {idVendor} = = "067b", ATTRS {idProduct} = = "2303", GROUP= "users", MODE= "0666"

3. Restart the computer or reload the udev rule

$sudo udevadm control-reload

Verify the permissions of the USB device:

Thank you for reading! This is the end of this article on "how to permanently modify USB device permissions in Linux". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, you can share it out for more people to see!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report