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

🐧 Get the latest tutorials on Linux, Open Source & DevOps via RSS feed or Weekly email newsletter.

🐧 3 comments so far... add one

CategoryList of Unix and Linux commands
Disk space analyzersncdu pydf
File Managementcat
FirewallAlpine Awall CentOS 8 OpenSUSE RHEL 8 Ubuntu 16.04 Ubuntu 18.04 Ubuntu 20.04
Network UtilitiesNetHogs dig host ip nmap
OpenVPNCentOS 7 CentOS 8 Debian 10 Debian 8/9 Ubuntu 18.04 Ubuntu 20.04
Package Managerapk apt
Processes Managementbg chroot cron disown fg jobs killall kill pidof pstree pwdx time
Searchinggrep whereis which
User Informationgroups id lastcomm last lid/libuser-lid logname members users whoami who w
WireGuard VPNAlpine CentOS 8 Debian 10 Firewall Ubuntu 20.04
3 comments… add one
  • Akshay Mar 21, 2014 @ 5:11

    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 @ 23:08

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

      • 🐧 Vivek Gite Jan 3, 2017 @ 9:40

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

Leave a Reply

Your email address will not be published.

Use HTML <pre>...</pre> for code samples. Still have questions? Post it on our forum