{"id":12910,"date":"2019-03-29T02:15:28","date_gmt":"2019-03-29T02:15:28","guid":{"rendered":"http:\/\/www.appservgrid.com\/paw92\/?p=12910"},"modified":"2019-03-29T02:15:28","modified_gmt":"2019-03-29T02:15:28","slug":"how-to-install-kernel-headers-in-ubuntu-and-debian","status":"publish","type":"post","link":"https:\/\/www.appservgrid.com\/paw92\/index.php\/2019\/03\/29\/how-to-install-kernel-headers-in-ubuntu-and-debian\/","title":{"rendered":"How to Install Kernel Headers in Ubuntu and Debian"},"content":{"rendered":"<p><strong>Kernel Headers<\/strong>\u00a0contain the\u00a0<strong>C<\/strong>header files for the Linux kernel, which offers the various function and structure definitions required when compiling any code that interfaces with the kernel, such as kernel modules or device drivers and some user programs.<\/p>\n<p>It is very important to note that the kernel headers package you install should match with the currently installed kernel version on your system. If your kernel version ships with the default distribution installation or you have\u00a0<a href=\"https:\/\/www.tecmint.com\/upgrade-kernel-in-ubuntu\/\" target=\"_blank\" rel=\"noopener\">upgraded your Kernel using dpkg or apt<\/a>\u00a0package manager from the Ubuntu or Debian base repositories, then you must install matching kernel headers using package manager only. And if you\u2019ve compiled kernel from sources, you must also install kernel headers from sources.<\/p>\n<p>In this article, we will explain how to install\u00a0<strong>Kernel Headers<\/strong>\u00a0in\u00a0<strong>Ubuntu<\/strong>\u00a0and\u00a0<strong>Debian<\/strong>\u00a0Linux distributions using default package manager.<\/p>\n<h3>Install Kernel Headers in Ubuntu and Debian<\/h3>\n<p>First check your installed kernel version as well as kernel header package that matches your kernel version using following commands.<\/p>\n<pre>$ uname -r\r\n$ apt search linux-headers-$(uname -r)\r\n<\/pre>\n<div id=\"attachment_29569\" class=\"wp-caption aligncenter\">\n<p><a href=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2018\/05\/Check-Kernel-Version-and-Kernel-Headers-in-Ubuntu.png\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-29569\" src=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2018\/05\/Check-Kernel-Version-and-Kernel-Headers-in-Ubuntu.png\" alt=\"Check Kernel Version and Kernel Headers in Ubuntu\" width=\"742\" height=\"249\" aria-describedby=\"caption-attachment-29569\" data-lazy-loaded=\"true\" \/><\/a><\/p>\n<p id=\"caption-attachment-29569\" class=\"wp-caption-text\">Check Kernel Version and Kernel Headers in Ubuntu<\/p>\n<p>&nbsp;<\/p>\n<\/div>\n<p>On\u00a0<strong>Debian<\/strong>,\u00a0<strong>Ubuntu<\/strong>\u00a0and their derivatives, all kernel header files can be found under\u00a0<strong>\/usr\/src<\/strong>\u00a0directory. You can check if the matching kernel headers for your kernel version are already installed on your system using the following command.<\/p>\n<pre>$ ls -l \/usr\/src\/linux-headers-$(uname -r)\r\n<\/pre>\n<div id=\"attachment_29570\" class=\"wp-caption aligncenter\">\n<p><a href=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2018\/05\/Check-Kernel-Headers-in-Ubuntu.png\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-29570\" src=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2018\/05\/Check-Kernel-Headers-in-Ubuntu.png\" sizes=\"auto, (max-width: 872px) 100vw, 872px\" srcset=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2018\/05\/Check-Kernel-Headers-in-Ubuntu.png 872w, https:\/\/www.tecmint.com\/wp-content\/uploads\/2018\/05\/Check-Kernel-Headers-in-Ubuntu-768x102.png 768w\" alt=\"Check Kernel Headers in Ubuntu\" width=\"872\" height=\"116\" aria-describedby=\"caption-attachment-29570\" data-lazy-loaded=\"true\" \/><\/a><\/p>\n<p id=\"caption-attachment-29570\" class=\"wp-caption-text\">Check Kernel Headers in Ubuntu<\/p>\n<\/div>\n<p>From the above output, it\u2019s clear that the matching kernel header directory doesn\u2019t exist, meaning the package is not yet installed.<\/p>\n<p>Before you can install the appropriate kernel headers, update your packages index, in order to grab information about the latest package releases, using the following command.<\/p>\n<pre>$ sudo apt update\r\n<\/pre>\n<p>Then run the following command that follows to install the Linux Kernel headers package for your kernel version.<\/p>\n<pre>$ sudo apt install linux-headers-$(uname -r)\r\n<\/pre>\n<div id=\"attachment_29571\" class=\"wp-caption aligncenter\">\n<p><a href=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2018\/05\/Install-Kernel-Headers-in-Ubuntu.png\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-29571\" src=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2018\/05\/Install-Kernel-Headers-in-Ubuntu.png\" sizes=\"auto, (max-width: 872px) 100vw, 872px\" srcset=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2018\/05\/Install-Kernel-Headers-in-Ubuntu.png 872w, https:\/\/www.tecmint.com\/wp-content\/uploads\/2018\/05\/Install-Kernel-Headers-in-Ubuntu-768x403.png 768w\" alt=\"Install Kernel Headers in Ubuntu\" width=\"872\" height=\"458\" aria-describedby=\"caption-attachment-29571\" data-lazy-loaded=\"true\" \/><\/a><\/p>\n<p id=\"caption-attachment-29571\" class=\"wp-caption-text\">Install Kernel Headers in Ubuntu<\/p>\n<\/div>\n<p>Next, check if the matching kernel headers have been installed on your system using the following command<\/p>\n<pre>$ ls -l \/usr\/src\/linux-headers-$(uname -r)\r\n<\/pre>\n<div id=\"attachment_29572\" class=\"wp-caption aligncenter\">\n<p><a href=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2018\/05\/Verify-Installed-Kernel-Headers.png\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-29572\" src=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2018\/05\/Verify-Installed-Kernel-Headers.png\" sizes=\"auto, (max-width: 1012px) 100vw, 1012px\" srcset=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2018\/05\/Verify-Installed-Kernel-Headers.png 1012w, https:\/\/www.tecmint.com\/wp-content\/uploads\/2018\/05\/Verify-Installed-Kernel-Headers-768x506.png 768w\" alt=\"Verify Installed Kernel Headers in Ubuntu\" width=\"1012\" height=\"667\" aria-describedby=\"caption-attachment-29572\" data-lazy-loaded=\"true\" \/><\/a><\/p>\n<p id=\"caption-attachment-29572\" class=\"wp-caption-text\">Verify Installed Kernel Headers in Ubuntu<\/p>\n<\/div>\n<p>That\u2019s all! In this article, we have explained how to install kernel headers in\u00a0<strong>Ubuntu<\/strong>\u00a0and\u00a0<strong>Debian<\/strong>\u00a0Linux and other distributions in the Debian family tree.<\/p>\n<p>Always keep in mind that to compile a kernel module, you will need the Linux kernel headers. If you have any quires, or thoughts to share, use the comment form below to reach us.<\/p>\n<p><a href=\"https:\/\/www.tecmint.com\/install-kernel-headers-in-ubuntu-and-debian\/\" target=\"_blank\" rel=\"noopener\">Source<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Kernel Headers\u00a0contain the\u00a0Cheader files for the Linux kernel, which offers the various function and structure definitions required when compiling any code that interfaces with the kernel, such as kernel modules or device drivers and some user programs. It is very important to note that the kernel headers package you install should match with the currently &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/www.appservgrid.com\/paw92\/index.php\/2019\/03\/29\/how-to-install-kernel-headers-in-ubuntu-and-debian\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;How to Install Kernel Headers in Ubuntu and Debian&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-12910","post","type-post","status-publish","format-standard","hentry","category-linux"],"_links":{"self":[{"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/posts\/12910","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/comments?post=12910"}],"version-history":[{"count":1,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/posts\/12910\/revisions"}],"predecessor-version":[{"id":12911,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/posts\/12910\/revisions\/12911"}],"wp:attachment":[{"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/media?parent=12910"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/categories?post=12910"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/tags?post=12910"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}