realksh(8)
π realksh(8) β the manual page, but make it make sense
okay bestie, pull up a chair, we're talking about realksh π¦
β¨ NAME β¨
realksh.c β a shell for running Kernel-mode C code π
β¨ SYNOPSIS β¨
realksh.c
that's it. that's the whole synopsis. iconic behavior honestly πΈ
β¨ DESCRIPTION β¨
so realksh.c is an interactive shell that runs C source code, no cap. every line you type gets treated as a line inside the module_init() function, and the C code that comes out of it gets compiled into a kernel module. then that module gets inserted into the kernel, and then removed from the kernel. that's the whole loop. it's giving compile-insert-remove, compile-insert-remove π«
and because debugging kernel stuff blind is a nightmare, any kernel message output that's prepended with KMSG: gets copied over to standard out for convenience β so functions like printk are right there for easy debugging. literally your little bestie for printf-style snooping π
now here's a cute little trick: if you enter a line starting with #, like #include <stdio.h>, that line gets added to every code after that at the start of sourcecode. so it sticks around for everything you write from then on. very "set it and forget it" energy β¨
you can see the whole list of those lines with ## π
β¨ EXAMPLES β¨
here's an example session, look at her go π
$ sudo ./realksh.c
REAL ksh: printk ("hello\n");
Building modules, stage 2.
KMSG: <4>hello
REAL ksh: printk ("%x\n", mfmsr());
Building modules, stage 2.
KMSG: <4>9032
REAL ksh: printk ("%x\n", mfspr(SPRN_MMCR0));
Building modules, stage 2.
KMSG: <4>0
REAL ksh:
the way it just prints your hex and moves onβ¦ main character energy, fr fr π₯
β¨ INTERNALS β¨
okay so here's what the C code actually looks like under the hood π«Ά
#include <linux/module.h>
#include <linux/init.h>
MODULE_AUTHOR("dancerj");
MODULE_DESCRIPTION("....");
MODULE_LICENSE("GPL");
static int __init realkshmod2_init(void)
{
input-line
return 0;
}
static void __exit realkshmod2_cleanup(void)
{
}
module_init(realkshmod2_init);
module_exit(realkshmod2_cleanup);
see how your input-line just slots right in there? you're basically writing a function body and the shell handles all the boilerplate for you. chef's kiss π
β¨ AUTHOR β¨
Junichi Uekawa (dancer@debian.org) β the legend themselves π
the upstream page is available at http://www.netfort.gr.jp/~dancer/software/ β go say hi π
β¨ SEE ALSO β¨
and that's the whole vibe check bestie π¦ this page came from binfmt_misc, written by Dancer, dated 2006 Jan 1, and it lives as realksh(8). stay slay, keep your modules GPL'd, and never forget to remove what you inserted ππ
π¦ where this page comes from
- debian bookworm: binfmtc 0.17-2.2
- debian trixie: binfmtc 0.17-4 Β· GPL-2.0-or-later
- ubuntu jammy: binfmtc 0.17-2
- ubuntu noble: binfmtc 0.17-2.3
- ubuntu questing: binfmtc 0.17-4
- ubuntu resolute: binfmtc 0.17-4build1 Β· GPL-2.0-or-later
- ubuntu stonking: binfmtc 0.17-6 Β· GPL-2.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms