**** #include <linux/init.h> #include <linux/module.h> /*MODULE_LICENSE("Dual BSD/GPL");*/ static int hello_init(void) { printk(KERN_ALERT "Hello, world\n"); return 0; } static void hello_exit(void) { printk(KERN_ALERT "Goodbye, cruel world\n"); } module_init(hello_init); module_exit(hello_exit);
=======================================
now create a file for ubuntu
/ * for the first type on the ur terminal that $ (uname -r), then u will get the version. which uses ur system * /
obj-m +=basic.o KDIR =//usr/src/linux-headers-3.13.0-44-generic all: $(MAKE) -C $(KDIR) SUBDIRS=$(PWD) modules clean: rm -rf *.o *.ko *.mod.* *.symvers *.order
================================================= =
To run the code
$sudo insmode basic.ko $dmesg u will get the output $sudo rmmod basic.ko $dmesg
source share