You need to use lsmod program which show the status of loaded modules in the Linux Kernel. Linux kernel use a term modules for all hardware device drivers.
Tutorial details | |
---|---|
Difficulty | Easy (rss) |
Root privileges | Yes |
Requirements | lsmod |
Time | Less than a one minute |
This is an important task. With lsmod you can verify that device driver is loaded for particular hardware. Any hardware device will only work if device driver is loaded.
Task: List or display loaded modules
Open a terminal or login over the ssh session and type the following command
$ less /proc/modules
Sample outputs:
sha1_generic 1759 4 - Live 0xffffffffa059e000 arc4 1274 2 - Live 0xffffffffa0598000 ecb 1841 2 - Live 0xffffffffa0592000 ppp_mppe 5240 2 - Live 0xffffffffa058b000 ppp_async 6245 1 - Live 0xffffffffa0584000 crc_ccitt 1323 1 ppp_async, Live 0xffffffffa057e000 ppp_generic 19291 6 ppp_mppe,ppp_async, Live 0xffffffffa0572000 slhc 4003 1 ppp_generic, Live 0xffffffffa056c000 ext3 106854 1 - Live 0xffffffffa0546000 jbd 37349 1 ext3, Live 0xffffffffa0533000 sha256_generic 8692 2 - Live 0xffffffffa0525000 aes_x86_64 7340 2 - Live 0xffffffffa0517000 aes_generic 25714 1 aes_x86_64, Live 0xffffffffa050b000 .... ... .... ahci 32950 20 - Live 0xffffffffa007b000 libata 133824 3 ata_generic,pata_jmicron,ahci, Live 0xffffffffa0045000 scsi_mod 126901 3 usb_storage,sd_mod,libata, Live 0xffffffffa0012000 thermal 11674 0 - Live 0xffffffffa0009000 thermal_sys 11942 3 video,processor,thermal, Live 0xffffffffa0000000
To see nicely formatted output, type:
$ lsmod
Sample outputs:
Module Size Used by sha1_generic 1759 4 arc4 1274 2 ecb 1841 2 ppp_mppe 5240 2 ppp_async 6245 1 crc_ccitt 1323 1 ppp_async ppp_generic 19291 6 ppp_mppe,ppp_async slhc 4003 1 ppp_generic ext3 106854 1 jbd 37349 1 ext3 sha256_generic 8692 2 aes_x86_64 7340 2 aes_generic 25714 1 aes_x86_64 cbc 2539 1 nfsd 254974 13 exportfs 3186 1 nfsd nfs 241498 0 lockd 57651 2 nfsd,nfs fscache 29882 1 nfs nfs_acl 2031 2 nfsd,nfs auth_rpcgss 33524 2 nfsd,nfs sunrpc 161756 12 nfsd,nfs,lockd,nfs_acl,auth_rpcgss fuse 51020 1 dm_crypt 10680 1 it87 15879 0 hwmon_vid 1828 1 it87 coretemp 4325 0 loop 11799 0 snd_pcm 60487 0 usb_storage 40233 0 i915 257462 0 snd_timer 15598 1 snd_pcm drm_kms_helper 20369 1 i915 snd 46542 2 snd_pcm,snd_timer ata_generic 3239 0 drm 143120 2 i915,drm_kms_helper soundcore 4598 1 snd snd_page_alloc 6265 1 snd_pcm uhci_hcd 18537 0 i2c_algo_bit 4209 1 i915 psmouse 49969 0 ehci_hcd 32145 0 video 17445 1 i915 i2c_i801 7830 0 evdev 7352 2 pata_jmicron 2280 0 pcspkr 1699 0 serio_raw 3752 0 usbcore 123399 4 usb_storage,uhci_hcd,ehci_hcd i2c_core 15835 5 i915,drm_kms_helper,drm,i2c_algo_bit,i2c_i801 nls_base 6567 1 usbcore output 1692 1 video e1000e 124884 0 button 4650 1 i915 processor 29951 0 ext4 288755 2 mbcache 5050 2 ext3,ext4 jbd2 67175 1 ext4 crc16 1319 1 ext4 dm_mod 53994 6 dm_crypt raid456 44516 4 md_mod 73936 5 raid456 async_raid6_recov 5186 1 raid456 async_pq 3495 2 raid456,async_raid6_recov raid6_pq 77179 2 async_raid6_recov,async_pq async_xor 2494 3 raid456,async_raid6_recov,async_pq xor 4380 1 async_xor async_memcpy 1198 2 raid456,async_raid6_recov async_tx 1750 5 raid456,async_raid6_recov,async_pq,async_xor,async_memcpy sd_mod 29953 25 crc_t10dif 1276 1 sd_mod ahci 32950 20 libata 133824 3 ata_generic,pata_jmicron,ahci scsi_mod 126901 3 usb_storage,sd_mod,libata thermal 11674 0 thermal_sys 11942 3 video,processor,thermal
First column is Module name and second column is the size of the modules i..e the output format is module name, size, use count, list of referring modules.
Finding more info about any module or driver
Type the following command:
# modinfo driver-Name-Here
# modinfo thermal_sys
# modinfo e1000e
Sample outputs:
filename: /lib/modules/2.6.32-5-amd64/kernel/drivers/net/e1000e/e1000e.ko version: 1.2.20-k2 license: GPL description: Intel(R) PRO/1000 Network Driver author: Intel Corporation, <linux.nics@intel.com> srcversion: AB58ACECA1618E521F58503 alias: pci:v00008086d00001503sv*sd*bc*sc*i* alias: pci:v00008086d00001502sv*sd*bc*sc*i* alias: pci:v00008086d000010F0sv*sd*bc*sc*i* alias: pci:v00008086d000010EFsv*sd*bc*sc*i* alias: pci:v00008086d000010EBsv*sd*bc*sc*i* alias: pci:v00008086d000010EAsv*sd*bc*sc*i* alias: pci:v00008086d00001525sv*sd*bc*sc*i* alias: pci:v00008086d000010DFsv*sd*bc*sc*i* alias: pci:v00008086d000010DEsv*sd*bc*sc*i* alias: pci:v00008086d000010CEsv*sd*bc*sc*i* alias: pci:v00008086d000010CDsv*sd*bc*sc*i* alias: pci:v00008086d000010CCsv*sd*bc*sc*i* alias: pci:v00008086d000010CBsv*sd*bc*sc*i* alias: pci:v00008086d000010F5sv*sd*bc*sc*i* alias: pci:v00008086d000010BFsv*sd*bc*sc*i* alias: pci:v00008086d000010E5sv*sd*bc*sc*i* alias: pci:v00008086d0000294Csv*sd*bc*sc*i* alias: pci:v00008086d000010BDsv*sd*bc*sc*i* alias: pci:v00008086d000010C3sv*sd*bc*sc*i* alias: pci:v00008086d000010C2sv*sd*bc*sc*i* alias: pci:v00008086d000010C0sv*sd*bc*sc*i* alias: pci:v00008086d00001501sv*sd*bc*sc*i* alias: pci:v00008086d00001049sv*sd*bc*sc*i* alias: pci:v00008086d0000104Dsv*sd*bc*sc*i* alias: pci:v00008086d0000104Bsv*sd*bc*sc*i* alias: pci:v00008086d0000104Asv*sd*bc*sc*i* alias: pci:v00008086d000010C4sv*sd*bc*sc*i* alias: pci:v00008086d000010C5sv*sd*bc*sc*i* alias: pci:v00008086d0000104Csv*sd*bc*sc*i* alias: pci:v00008086d000010BBsv*sd*bc*sc*i* alias: pci:v00008086d00001098sv*sd*bc*sc*i* alias: pci:v00008086d000010BAsv*sd*bc*sc*i* alias: pci:v00008086d00001096sv*sd*bc*sc*i* alias: pci:v00008086d0000150Csv*sd*bc*sc*i* alias: pci:v00008086d000010F6sv*sd*bc*sc*i* alias: pci:v00008086d000010D3sv*sd*bc*sc*i* alias: pci:v00008086d0000109Asv*sd*bc*sc*i* alias: pci:v00008086d0000108Csv*sd*bc*sc*i* alias: pci:v00008086d0000108Bsv*sd*bc*sc*i* alias: pci:v00008086d0000107Fsv*sd*bc*sc*i* alias: pci:v00008086d0000107Esv*sd*bc*sc*i* alias: pci:v00008086d0000107Dsv*sd*bc*sc*i* alias: pci:v00008086d000010B9sv*sd*bc*sc*i* alias: pci:v00008086d000010D5sv*sd*bc*sc*i* alias: pci:v00008086d000010DAsv*sd*bc*sc*i* alias: pci:v00008086d000010D9sv*sd*bc*sc*i* alias: pci:v00008086d00001060sv*sd*bc*sc*i* alias: pci:v00008086d000010A5sv*sd*bc*sc*i* alias: pci:v00008086d000010BCsv*sd*bc*sc*i* alias: pci:v00008086d000010A4sv*sd*bc*sc*i* alias: pci:v00008086d0000105Fsv*sd*bc*sc*i* alias: pci:v00008086d0000105Esv*sd*bc*sc*i* depends: vermagic: 2.6.32-5-amd64 SMP mod_unload modversions parm: copybreak:Maximum size of packet that is copied to a new buffer on receive (uint) parm: TxIntDelay:Transmit Interrupt Delay (array of int) parm: TxAbsIntDelay:Transmit Absolute Interrupt Delay (array of int) parm: RxIntDelay:Receive Interrupt Delay (array of int) parm: RxAbsIntDelay:Receive Absolute Interrupt Delay (array of int) parm: InterruptThrottleRate:Interrupt Throttling Rate (array of int) parm: IntMode:Interrupt Mode (array of int) parm: SmartPowerDownEnable:Enable PHY smart power down (array of int) parm: KumeranLockLoss:Enable Kumeran lock loss workaround (array of int) parm: WriteProtectNVM:Write-protect NVM [WARNING: disabling this can lead to corrupted NVM] (array of int) parm: CrcStripping:Enable CRC Stripping, disable if your BMC needs the CRC (array of int)
Is there a standard directory in Linux where my driver files are stored?
Type the following command to see a directory location where your driver files are located:
echo "Kernel drivers dir: \"/lib/modules/$(uname -r)/kernel/drivers/\" \ for Linux kernel version \"$(uname -r)\" "
To view drivers, enter:
ls -l /lib/modules/$(uname -r)/kernel/drivers/
Sample outputs:
acpi block dca fmc hv infiniband lightnvm memstick net parport power regulator ssb uio virtio ata bluetooth dma fpga hwmon input macintosh message nfc pci powercap remoteproc staging usb vme atm char edac gpio hwtracing iommu mailbox mfd ntb pcmcia pps rtc target uwb w1 auxdisplay clk extcon gpu i2c ipack mcb misc nvdimm phy ptp scsi thermal vfio watchdog base cpufreq firewire hid idle isdn md mmc nvme pinctrl pwm spi thunderbolt vhost xen bcma crypto firmware hsi iio leds media mtd nvmem platform rapidio spmi tty video
How do I find out if a particular module/driver installed or not?
The syntax is:
$ find /lib/modules/$(uname -r)/kernel/drivers/ -iname "driver-to-search-here"
To find out if a driver called foo.ko installed or not, run:
$ find /lib/modules/$(uname -r)/kernel/drivers/ -iname "foo.ko"
Find if e1000e driver installed or not:
$ find /lib/modules/$(uname -r)/kernel/drivers/ -iname "*e1000e*.ko"
$ find /lib/modules/$(uname -r)/kernel/drivers/ -iname "e1000e.ko"
Run modinfo on driver name:
$ modinfo e1000e
🐧 9 comments so far... add one ↓
Category | List of Unix and Linux commands |
---|---|
File Management | cat |
Firewall | Alpine Awall • CentOS 8 • OpenSUSE • RHEL 8 • Ubuntu 16.04 • Ubuntu 18.04 • Ubuntu 20.04 |
Network Utilities | dig • host • ip • nmap |
OpenVPN | CentOS 7 • CentOS 8 • Debian 10 • Debian 8/9 • Ubuntu 18.04 • Ubuntu 20.04 |
Package Manager | apk • apt |
Processes Management | bg • chroot • cron • disown • fg • jobs • killall • kill • pidof • pstree • pwdx • time |
Searching | grep • whereis • which |
User Information | groups • id • lastcomm • last • lid/libuser-lid • logname • members • users • whoami • who • w |
WireGuard VPN | Alpine • CentOS 8 • Debian 10 • Firewall • Ubuntu 20.04 |
Is there any way by which I can know for example “xyz” module is for “xyz” hardware?
Just do modinfo and it tells you roght at the top.
Sorry for another comment…
Actually my objective is to find what device drivers(modules) are loaded for my hardware and is there any hardware which doesn’t have the right module installed for it.
Thanks
Harshal.
@Harshal
Hey!
Maybe it is a little bit late, but try out this command: “lspci -v”.
It’ll show a huge list of all PCI devices and all kind of information INCLUDING the current used module.
Hope, it helps.
Alex
helped me thanks.
what command would i use to output the above commands directly to a file?
thanks again
Use the directing “>” symbol.
E.g.
lspci -v > filename.txt
Alex
Hi,
what about listing modules which are *NOT* loaded in the kernel?
I.E finding out what’s supported with your kernel?
You can find them as .ko files in /lib/modules/”your kernel folder name”.
Also they are listed in the modules.dep file in the same folder as above.
Hi Ruphus and mamma,
This saved me a huge amount of time. I was about to rebuild the kernel thinking a module wasn’t installed. Thanks!