≡ Menu

Find Out Linux Kernel Modules ( Drivers ) Location / Directory

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/
$ 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

Share this tutorial on:

Your support makes a big difference:
I have a small favor to ask. More people are reading the nixCraft. Many of you block advertising which is your right, and advertising revenues are not sufficient to cover my operating costs. So you can see why I need to ask for your help. The nixCraft, takes a lot of my time and hard work to produce. If you use nixCraft, who likes it, helps me with donations:
Become a Supporter →    Make a contribution via Paypal/Bitcoin →   

Don't Miss Any Linux and Unix Tips

Get nixCraft in your inbox. It's free:

{ 3 comments… add one }
  • Akshay March 21, 2014, 5:11 am

    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.

    • Rares May 31, 2016, 11:08 pm

      Have you found the answer? I really need to do something similar.

      • Vivek Gite January 3, 2017, 9:40 am

        You need to download your kernel driver source code and edit those files. Once edited, you need to compile driver or kernel itself. Visit https://www.kernel.org/ to grab Linux kernel.

Security: Are you a robot or human?

Leave a Comment

You can use these HTML tags and attributes: <strong> <em> <pre> <code> <a href="" title="">

   Tagged with: , , , , , , , , , , , , ,