lsmod in Ubuntu

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

/lib/modules/linux_kernel_release

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 –

uname -r

So, if the kernel release for you is –

5.15.0-46-generic

Then, issue the following to get inside the directory –

cd /lib/modules/5.15.0-46-generic

And, to list the contents of the directory –

ls -l

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 –

lsmod

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 /proc/modules

Use cat command-line utility to see the difference –

cat /proc/modules

Similar Posts