The kernel is the part of the operating system that facilitates interactions between hardware and software components. On most systems, it is loaded on startup after the bootloader and handles I/O requests as well as peripherals like keyboards, monitors, network adapters, and speakers. Typically, the kernel is responsible for memory management, process management, device management, system calls, and security. Applications use the system call mechanism for requesting a service from the operating system and most of the time, this request is passed to the kernel using a library provided by the operating system to invoke the related kernel function. While the kernel performs these low-level tasks, it's resident on a separate part of memory named protected kernel space which is not accessible by applications and other parts of the system. In contrast, applications like browsers, text editors, window managers or audio/video players use a different separate area of the memory, user space. This separation prevents user data and kernel data from interfering with each other and causing instability and slowness, as well as preventing malfunctioning application programs from crashing the entire operating system.
There are different kernel designs due to the different ways of managing system calls and resources. For example, while monolithic kernels run all the operating system instructions in the same address space for speed, microkernels use different spaces for user and kernel services for modularity. Apart from those, there are hybrid kernels, nanokernels, and, exokernels. The hybrid kernel architecture is based on combining aspects of microkernel and monolithic kernels.
The Linux kernel is the open-source, monolithic and, Unix-like operating system kernel that used in the Linux distributions, various embedded systems such as routers and as well as in the all Android-based systems. Linus Torvalds conceived and created the Linux kernel in 1991 and it's still being developed by thousands of developers today. It's a prominent example of free and open source software and it's used in other free software projects, notably the GNU operating system. Although the Linux-based operating systems dominate the most of computing, it still carries some of the design flaws which were quite a bit of debate in the early days of Linux. For example, it has the largest footprint and the most complexity over the other types of kernels. But it's a design feature that monolithic kernels inherent to have. These kind of design issues led developers to add new features and mechanisms to the Linux kernel which other kernels don't have.
Unlike the standard monolithic kernels, the Linux kernel is also modular, accepting loadable kernel modules (LKM) that typically used to add support for new hardware (as device drivers) and/or filesystems, or for adding system calls. Since LKMs could be loaded and unloaded to the system at runtime, they have the advantage of extending the kernel without rebooting and re-compiling. Thus, the kernel functionalities provided by modules would not reside in memory without being used and the related module can be unloaded in order to free memory and other resources.
Loadable kernel modules are located in
/lib/modules with the
.ko (kernel object) extension in Linux. While the lsmod command could be used for listing the loaded kernel modules, modprobe is used for loading or unloading a kernel module.
make # build sudo make install # install sudo modprobe lkm_example # load sudo modprobe -r lkm_example # unload
The dmesg command is used below to retrieve the message buffer of the kernel.
[16994.295552] [+] Example kernel module loaded. [16996.325674] [-] Example kernel module unloaded.
kmon provides a text-based user interface for managing the Linux kernel modules and monitoring the kernel activities. By managing, it means loading, unloading, blacklisting and showing the information of a module. These updates in the kernel modules, logs about the hardware and other kernel messages can be tracked with the real-time activity monitor in kmon. Since the usage of different tools like dmesg and kmod are required for these tasks in Linux, kmon aims to gather them in a single terminal window and facilitate the usage as much as possible while keeping the functionality.
Table of Contents
- Key Bindings
- Navigating & Scrolling
- Kernel Information
- Module Information
- Searching a module
- Loading a module
- Unloading a module
- Blacklisting a module
- Clearing the ring buffer
- Copy & Paste
- Sorting/reversing the kernel modules
- Customizing the colors
- Unicode symbols
- Setting the terminal tick rate
cargo install kmon
--force option to update.
cargo install kmon --force
- Download the latest binary from releases.
- Extract the files.
tar -xvzf kmon-*.tar.gz
- Run the binary.
Move binary to
/usr/local/bin/for running it from the terminal using
Man page could be viewed if kmon.8 file is copied to
cp kmon.8 /usr/local/man/man8/ gzip /usr/local/man/man8/kmon.8 man kmon
libxcb1-dev package for Debian/Ubuntu and
libxcb-devel package for Fedora/openSUSE/Void Linux.
kmon [FLAGS] [OPTIONS] [SUBCOMMANDS]
-h, --help Prints help information -r, --reverse Reverse the kernel module list -u, --unicode Show Unicode symbols for the block titles -V, --version Prints version information
-c, --color <COLOR> Set the main color using hex or color name [default: darkgray] -t, --tickrate <MS> Set the refresh rate of the terminal [default: 250]
help Prints this message or the help of the given subcommand(s) sort Sort kernel modules
kmon sort [FLAGS] FLAGS: -n, --name Sort modules by their names -s, --size Sort modules by their sizes
||Switch between blocks|
||Scroll up/down [selected block]|
||Scroll up/down [kernel activities]|
||Scroll up/down [module information]|
||Scroll right/left [kernel activities]|
||Scroll to top/bottom [module list]|
||Clear the kernel ring buffer|
||Show the module dependency information|
||Show the next kernel information|
||Search a kernel module|
||Load a kernel module|
||Unload the kernel module|
||Blacklist the kernel module|
||Execute/cancel the command|
?' while running the terminal UI to see key bindings.
Navigating & Scrolling
Arrow keys are used for navigating between blocks and scrolling.
Scrolling Kernel Activities
Some kernel messages might be long enough for not fitting into the kernel activities block since they are not wrapped. In this situation, kernel activities can be scrolled horizontally with
alt-h & alt-l keys. Vertical scrolling mechanism is the same as other blocks.
alt-j & alt-k keys can be used to scroll kernel activity and module information blocks slowly.
Use one of the
\, tab, backtab keys to switch between kernel release, version and platform informations.
The status of a kernel module is shown on selection.
For jumping to a dependent kernel module from its parent module,
number keys (1-9) can be used for specifying the index of the module on the Used By column.
Searching a module
Switch to the search area with arrow keys or using one of the
/, s, enter and provide a search query for the module name.
Loading a module
For adding a module to the Linux kernel, switch to load mode with one of the
+, i, insert keys and provide the name of the module to load. Then confirm/cancel the execution of the load command with
The command that used for loading a module:
Unloading a module
Use one of the
-, u, backspace keys to remove the selected module from the Linux kernel.
The command that used for removing a module:
modprobe -r <module_name>
Blacklisting a module
Blacklisting is a mechanism to prevent the kernel module from loading. To blacklist the selected module, use one of the
x, b, delete keys and confirm the execution.
The command that used for blacklisting a module:
if ! grep -q <module_name> /etc/modprobe.d/blacklist.conf; then echo 'blacklist <module_name>' >> /etc/modprobe.d/blacklist.conf echo 'install <module_name> /bin/false' >> /etc/modprobe.d/blacklist.conf fi
Clearing the ring buffer
The kernel ring buffer can be cleared with using one of the
ctrl-l/u, alt-c keys.
Copy & Paste
c/v keys are set for copy/paste operations.
ctrl-c/ctrl-v for copying and pasting while in input mode.
Sorting/reversing the kernel modules
sort subcommand can be used for sorting the kernel modules by their names or sizes.
kmon sort --name kmon sort --size
-r, --reverse flag is used for reversing the kernel module list.
Customizing the colors
kmon uses the colors of the terminal as default but the highlighting color could be specified with
-c, --color option.
Supported terminal colors are
black, red, green, yellow, blue, magenta, cyan, gray, darkgray, lightred, lightgreen, lightyellow, lightblue, lightmagenta, lightcyan, white.
kmon --color red
Using a custom color
Provide a hexadecimal value for the color to use.
kmon --color 19683a
-u, --unicode flag for showing Unicode symbols for the block titles.
Setting the terminal tick rate
-t, --tickrate option can be used for setting the refresh interval of the terminal UI in milliseconds.
docker run -it --cap-add syslog orhunp/kmon:tagname
docker build -t kmon .
docker run -it --cap-add syslog kmon
kmon aims to be a standard tool for Linux kernel management while supporting most of the Linux distributions.
Management actions about the Linux kernel should be applicable in kmon for minimizing the dependence on to command line and other tools.
kmon should be tested and reported on different architectures for further development and support.
About the project
- Exploring the Linux Kernel by Bob Cromwell
- Anatomy of the Linux loadable kernel module by Terenceli
- Managing kernel modules with kmod by Lucas De Marchi
|Fedora 31||Debian 10||Manjaro 19|
|Ubuntu 18.04||openSUSE||Void Linux|
GNU General Public License (3.0)
Copyright (c) 2020, orhun