HowTo: Ubuntu Linux Install Kernel Source Code And Headers

See all Ubuntu Linux related FAQ
How do I install Linux kernel source with Ubuntu patches? How can I install Ubuntu Linux kernel source code tree for version 2.6.3x using command line options?

You need to use the apt-get command to install Linux kernel source code. Open the terminal and type the following commands to install Ubuntu Linux source code:
$ sudo apt-get update
$ sudo apt-get install linux-source

Sample outputs:
Advertisement

Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following extra packages will be installed:
  linux-source-2.6.32
Suggested packages:
  libncurses-dev ncurses-dev kernel-package libqt3-dev
The following NEW packages will be installed:
  linux-source linux-source-2.6.32
0 upgraded, 2 newly installed, 0 to remove and 0 not upgraded.
Need to get 65.9MB of archives.
After this operation, 66.0MB of additional disk space will be used.
Do you want to continue [Y/n]? y 

🥺 Was this helpful? Please add a comment to show your appreciation or feedback.

nixCrat Tux Pixel Penguin
Hi! 🤠
I'm Vivek Gite, and I write about Linux, macOS, Unix, IT, programming, infosec, and open source. Subscribe to my RSS feed or email newsletter for updates.

7 comments… add one
  • Divyans Oct 14, 2012 @ 12:52

    Gr8! Thanks..

  • JCD Mar 20, 2013 @ 19:34

    Thank you, after a few hours of frustration, these instruction did the trick.

  • root Apr 16, 2013 @ 14:26

    s/sudp/sudo/

    • 🛡️ Vivek Gite (Author and Admin) nixCraft Apr 17, 2013 @ 9:06

      Thanks for the heads up!

  • dave May 29, 2014 @ 15:20

    Great, but what directory are the source files stored in?

    • doesn't matter Sep 1, 2014 @ 15:16

      you can find those under /usr/src/

  • Umer Apr 22, 2015 @ 18:39

    unable to connect to 10.0.11.21 error while executing apt-get source command

Leave a Reply

Your email address will not be published. Required fields are marked *

Use HTML <pre>...</pre> for code samples. Your comment will appear only after approval by the site admin.