This guide covers the basic usage of the kmod tool from the installation to the available options.
Installing the Kmod Package
The latest Linux systems come with the pre-installed kmod package. Nonetheless, if you need to install the package, you can use the apt or apt-get commands.
To install kmod using the apt-get, run the following commands:
$ sudo apt-get install -y kmod
The previous commands update the apt database and install the kmod package.
To install kmod using apt, run the following commands:
$ sudo apt install -y kmod
Similarly, you can uninstall kmod using either of the following commands:
To only remove the package, use this command:
To uninstall kmod and its dependencies, use this command:
If you need to remove kmod and its configurations and data, use this command:
Alternatively, the following command uninstalls kmod and all its configurations, data, and dependencies:
How to Use the Kmod Linux Package
The kmod has only a few commands and options.
Its basic syntax is:
There are two options available:
1. To get the help message, use the –help or -h option.
2. To check the version of kmod, use the -V or –version.
Kmod implements the programs that control the Linux kernel modules and uses two commands listed in the following examples:
To view all the modules currently loaded in the system.
From the previous output you can note the different modules loaded. On the right side, it lists the module name followed by the size of the module. Next, it shows the name of the process using the specific module.
You can search for a specific module from the list using the commands like grep. For instance, to search a module named kvm, we can use the following command:
In the following output, you will note that we filtered the output using grep.
You can also combine the other commands to save the output on a file using the cat command as shown in the following. Here, our output file is output1.txt:
The output displays the contents of the output file created while using the kmod command and filtering the specific modules.
It lists the information of static device nodes provided by the running kernel version’s modules.
Your output may differ from the previous example depending on your modules. Similar to the first command, you may combine it with the other commands to achieve the different functionalities. For instance, you can save the output in a file to analyze later.
For this, use the cat command as shown in the following:
We covered about the Linux kmod command and how to use it to achieve the different functionalities. Besides, we’ve seen its various options and commands and how to combine them with the other options using the different examples. You now have a solid understanding of the kmod Linux command.