Find Out Linux Kernel Modules ( Drivers ) Location / Directory

Posted on in Categories , , , , , last updated January 3, 2017

Can you tell me an exact location of Linux kernel driver under Linux file system? Where to find all available modules under Linux operating systems?

The /lib/modules/kernel-version/ directory stores all compiled drivers under Linux operating system. You can use the modprobe command to intelligently add or remove a module from the Linux kernel. The modprobe command looks in the module directory /lib/modules/$(uname -r) for all the modules and other files, except for the optional /etc/modprobe.conf configuration file and /etc/modprobe.d directory. Type the following command to display current modules directory name:
$ echo "Modules dir: /lib/modules/$(uname -r) for kernel version $(uname -r)"
Sample outputs:

Modules dir: /lib/modules/2.6.18-238.el5 for kernel version 2.6.18-238.el5

To see the contains of the directory, enter:
$ ls -l /lib/modules/$(uname -r)
Sample output:

total 1396
lrwxrwxrwx 1 root root     46 Jan 14 04:57 build -> ../../../usr/src/kernels/2.6.18-238.el5-x86_64
drwxr-xr-x 2 root root   4096 Dec 19 13:37 extra
drwxr-xr-x 9 root root   4096 Jan 14 04:57 kernel
-rw-r--r-- 1 root root 297080 Jan 14 04:57 modules.alias
-rw-r--r-- 1 root root     69 Jan 14 04:57 modules.ccwmap
-rw-r--r-- 1 root root 218901 Jan 14 04:57 modules.dep
-rw-r--r-- 1 root root    147 Jan 14 04:57 modules.ieee1394map
-rw-r--r-- 1 root root    375 Jan 14 04:57 modules.inputmap
-rw-r--r-- 1 root root   2699 Jan 14 04:57 modules.isapnpmap
-rw-r--r-- 1 root root     74 Jan 14 04:57 modules.ofmap
-rw-r--r-- 1 root root 232149 Jan 14 04:57 modules.pcimap
-rw-r--r-- 1 root root   4033 Jan 14 04:57 modules.seriomap
-rw-r--r-- 1 root root 147317 Jan 14 04:57 modules.symbols
-rw-r--r-- 1 root root 396941 Jan 14 04:57 modules.usbmap
lrwxrwxrwx 1 root root      5 Jan 14 04:57 source -> build
drwxr-xr-x 2 root root   4096 Dec 19 13:37 updates
drwxr-xr-x 3 root root   4096 Jan 14 04:57 weak-updates

You can change directory by typing the following command:
$ cd /lib/modules/$(uname -r)
$ pwd

Now cd into kernel/drivers/ to see a list of all compiled drivers:
$ cd kernel/drivers/
OR
$ cd /lib/modules/$(uname -r)/kernel/drivers/
Now issue the ls command:
$ ls | more
Sample outputs:

Fig.01: Sample output from above commands
Fig.01: Sample output from above commands

Posted by: Vivek Gite

The author is the creator of nixCraft and a seasoned sysadmin and a trainer for the Linux operating system/Unix shell scripting. He has worked with global clients and in various industries, including IT, education, defense and space research, and the nonprofit sector. Follow him on Twitter, Facebook, Google+.

3 comment

  1. Where are the .c files for the driver placed in the kernel tree?
    I need to edit the “class driver” of a flash drive so that whenever it is attached to the system, a specific message should be printed on the console.

Leave a Comment