FreeKB - Linux Files /udev/rules.d
Linux Files - /udev/rules.d

UDEV may not officially stand for "user devices", but this definition can be helpful in understanding what UDEV does. Let's say you connect a Samsung device to your Linux machine with a USB cable. Let's use the LSUSB command to gather some data about the device.

[user1@server1 ]# lsusb
Bus 002 Device 007: ID 04e8:6860 Samsung Electronics Co., Ltd Galaxy (MTP)


Let's also use the mount command to see where the device is mounted.

[user1@server1 ]# mount
/dev/sdb1 on /media type fuseblk (rw, nosuid, nodev, allow_other, blksize=4096)


The kernel will emit a uevent. The uevent is picked up by UDEV. UDEV will then follow rules at one of these directories:

  • /etc/udev/rules.d
  • /run/udev/rules.d
  • /lib/udev/rules.d

As an example, when the Samsung device is connected to the Linux machine, the Linux machine will read the contents of the /lib/udev/rules.d/69-libmtp.rules file to know what to do with the USB flash drive. We can use the CAT command to read the contents of the /lib/udev/rules.d/69-libmtp.rules file, and then pipe the STDOUT through GREP, using device is 6860 from the LSUSB command.

[user1@server1 ]# cat /lib/udev/rules.d/69-libmtp.rules | grep 6860
ATTR{idVendor}=="04e8", ATTR{idProduct}=="6860", SYMLINK+="libmtp-%k", MODE="660", GROUP="audio", ENV{ID_MTP_DEVICE}="1", ENV{ID_MEDIA_PLAYER}="1"


Notice the Mode is 660 and the group is "audio." If we view the mounted device, we can see that the mode is 660 and hte group is audio.

[user1@server1 ]# ls -l /media
drw-rw---- 2 root audio 4096 Jan 1 00:01 Samsung

Add a Comment

We will never share your name or email with anyone. Enter your email if you would like to be notified when we respond to your comment.

Please enter 7697a in the box below so that we can be sure you are a human.


Web design by yours truely - me, myself, and I   |   |