Skip to content

Instantly share code, notes, and snippets.

@evaporei
Created February 26, 2019 16:50
Show Gist options
  • Save evaporei/58a0b9f60763a5222b4bfe763014ddca to your computer and use it in GitHub Desktop.
Save evaporei/58a0b9f60763a5222b4bfe763014ddca to your computer and use it in GitHub Desktop.
Script to make USB device work on Linux
device_info_output="$(lsusb | grep $1)"
device_info_array=($device_info_output)
bus_number="${device_info_array[1]}"
device_number="${device_info_array[3]::-1}"
echo "${bus_number}"
echo "${device_number}"
sudo chmod 777 /dev/bus/usb/"$bus_number"/"$device_number"
@evaporei
Copy link
Author

Another way to solve the problem that doesn't require to run this script everytime is to create a file like this:

Name: /usr/lib/udev/rules.d/50-name_of_your_device.rules
Content:

SUBSYSTEM=="usb", ATTR{idVendor}=="vendor_id_of_website", MODE="0777", GROUP="plugdev"

Where:

  • name_of_your_device can be what ever you want, in my opinion it is better to reference something that references your device (ex: gertec);
  • vendor_id_of_website should be a number that is on this website: http://www.linux-usb.org/usb.ids. To find your USB id just use Ctrl + F and look for your device name.

Example, my device is from Gertec:

screenshot-gertec-id-device

So the content of my file should be:

SUBSYSTEM=="usb", ATTR{idVendor}=="1753", MODE="0777", GROUP="plugdev"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment