get kernel source code

7,480

You could just use apt to get the source, check that the file /etc/apt/sources.list contains a line starting with

deb-src 

and then use the command:

apt-get update
#if you want to download the source into the current directory use:
apt-get source linux-image-$(uname -r)
#if you want the source to be installed in the system directory use:
apt-get install linux-source-$(uname -r)

It will download the source in the folder:

/usr/src or /usr/sources
Share:
7,480

Related videos on Youtube

Luca Davanzo
Author by

Luca Davanzo

I'm a software developer and I've worked mainly on interactive multimedia applications. Actually I'm an iOS developer. SOreadytohelp

Updated on September 18, 2022

Comments

  • Luca Davanzo
    Luca Davanzo over 1 year

    I need a specific kernel version to compile it with some additional modules.

    When I typing:

    uname -r
    

    I get

    3.8.0-29-generic
    

    I need this one.

     uname -a
     Linux "..." 3.8.0-29-generic #42~precise1-Ubuntu SMP Wed Aug 14 16:19:23 UTC 2013 x86_64 x86_64 x86_64 GNU/Linux
    

    Where can I find this version? Here https://www.kernel.org/ seems that there isn't..

    • YoloTats.com
      YoloTats.com almost 10 years
      Sometimes it is enough to install the kernel headers with apt-get install linux-headers-$(uname -r).
  • YoloTats.com
    YoloTats.com almost 10 years
    The answer is not fully correct - it mixes two things. apt-get source downloads the package source files into the current directory. /usr/src is only filled if you are installing the source package with apt-get install linux-source-$(uname -r).
  • S edwards
    S edwards almost 10 years
    @jofel thank you for the precision, I corrected my answer