Linux Kernel Manager and Activity Monitor 🐧💻

modprobe or rmmod is used for loading or unloading a kernel module


Linux Kernel Manager and Activity Monitor 🐧💻


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 or insmod/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 .

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 the module using a Makefile are shown below.

The dmesg command is used below to retrieve the message buffer of the kernel.

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.

kmon is written in Rust and uses tui-rs & termion libraries for its text-based user interface.

Table of Contents

  • Installation
    • Cargo
    • Arch Linux
    • Nixpkgs
    • Docker
      • Build
      • Run
    • Manual
      • Note
  • Usage
    • Flags
    • Options
    • Subcommands
  • Key Bindings
  • Features
    • Help
    • Navigating & Scrolling
      • Scrolling Kernel Activities
      • Smooth Scrolling
    • Options Menu
    • Block Sizes
    • Block Positions
    • Kernel Information
    • Module Information
      • Displaying the dependent modules
      • Jumping to dependent modules
    • 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
      • Supported colors
      • Using a custom color
      • Changing the accent color
    • Unicode symbols
    • Setting the terminal tick rate
  • Roadmap
    • Accessibility
    • Dependencies
    • Features
    • Testing
  • Resources
    • About the project
    • Articles
    • In the media
    • Gallery
    • Social Media
  • Funding
    • Patreon
    • Open Collective
  • License
  • Copyright

Installation

Cargo

kmon can be installed from crates.io using Cargo if Rust is installed.

Use the --force option to update.

Arch Linux

kmon can be installed from the Arch Linux official repository.

There are also a development package on AUR. Use your favorite AUR helper to install. For example,

Nixpkgs

kmon can be installed using Nix package manager from nixpkgs-unstable channel.

On NixOS:

Docker

Build

Run

Manual

  1. Download the latest binary from releases.

  2. Extract the files.

  3. Run the binary.

  4. Move binary to /usr/local/bin/ for running it from the terminal using kmon command.

  5. Man page could be viewed if kmon.8 file is copied to /usr/local/man/man8/ directory.

Note

libxcb should be installed for using the copy/paste commands of X11. *

e.g: Install libxcb1-dev package for Debian/Ubuntu* and libxcb-devel package for Fedora/openSUSE/Void Linux.

Usage

Flags

Options

Subcommands

Key Bindings

[?], 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

Features

Help

Press '?' 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.

Smooth Scrolling

alt-j & alt-k keys can be used to scroll kernel activity and module information blocks slowly.

Options Menu

m and o 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.

Block Sizes

alt-e & alt-s keys can be used for expanding/shrinking the selected block.

Block Positions

ctrl-x key can be used for changing the positions of blocks.

Kernel Information

Use one of the \, tab, backtab keys to switch between kernel release, version and platform informations.

Module Information

The status of a kernel module is shown on selection.

Displaying the dependent modules

Use one of the d, alt-d keys to show all the dependent modules of the selected module.

Jumping to dependent modules

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 y/n.

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:

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:

Reloading a module

Use ctrl-r or alt-r key for reloading the selected module.

The command that used for reloading a module:

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.

Use 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, sizes or dependent modules.

Also the -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. Alternatively, default text color can be set via -a, --accent-color option.

Supported colors

Supported terminal colors are black, red, green, yellow, blue, magenta, cyan, gray, darkgray, lightred, lightgreen, lightyellow, lightblue, lightmagenta, lightcyan, white.

Using a custom color

Provide a hexadecimal value for the color to use.

Changing the accent color

Default 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.

Unicode symbols

Use -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.

Roadmap

kmon aims to be a standard tool for Linux kernel management while supporting most of the Linux distributions.

Accessibility

For achieving this goal, kmon should be accessible from different package managers such as Snap* and RPM.

Dependencies

It is required to have the essential tools like dmesg and kmod on the system for kmon to work as expected. Thus the next step would be using just the system resources for these functions.

Features

Management actions about the Linux kernel should be applicable in kmon for minimizing the dependence on to command line and other tools.

Testing

kmon should be tested and reported on different architectures for further development and support.

Resources

About the project

  • Code of conduct
  • Contributing
  • Creating a release

Articles

  • 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

In the media

  • Manage And Monitor Linux Kernel Modules With Kmon ( OSTechNix)
  • Kmon The Linux Kernel Management And Monitoring Software (Brodie Robertson on YouTube)

Gallery

Fedora 31 Debian 10 Manjaro 19
Ubuntu 18.04 openSUSE Void Linux

Social Media

  • Follow @kmonitor_ on Twitter
  • Follow the author:
    • @orhun on GitHub
    • @orhunp_ on Twitter

Funding

Patreon

Support the development of kmon and other projects by becoming a patron.

Open Collective

Support the open source development efforts by becoming a backer or sponsor.

License

GNU General Public License (3.0)

Copyright

Copyright © 2020-2022, Orhun Parmaksız

Issues

Collection of the latest Issues

github-actions[bot]

github-actions[bot]

0

Multiple soundness issues

Details
Package xcb
Version 0.8.2
URL https://github.com/RustSec/advisory-db/issues/653
Date 2021-02-04

Calls std::str::from_utf8_unchecked() without any checks

The function xcb::xproto::GetAtomNameReply::name() calls std::str::from_utf8_unchecked() on the raw bytes that were received from the X11 server without any validity checks. The X11 server only prevents interior null bytes, but otherwise allows any X11 client to create an atom for arbitrary bytes.

This issue is tracked here: https://github.com/rtbo/rust-xcb/issues/96

xcb::xproto::GetPropertyReply::value() allows arbitrary return types

The function xcb::xproto::GetPropertyReply::value() returns a slice of type T where T is an unconstrained type parameter. The raw bytes received from the X11 server are interpreted as the requested type.

The users of the xcb crate are advised to only call this function with the intended types. These are u8, u16, and u32.

This issue is tracked here: https://github.com/rtbo/rust-xcb/issues/95

Out of bounds read in xcb::xproto::change_property()

xcb::xproto::change_property has (among others) the arguments format: u8 and data: &[T]. The intended use is one of the following cases:

  • format = 8 and T = u8
  • format = 16 and T = u16
  • format = 32 and T = u32 However, this constraint is not enforced. For example, it is possible to call the function with format = 32 and T = u8. In this case, a read beyond the end of the data slice is performed and the bytes are sent to the X11 server.

The users of the xcb crate are advised to only call this function with one of the intended argument combinations.

This issue is tracked here: https://github.com/rtbo/rust-xcb/issues/94

'Safe' wrapper around std::mem::transmute()

The function xcb::base::cast_event() takes a reference to a xcb::base::GenericEvent and returns a reference to an arbitrary type, as requested by the caller (or found via type interference). The function is implemented as a direct call to std::mem::transmute(). Since the return type is not constrained, this allows transmution to an incorrect type or a type that is larger than the X11 event that was passed in.

X11 events are mostly always 32 bytes large and this function works as intended.

Users are advised to only cast to the event structs provided by the xcb crate (and hope for the best).

This issue is tracked here: https://github.com/rtbo/rust-xcb/issues/78

See advisory page for additional details.

orhun

orhun

enhancement
0

Is your feature request related to a problem? Please describe. It would be nice to have different menu layouts instead of having only one which is fixed. We already have the functionality for changing the block sizes and moving them around. This new menu(s) could be possibly change the overall layout for different use cases such as:

  • Kernel monitoring (dmesg) mode where the "Kernel Activities" block is maximized.
  • Inspection mode where only the module info is shown.

And a couple of other scenarios...

Describe the solution you'd like Define a list of menu layouts and add a key binding for changing the current layout.

Describe alternatives you've considered There could be a command-line argument for launching kmon with the given menu type. e.g. kmon --menu activities

Additional context bpytop has something similar where you press m and the layout changes.

cedricam

cedricam

enhancement
0

Your program is very interresting.

  1. You also could enable/disable IPv6 feature.
  2. On each module you have options. The idea is to be able to set all drivers options

If it s possibe, to have the default value, and the best value

  1. to unload drivers over the grub kernel ex: ipv6.disable=1 you could use this command : grubby --remove-args="argX argY" --args="argA argB" --update-kernel

  2. or to propose to add some options to the grub if you have a specific hardware.ex: gpu nvidia, cpu intel,wifi broadcom,...

  3. Backup/restore configuration by command line.

regards,

Versions

Find the latest versions by id

v1.6.0 - Nov 05, 2021

73918056-d5c45500-48d1-11ea-8d18-9943827ab2ed.png See changelog for release notes.

v1.5.5 - Aug 11, 2021

73918056-d5c45500-48d1-11ea-8d18-9943827ab2ed.png See changelog for release notes.

v1.5.4 - Jul 16, 2021

73918056-d5c45500-48d1-11ea-8d18-9943827ab2ed.png See changelog for release notes.

v1.5.3 - Dec 14, 2020

73918056-d5c45500-48d1-11ea-8d18-9943827ab2ed.png See changelog for release notes.

v1.5.2 - Dec 14, 2020

73918056-d5c45500-48d1-11ea-8d18-9943827ab2ed.png See changelog for release notes.

v1.5.1 - Oct 09, 2020

v1.5.0 - Aug 27, 2020

v1.4.0 - Aug 05, 2020

v1.3.5 - Jul 30, 2020

v1.3.4 - Jul 29, 2020

v1.3.3 - Jul 29, 2020

v1.3.2 - Jul 29, 2020

v1.3.1 - Jul 29, 2020

v1.3.0 - Jul 22, 2020

v1.2.0 - May 03, 2020

v1.1.0 - Apr 09, 2020

v1.0.1 - Apr 04, 2020

v1.0.0 - Apr 01, 2020

v0.3.3 - Mar 23, 2020

v0.3.2 - Mar 23, 2020

v0.3.1 - Mar 19, 2020

v0.3.0 - Mar 10, 2020

v0.2.2 - Mar 01, 2020

v0.2.1 - Feb 28, 2020

v0.2.0 - Feb 23, 2020

v0.1.1 - Feb 23, 2020

v0.1.0 - Feb 06, 2020

Information - Updated Apr 17, 2022

Stars: 1.5K
Forks: 48
Issues: 5

Repositories & Extras

A conversion of steam_suite to rust with additional features

Provides a single TUI-based registry for drm-free, wine and steam games on linux, accessed through a rofi launch menu

A conversion of steam_suite to rust with additional features

This is a very thin wrapper around the ncurses TUI lib

NOTE: The ncurses lib is terribly unsafe and ncurses-rs is only the lightest

This is a very thin wrapper around the ncurses TUI lib

Logger with smart widget for the tui crate

Capturing of log messages by the logger

Logger with smart widget for the tui crate

A hackable, minimal, fast TUI file explorer

[VIDEO] XPLR: Insanely Hackable Lua File Manager ~ Brodie Robertson

A hackable, minimal, fast TUI file explorer

gpg-tui is a Terminal User Interface for GnuPG

Terminal User Interface for gpg provides but it tries to bring a more interactive approach to key management

gpg-tui is a Terminal User Interface for GnuPG
Http

894

oha (おはよう)

oha is a tiny program that sends some load to a web application and show realtime tui inspired by tokio and beautiful tui by Azlux's...

oha (おはよう)

Idea is to make simple command line tool with TUI interface for viewing and simple...

Idea is to make simple command line tool with TUI interface for viewing and simple editting of most used databases with very

Idea is to make simple command line tool with TUI interface for viewing and simple...

This is a TUI application to play and manage anime with AniList for Linux systems

TUI application to play and manage anime with here

This is a TUI application to play and manage anime with AniList for Linux systems

Tuikit is a TUI library for writing terminal UI applications

Support non-fullscreen mode as well as fullscreen mode

Tuikit is a TUI library for writing terminal UI applications
CLI

249

Ttyper is a terminal-based typing test built with Rust and tui-rs

For usage instructions, you can run ttyper --help

Ttyper is a terminal-based typing test built with Rust and tui-rs
Facebook Instagram Twitter GitHub Dribbble
Privacy