lsmod in Ubuntu - it is used to list kernel modules currently loaded in our system. But, before we move ahead - we would like to discuss a bit about kernel modules itself.
Sometimes, we need to extend kernel functionality for various reasons. And, we can't rebuild kernel every time we add new functionality. So, that's where kernel modules comes to rescue. The kernel modules are nothing but a piece of code, which help us extend kernel functionality. One of the advantages of using kernel modules is that - we don't have to rebuild kernel and reboot our system every time we make changes to the kernel. Just simply load or unload the kernel module.
So, next question which may arise at this point in time is - where are these kernel modules stored in Ubuntu?
Answer - Following directory have all the kernel modules
Now, if you use cd command-line utility to get inside the directory straight-away. It won't work. Because linux_kernel_release isn't a directory here. We can use the following code to know the kernel release -
So, if the kernel release for you is -
Then, issue the following to get inside the directory -
And, to list the contents of the directory -
lsmod in Ubuntu
Now, not all kernel modules available in the system are loaded. So, to list the kernel modules currently loaded in our system - we use lsmod command-line utility. In the terminal, issue the following -
The output would contain - Module, size and used by columns.
In conclusion, we have covered lsmod in Ubuntu here. In coming articles, we continue with kernel modules and see how we can get more information about currently loaded kernel modules.
Additional Info -
The output we get from lsmod command-line utility is the formatted version of
Use cat command-line utility to see the difference -