title: Unable to insert module to kernel
body: <p>This is my introduction to kernel module. I'm following <a href="https://www.tldp.org/LDP/lkmpg/2.6/lkmpg.pdf" rel="nofollow noreferrer">The Linux Kernel Module Programming Guide</a> and just wrote my first simple module.</p>
  <p>This is my module file <code>hello.c</code>;</p>
  <pre><code>/*
  *  hello.c − The simplest kernel module. 
  */
  #include &lt;linux/module.h&gt;       /* Needed by all modules */
  #include &lt;linux/kernel.h&gt;       /* Needed for KERN_INFO */
  
  int init_module(void)
  {        
  printk(KERN_INFO &quot;Hello world 1.\n&quot;);        
  
  /*          
  * A non 0 return means init_module failed; module can't be loaded.          
  */        
  return 0;
  }
  
  void cleanup_module(void){
      printk(KERN_INFO &quot;Goodbye world 1.\n&quot;);
  }
  
  module_init(init_module);
  module_exit(cleanup_module);
  </code></pre>
  <p>here is my <code>Makefile</code></p>
  <pre><code>obj−m += hello.o
  
  all:
      make -C /lib/modules/$(shell uname -r)/build M=$(PWD) modules
  clean:
      make -C /lib/modules/$(shell uname -r)/build M=$(PWD) clean
  </code></pre>
  <p>when I run <code>make</code> command, this is what I get..</p>
  <blockquote>
  <p>make -C /lib/modules/4.15.0-45-generic/build M=/home/nailaakbar modules</p>
  <p>make<a href="https://www.tldp.org/LDP/lkmpg/2.6/lkmpg.pdf" rel="nofollow noreferrer">1</a>: Entering directory '/usr/src/linux-headers-4.15.0-45-generic'</p>
  <p>Building modules, stage 2.</p>
  <p>MODPOST 0 modules</p>
  <p>make<a href="https://www.tldp.org/LDP/lkmpg/2.6/lkmpg.pdf" rel="nofollow noreferrer">1</a>: Leaving directory '/usr/src/linux-headers-4.15.0-45-generic'</p>
  </blockquote>
  <p><a href="https://i.stack.imgur.com/GfZrX.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/GfZrX.png" alt="make result" /></a></p>
  <p>but now when I try to insert it in kernel by using this command;</p>
  <pre><code>sudo insmod hello.k
  </code></pre>
  <p>I got this error</p>
  <blockquote>
  <p>insmod: ERROR: could not load module hello.ko: No such file or directory</p>
  </blockquote>
  <p>I've tried different solutions like making both functions static, or changing files location but nothing worked out.</p>
  <blockquote>
  <p>Currently I'm running all these commands on Desktop and I'm using dual
  boot for linux environment.</p>
  </blockquote>
  <p>Can anyone help me out that what I'm doing wrong here??</p>
  <p><strong>Possible duplicate question actually solved my issue but it was not directly my issue. I went through that question during my issue searching but couldn't get the idea. It was actually one comment on my question, that changed my view for error and then that mentioned answer resolved my issue.</strong></p>