• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
  • Skip to footer navigation

The Geek Diary

  • OS
    • Linux
    • CentOS/RHEL
    • Solaris
    • Oracle Linux
    • VCS
  • Interview Questions
  • Database
    • oracle
    • oracle 12c
    • ASM
    • mysql
    • MariaDB
  • DevOps
    • Docker
    • Shell Scripting
  • Big Data
    • Hadoop
    • Cloudera
    • Hortonworks HDP

udevadm Command Examples in Linux

by admin

The udevadm command is used to manage udev. It takes various subcommands, each of which performs a certain task to modify the behavior of the systemd-udevd daemon and related components. Some of these subcommands are described in the following table.

Subcommand Used To
info Retrieve device information stored in the udev database, as well as detailed device attributes from the /sys/ filesystem. For example, you can view a device’s vendor ID, product ID, serial number, and much more.
control Modify the running state of udev. For example, providing the –reload-rules option will ensure that udev is reading from any new rules files you’ve added.
trigger Execute rules that apply to any device that is currently plugged in. You can also specify an action using the -c option, such as add, remove, or change. As the names imply, these will trigger events where a device is added, removed, or changed in the running kernel.
monitor Watch for events sent by the kernel or by a udev rule.
test Simulate a udev event running for a device, with results on output.

With the udevadm monitor command, you can tap into udev in real time and see what it sees when you plug in different devices. Try it as root.

# udevadm monitor

The monitor function prints received events for

  • UDEV: The event which udev sends out after rule processing.
  • KERNEL: The kernel uevent.

With udevadm monitor running, plug in a thumb drive and watch as all kinds of information are spewed out onto your screen. Notice, particularly, that the type of event is an ADD event. That’s a good way of identifying what type of event you want.

Syntax

The syntax of the udevadm command is:

# udevadm [options] [subcommand] [arguments]

udevadm Command Examples

1. Monitor all device events:

# udevadm monitor

2. Print `uevents` sent out by the kernel:

# udevadm monitor --kernel

3. Print device events after being processed by `udev`:

# udevadm monitor --udev

4. List attributes of a device:

# udevadm info --attribute-walk --path /dev/sda1

5. Reload all `udev` rules:

# udevadm control --reload-rules

6. Trigger all `udev` rules to run:

# udevadm trigger

Filed Under: Linux

Some more articles you might also be interested in …

  1. CentOS / RHEL 6,7 : How to enable or disable XDMCP service (GDM)
  2. mountpoint: command not found
  3. How to disable Ctrl+Alt+Del causing system reboot in CentOS/RHEL 6
  4. How to Remove a Dead Mulitpath Device without Reboot in CentOS/RHEL
  5. pacman: command not found
  6. Yum Command Fails with “Another app is currently holding the yum lock” in CentOS/ RHEL 7
  7. What are different Samba Server Types
  8. Yum Fails with “Error: database disk image is malformed” in /var/log/messages
  9. CentOS / RHEL 5,6 : How to Change the timezone
  10. pdftoppm: command not found

You May Also Like

Primary Sidebar

Recent Posts

  • powertop Command Examples in Linux
  • powertop: command not found
  • powerstat: command not found
  • powerstat Command Examples in Linux

© 2023 · The Geek Diary

  • Archives
  • Contact Us
  • Copyright