I apologize if the query is too simple. But I want to ask is there a difference between linux system modules and linux kernel modules. If there is a difference then where are both located. Is it that /lib/module/$(uname -r) shows kernel modules and /sys/module/ shows system modules
/lib/module/$(uname -r) is a directory on your disk¹. It contains files, most of which (
*.ko) are module files: files that contain the code of a kernel module. The files in this directory (and its subdirectories) contain, in principle, modules that you can load into your running kernel.
/sys/module is a directory on a virtual filesystem that exposes kernel internals. Accessing a file in that directory invokes a function in the kernel which only looks at some internal kernel data structures, it doesn't go any further to a disk layer. Each entry in
/sys/module corresponds to a component of the running kernel, with code that's loaded in memory and active. This includes all loaded modules, but also components that could be loaded as a module but were built directly into the kernel when the kernel was compiled.
Having files in
/lib/module/$(uname -r) that don't correspond to an entry in
/sys/module is very common: they're drivers for some piece of hardware (or other thing managed by the kernel) that you don't have in your computer. Entries in
/sys/module with no corresponding file under
/lib/module/$(uname -r) happen when the component was built into the kernel (here's how to tell), or if the module was loaded manually from a file that's located elsewhere (or is now deleted).
¹ Or rarely on something other than a disk, if your system keeps its root filesystem elsewhere, e.g. over the network or in a RAM disk.
/sys/module/ shows all modules in the system by their name as folders with diverse information needed by the system. The directory
/lib/module/$(uname -r) contains the kernel module files, stored in a folder hierarchy according to their function.
For example, the Software Watchdog kernel module file would be in
On the other hand, this module has its own "softdog" (the module name) directory in
/sys/module/ with information used by the system when operating/inserting this module, but not the file of the module itself.
You can operate modules by name with
modprobe [args] <module-name> [module-params]
You can operate modules by path to the
.ko file with
insmod [args] <path> [module-params].
Mind that operating kernel modules requires root privileges.