본문 바로가기
Development Solutions/Linux

How to grant USB device permission to general user on Ubuntu (Linux 우분투에서 일반 유저에게 usb디바이스 권한 부여하는 방법)

by Dev Diary Hub 2022. 10. 12.
반응형

How to grant USB device permission to general user

(일반 유저에게 usb디바이스 권한 부여하는 방법)

 

 

리눅스에서 애플리케이션을 개발하다보면, usb디바이스와의 연결이 필요한 기능을 개발할 때가 있다.

이 때, usb 디바이스에 접근이 되지 않는 문제가 발생하곤 한다.

libusb 기반의 라이브러리를 사용할 경우, LIBUSB_ACCESS_ERROR가 발생할 것이다.

해결책은 아래 명령어를 순서대로 입력하는 것이다. 터미널을 열고 아래 명령어를 하나씩 입력해보자.

 

[English] (When developing applications in Linux, there are times when developing functions that require connection to a USB device. At this time, the problem of not being able to access the USB device often occurs. If a libusb-based library is used, LIBUSB_ACCESS_ERROR will occur. The solution is to enter the following commands in order. Open a terminal and enter the following commands one by one.)

반응형

1. rules.d에 USB연결 권한을 위한 새로운 룰 파일(rules)을 생성한다.

[English] (Create a new rule file (rules) for USB connection permission in rules.d.)

$ sudo vi /etc/udev/rules.d/51-usb-devices.rules

 

2. 1단계에서 만든 rules파일에 아래 양식의 룰을 입력한다.

idVendor와 idProduct만 각자의 디바이스에 해당하는 값으로 채운다. 해당 값은 lsusb -v 명령어로 확인할 수 있다.

[English] (Enter the rules of the form below in the rules file created in step 1. Only idVendor and idProduct are filled with values corresponding to their respective devices. The corresponding value can be checked with the lsusb -v command.)

SUBSYSTEM=="usb", ATTR{idVendor}=="0836", ATTR{idProduct}="c0a0", GROUP="plugdev", MODE="0666"

 

 

3. 추가된 rule을 포함하여 다시 로드한다.

[English] (Reload including added rules.)

$ udevadm control --reload-rules
반응형