How do I create a kernel module without the use of sudo? I know the normal way(sudo insmod, sudo rmmod), but we're not allowed to use sudo in school.


First off, what module do you want to insert and why? Normally there is no need to manually remove / insert modules. By the way, creating a module is a different story, insmod and rmmod are for loading / unloading a particular module (created by someone else).

Once you got your reasons straight, and are sure that there is no other way... then go to your system administrator and ask politely. Explain clearly your reasons, and you have a chance to succeed. No joke: unless you want to go against all rules (and some laws, probably) and hack the machine belonging to your school, you will not acquire privileges granting you such a low level operation.

  • Actually I'm just going to print the value of the page size of the Linux machine I am currently using. We're asked to demonstrate it with the use of kernel module. Aren't there any other way besides hacking and sudo? – Sudoer Sep 11 '12 at 1:41
  • 3
    You need to be root to play with the kernel. Sudo is just a way of doing that. Logging in as root is another. Having a suid insmod is another. And su is yet another. Yet I'm still wondering as to what kernel module you are referring to. Finding out the page size is as simple as typing getconf PAGESIZE. You might be on a wrong track... – January Sep 11 '12 at 2:11
  • One module in particular that it would be nice to remove and insert without sudo would be the pcspkr module to allow beep sometimes but not all of the time as it can get annoying. – mchid Jul 11 '16 at 21:15

Perhaps an easier way forward is to do the kernel development inside a virtual machine; I use virt-manager + kvm-qemu, but there are other options such as VirtualBox. This allow can then allow you to do all the development in a safe virtualized environment and maybe allowed by your system administrator.

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.