Created
February 26, 2019 16:50
-
-
Save evaporei/58a0b9f60763a5222b4bfe763014ddca to your computer and use it in GitHub Desktop.
Script to make USB device work on Linux
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" |
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 useCtrl + F
and look for your device name.
Example, my device is from Gertec
:
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
How to use
First run this in your terminal:
This will list all USB devices connected to your computer. The output will have a format similar to this:
Then run the script of this
gist
passing the name of the device as an argument, like this:Now your USB device will be enabled to use 🙂