Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork88
Linux Kernel Manager and Activity Monitor 🐧💻
License
orhun/kmon
Folders and files
| Name | Name | Last commit message | Last commit date | |
|---|---|---|---|---|
Repository files navigation

Linux Kernel Manager and Activity Monitor 🐧💻
The kernel is the part of the operating system that facilitates interactions betweenhardware andsoftware components. On most systems, it is loaded on startup after thebootloader and handles I/O requests as well as peripherals like keyboards, monitors, network adapters, and speakers. Typically, the kernel is responsible formemory management,process management,device management,system calls, andsecurity.Applications use thesystem 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 namedprotected 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, whilemonolithic kernels run all the operating system instructions in the same address spacefor speed,microkernels use different spaces for user and kernel servicesfor modularity. Apart from those, there arehybrid 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 offree and open source software and it's used in other free software projects, notably theGNU 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 thelargest footprint andthe 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 alsomodular, acceptingloadable kernel modules (LKM) that typically used to add support for newhardware (as device drivers) and/orfilesystems, or for addingsystem calls. Since LKMs could be loaded and unloaded to the systemat 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 thelsmod command could be used for listing the loaded kernel modules,modprobe orinsmod/rmmod is used for loading or unloading a kernel module. insmod/rmmod are used for modules independent of modprobe and without requiring an installation to/lib/modules/$(uname -r).
Here's a simple example of a Linux kernel module that prints a message when it's loaded and unloaded. The build and installation steps of themodule using aMakefile are shown below.
make # buildsudo make install # installsudo modprobe lkm_example # loadsudo modprobe -r lkm_example # unloadThedmesg 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 atext-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 likedmesg andkmod 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.
kmon is written inRust and usesRatatui &termion libraries for its text-based user interface.
- Installation
- Usage
- Key Bindings
- Features
- Help
- Navigating & Scrolling
- Options Menu
- Block Sizes
- Block Positions
- Kernel Information
- Module Information
- Searching a module
- Loading a module
- Unloading a module
- Blacklisting a module
- Reloading a module
- Clearing the ring buffer
- Copy & Paste
- Sorting/reversing the kernel modules
- Customizing the colors
- Unicode symbols
- Setting the terminal tick rate
- Searching modules by regular expression
- Roadmap
- Resources
- Funding
- License
- Copyright
kmon can be installed fromcrates.io using Cargo ifRust is installed.
cargo install kmonThe minimum supported Rust version (MSRV) is1.74.1.
kmon can be installed from the Arch Linuxofficial repository.
pacman -S kmonThere is also a development package on theAUR. Use your favoriteAUR helper to install. For example,
paru -S kmon-gitkmon can be installed usingNix package manager fromnixpkgs-unstable channel.
nix-channel --add https://nixos.org/channels/nixpkgs-unstablenix-channel --update nixpkgsnix-env -iA nixpkgs.kmonOnNixOS:
nix-channel --add https://nixos.org/channels/nixos-unstablenix-channel --update nixosnix-env -iA nixos.kmonkmon is available forAlpine Edge. It can be installed viaapk after enabling thecommunity repository.
apk add kmondocker run -it --cap-add syslog orhunp/kmon:tagnamedocker build -t kmon .docker run -it --cap-add syslog kmon- Download the latest binary fromreleases section and pick betweenglibc ormusl-libc binary.
- To download the package compiled withglibc run:
wget https://github.com/orhun/kmon/releases/download/v[VERSION]/kmon-[VERSION]-x86_64-unknown-linux-gnu.tar.gz- To download the package compiled withmusl-libc run:
wget https://github.com/orhun/kmon/releases/download/v[VERSION]/kmon-[VERSION]-x86_64-unknown-linux-musl.tar.gz- Extract the files.
tar -xvzf kmon-*.tar.gz- Enter in the new folder.
cd kmon-[VERSION]- Run the binary.
./kmonMove binary to
/usr/local/bin/for running it from the terminal usingkmoncommand.Man page and shell completions are generated at build time in
targetdirectory.
libxcb should be installed for using the copy/paste commands of X11.
e.g: Installlibxcb1-dev package for Debian/Ubuntu* andlibxcb-devel package for Fedora/openSUSE/Void Linux.
kmon [OPTIONS] [COMMAND]-a, --accent-color <COLOR> Set the accent color using hex or color name [default: white]-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]-r, --reverse Reverse the kernel module list-u, --unicode Show Unicode symbols for the block titles-E, --regex Interpret the module search query as a regular expression-h, --help Print help information-V, --version Print version informationsort Sort kernel moduleskmon sort [OPTIONS]Options:
-s, --size Sort modules by their sizes-n, --name Sort modules by their names-d, --dependent Sort modules by their dependent modules-h, --help Print help information[?], F1 | Help |
right/left, h/l | Switch between blocks |
up/down, k/j, alt-k/j | Scroll up/down [selected block] |
pgup/pgdown | Scroll up/down [kernel activities] |
</> | Scroll up/down [module information] |
alt-h/l | Scroll right/left [kernel activities] |
ctrl-t/b, home/end | Scroll to top/bottom [module list] |
alt-e/s | Expand/shrink the selected block |
ctrl-x | Change the block position |
ctrl-l/u, alt-c | Clear the kernel ring buffer |
[d], alt-d | Show the dependent modules |
[1]..[9] | Jump to the dependent module |
[\], tab, backtab | Show the next kernel information |
[/], s, enter | Search a kernel module |
[+], i, insert | Load a kernel module |
[-], u, backspace | Unload the kernel module |
[x], b, delete | Blacklist the kernel module |
ctrl-r, alt-r | Reload the kernel module |
m, o | Show the options menu |
y/n | Execute/cancel the command |
c/v | Copy/paste |
r, F5 | Refresh |
q, ctrl-c/d, ESC | Quit |
Press '?' while running the terminal UI to see key bindings.
Arrow keys are used for navigating between blocks and scrolling.
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 withalt-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.
m ando keys can be used as a shortcut for kernel management operations. When pressed, an options menu will be provided for managing the currently selected kernel module.
alt-e & alt-s keys can be used for expanding/shrinking the selected block.
ctrl-x key can be used for changing the positions of blocks.
Use one of the\, tab, backtab keys to switch between kernel release, version and platform information.
The status of a kernel module is shown on selection.
Use one of thed, alt-d keys to show all the dependent modules of the selected module.
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 theUsed By column.
Switch to the search area with arrow keys or using one of the/, s, enter and provide a search query for the module name.
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 withy/n.
The command that used for loading a module:
modprobe <module_name> || insmod <module_name>.koUse 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> || rmmod <module_name>Blacklisting is a mechanism to prevent the kernel module from loading. To blacklist the selected module, use one of thex, 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.conffiUsectrl-r oralt-r key for reloading the selected module.
The command that used for reloading a module:
modprobe -r <module_name> || rmmod <module_name> && modprobe <module_name> || insmod <module_name>.koThe kernel ring buffer can be cleared with using one of thectrl-l/u, alt-c keys.
dmesg --clearc/v keys are set for copy/paste operations.
Usectrl-c/ctrl-v for copying and pasting while in input mode.
sort subcommand can be used for sorting the kernel modules by their names, sizes or dependent modules.
kmon sort --namekmon sort --sizekmon sort --dependentAlso the-r, --reverse flag is used for reversing the kernel module list.
kmon --reversekmon uses the colors of the terminal as default but the highlighting color could be specified with-c, --color option. Alternatively, default text color can be set via-a, --accent-color option.
Supported terminal colors areblack, red, green, yellow, blue, magenta, cyan, gray, darkgray, lightred, lightgreen, lightyellow, lightblue, lightmagenta, lightcyan, white.
kmon --color redProvide a hexadecimal value for the color to use.
kmon --color 19683aDefault text color might cause readability issues on some themes that have transparency.-a, --accent-color option can be used similarly to the-c, --color option for overcoming this issue.
kmon --color 6f849c --accent-color e35760Use-u, --unicode flag for showing Unicode symbols for the block titles.
kmon --unicode-t, --tickrate option can be used for setting the refresh interval of the terminal UI in milliseconds.
-E, --regex option can be used for searching modules by regular expression.
kmon aims to be a standard tool for Linux kernel management while supporting most of the Linux distributions.
For achieving this goal, kmon should be accessible from different package managers such asSnap* andRPM.
It is required to have the essential tools likedmesg andkmod on the system for kmon to work as expected. Thus the next step would be using just the system resources for these functions.
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.
- 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
- Manage And Monitor Linux Kernel Modules With Kmon (OSTechNix)
- Kmon The Linux Kernel Management And Monitoring Software (Brodie Robertson on YouTube)
| Fedora 31 | Debian 10 | Manjaro 19 |
|---|---|---|
![]() | ![]() | ![]() |
| Ubuntu 18.04 | openSUSE | Void Linux |
|---|---|---|
![]() | ![]() | ![]() |
- Follow@kmonitor_ on Twitter
- Follow theauthor:
Support the development of my projects by supporting me onGitHub Sponsors.
Support the open source development efforts by becoming abacker orsponsor.
GNU General Public License (3.0)
Copyright © 2020-2024,Orhun Parmaksız
About
Linux Kernel Manager and Activity Monitor 🐧💻
Topics
Resources
License
Code of conduct
Contributing
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Sponsor this project
Uh oh!
There was an error while loading.Please reload this page.
Packages0
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
































