How to change USB device permission permanently on Linux

Question: I am trying to run gpsd on my Linux with a USB GPS receiver. However, I am getting the following errors from gpsd.

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

Looks like gpsd does not have permission to access the USB device (/dev/ttyUSB0). How can I change its default permission mode permanently on Linux?

When you run a process that wants to read or write to a USB device, the user/group of the process must have appropriate permission to do so. Of course you can change the permission of your USB device manually with chmod command, but such manual permission change will be temporary. The USB device will revert to its default permission mode when you reboot your Linux machine.

As a permanent solution, you can create a udev-based USB permission rule which assigns any custom permission mode of your choice. Here is how to do it.

First, you need to identify the vendorID and productID of your USB device. For that, use lsusb command.

$ lsusb -vvv

From the lsusb output, find your USB device's entry, and look for "idVendor" and "idProduct" fields. In this example, we have idVendor (0x067b) and idProduct (0x2303).

Next, create a new udev rule as follows.

$ sudo vi /etc/udev/rules.d/50-myusb.rules
SUBSYSTEMS=="usb", ATTRS{idVendor}=="067b", ATTRS{idProduct}=="2303", GROUP="users", MODE="0666"

Replace "idVendor" and "idProduct" values with your own. MODE="0666" indicates the preferred permission of the USB device.

Now reboot your machine or reload udev rules:

$ sudo udevadm control --reload

Then verify the permission of the USB device.

Download this article as ad-free PDF (made possible by your kind donation): 
Download PDF

Subscribe to Ask Xmodulo

Do you want to receive Linux related questions & answers published at Ask Xmodulo? Enter your email address below, and we will deliver our Linux Q&A straight to your email box, for free. Delivery powered by Google Feedburner.

Support Xmodulo

Did you find this tutorial helpful? Then please be generous and support Xmodulo!

2 thoughts on “How to change USB device permission permanently on Linux

Leave a comment

Your email address will not be published. Required fields are marked *