Linux Kernel Module Programming — Simplest example

  • C programming language
  • Makefiles
#include <linux/init.h>
#include <linux/module.h>
#include <linux/kernel.h>
MODULE_AUTHOR("Sachith Muhandiram");
MODULE_DESCRIPTION("Simple first Linux module");
static int __init initHelloWorld(void){
printk(KERN_INFO "Hello, this is my first kernel module \n");
return 0;
static void __exit exitHelloWorld(void){
printk(KERN_INFO "Exit Hello world module\n");
obj-m += hello.oall:
make -C /lib/modules/$(shell uname -r)/build M=$(PWD) modules
make -C /lib/modules/$(shell uname -r)/build M=$(PWD) clean



Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Sachith Muhandiram

Sachith Muhandiram

DevOps who is willing to learn and try new things.