Linux: How to find the device driver used for a device?

  • If my target has one device connected and many drivers for that device loaded, how can I understand what device is using which driver?

  • Igor Chubin

    Igor Chubin Correct answer

    8 years ago

    Just use /sys.

    Example. I want to find the driver for my Ethernet card:

    $ sudo lspci
    02:00.0 Ethernet controller: Realtek Semiconductor Co., Ltd. RTL8111/8168B PCI Express Gigabit Ethernet controller (rev 01)
    $ find /sys | grep drivers.*02:00

    That is r8169.

    First I need to find coordinates of the device using lspci; then I find driver that is used for the devices with these coordinates.

    `lspci -v` does it by itself.

    `lspci -nk` will show you attached drivers. In general the sysfs is the right place to search for.

    @AndyShevchenko thank you! This will be a *great* timesaver for me :-D

    I know the OP asked for "drivers being used", but what if the driver is not installed nor being used? How to find out just by the `vendorID:productID`? Also, what if it is not a PCI device, and you only see it in `lsusb` for example?

    @DrBeco: But if driver is not installed, what do you want to find? You should just google in this case

    Well, not an option if you are trying to find the correct driver to load for a bunch of network cards that are not working (so, no google, unless you keep moving to another machine, or booting something that work, which takes time)

    And if it's USB? Is there a generic way to do this? Looking at /sys or /proc or something?

    `lspci -vk | grep -A 6 -i ethernet` but you have to adjust the number of lines printed after the matching line with `-A`.

License under CC-BY-SA with attribution

Content dated before 6/26/2020 9:53 AM