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 set the user right of USB device under Linux system

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

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

This article mainly explains "how to set USB device user rights under the Linux system". The content of the article is simple and clear, and it is easy to learn and understand. Please follow the editor's train of thought to study and learn "how to set USB device user rights under the Linux system".

Let GUEST recognize the USB device

1. The simplest way is as follows:

The code is as follows:

$sudo gedit / etc/fstab

Add at the end

The code is as follows:

# the USB group

# Open read and write access to USB devices for all users

None / proc/bus/usb usbfs devmode=666 0 0

Then the average user can use the USB device through libusb.

2. However, it is not safe to open the read and write permissions of USB devices to all users in some cases, and it is safer to do so:

(1)。 Add user group usbfs

The code is as follows:

$sudo groupadd usbfs

(2)。 View the gid of the usbfs user group

The code is as follows:

$cat / etc/group | grep usbfs

Usbfs:x:1002:

3. Add current users to the usbfs group

The code is as follows:

$sudo gedit / etc/group

Put

The code is as follows:

Usbfs:x:1002:

Modify to

The code is as follows:

Usbfs:x:1002:joson

4. Reset permissions to edit / etc/fstab file for USB devices, add the following two lines, and note that your gid may not be 1002

The code is as follows:

$sudo gedit / etc/fstab

Add at the end

The code is as follows:

# 1002 is the USB group ID

None / proc/bus/usb usbfs devgid=1002,devmode=664 00

5. After the reboot, you should be able to use the USB device in the client.

Note: uninstall the USB device in the host before using it in the client.

Permanently modify USB device permissions in Linux

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.

First, you need to find out the vendorID and productID of the USB device. Use the lsusb command.

The code is as follows:

$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)

Let's create a new udev rule.

The code is as follows:

$sudo vi / etc/udev/rules.d/50-myusb.rules

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

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

Now restart the computer and reload the udev rule:

The code is as follows:

$sudo udevadm control-reload

Then verify the permissions of the USB device.

Thank you for your reading, the above is the content of "how to set the user rights of USB devices under the Linux system". After the study of this article, I believe you have a deeper understanding of how to set the user rights of USB devices under the Linux system. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!

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

Servers

Wechat

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

12
Report