{"id":12912,"date":"2019-03-29T02:18:40","date_gmt":"2019-03-29T02:18:40","guid":{"rendered":"http:\/\/www.appservgrid.com\/paw92\/?p=12912"},"modified":"2019-03-29T02:18:40","modified_gmt":"2019-03-29T02:18:40","slug":"how-to-install-kernel-headers-in-centos-7","status":"publish","type":"post","link":"https:\/\/www.appservgrid.com\/paw92\/index.php\/2019\/03\/29\/how-to-install-kernel-headers-in-centos-7\/","title":{"rendered":"How to Install Kernel Headers in CentOS 7"},"content":{"rendered":"<p>When you compile a custom kernel module such as device driver on a\u00a0<strong>CentOS<\/strong>\u00a0system, you need to have kernel header files installed on the system, which include the\u00a0<strong>C<\/strong>\u00a0header files for the Linux kernel. Kernel header files provide different kinds of function and structure definitions required when installing or compiling any code that interfaces with the kernel.<\/p>\n<p>When you install\u00a0<strong>Kernel Headers<\/strong>, make sure it matches with the currently installed kernel version on the system. If your Kernel version comes with the default distribution installation or you have\u00a0<a href=\"https:\/\/www.tecmint.com\/install-upgrade-kernel-version-in-centos-7\/\" target=\"_blank\" rel=\"noopener\">upgraded your Kernel using yum package manager<\/a>\u00a0from system base repositories, then you must install matching kernel headers using package manager only. If you\u2019ve compiled Kernel from sources, you can install kernel headers from sources only.<\/p>\n<p><strong>Read Also<\/strong>:\u00a0<a href=\"https:\/\/www.tecmint.com\/install-kernel-headers-in-ubuntu-and-debian\/\" target=\"_blank\" rel=\"noopener\">How to Install Kernel Headers in Ubuntu and Debian<\/a><\/p>\n<p>In this article, we will explain how to install\u00a0<strong>Kernel Headers<\/strong>\u00a0in\u00a0<strong>CentOS\/RHEL 7<\/strong>\u00a0and\u00a0<strong>Fedora<\/strong>\u00a0distributions using default package manager.<\/p>\n<h3>Install Kernel Headers in CentOS 7<\/h3>\n<p>First confirm that the matching kernel headers are already installed under\u00a0<strong>\/usr\/src\/kernels\/<\/strong>\u00a0location on your system using following commands.<\/p>\n<pre># cd \/usr\/src\/kernels\/\r\n# ls -l\r\n<\/pre>\n<div id=\"attachment_29542\" class=\"wp-caption aligncenter\">\n<p><a href=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2018\/05\/Check-Kernel-Headers-in-CentOS.png\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-29542\" src=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2018\/05\/Check-Kernel-Headers-in-CentOS.png\" alt=\"Check Kernel Headers in CentOS 7\" width=\"454\" height=\"86\" aria-describedby=\"caption-attachment-29542\" data-lazy-loaded=\"true\" \/><\/a><\/p>\n<p id=\"caption-attachment-29542\" class=\"wp-caption-text\">Check Kernel Headers in CentOS 7<\/p>\n<\/div>\n<p>If no matching kernel headers are located in the\u00a0<strong>\/usr\/src\/kernels\/<\/strong>\u00a0directory, go ahead and install kernel headers, which is provided by the\u00a0<strong>kernel-devel<\/strong>\u00a0package that can be installed using default package manager as shown.<\/p>\n<pre># yum install kernel-devel   [<strong>On CentOS\/RHEL 7<\/strong>]\r\n# dnf install kernel-devel   [<strong>On Fedora 22+<\/strong>]\r\n<\/pre>\n<div id=\"attachment_29543\" class=\"wp-caption aligncenter\">\n<p><a href=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2018\/05\/Install-Kernel-Headers-in-CentOS.png\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-29543\" src=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2018\/05\/Install-Kernel-Headers-in-CentOS.png\" sizes=\"auto, (max-width: 1103px) 100vw, 1103px\" srcset=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2018\/05\/Install-Kernel-Headers-in-CentOS.png 1103w, https:\/\/www.tecmint.com\/wp-content\/uploads\/2018\/05\/Install-Kernel-Headers-in-CentOS-768x402.png 768w\" alt=\"Install Kernel Headers in CentOS 7\" width=\"1103\" height=\"578\" aria-describedby=\"caption-attachment-29543\" data-lazy-loaded=\"true\" \/><\/a><\/p>\n<p id=\"caption-attachment-29543\" class=\"wp-caption-text\">Install Kernel Headers in CentOS 7<\/p>\n<\/div>\n<p>After installing the\u00a0<strong>kernel-devel<\/strong>\u00a0package, you can find all the kernel headers files in\u00a0<strong>\/usr\/src\/kernels<\/strong>\u00a0directory using following command.<\/p>\n<pre># ls -l \/usr\/src\/kernels\/$(uname -r) \r\n<\/pre>\n<p>Note on a\u00a0<strong>VPS<\/strong>\u00a0(for instance a\u00a0<a href=\"https:\/\/www.linode.com\/?r=64ebb9f723fed8b32fda84b6594006df08ad24b6\" target=\"_blank\" rel=\"nofollow noopener\">Linode VPS<\/a>), a kernel may have a customized version name, in such scenario, you have to identify the kernel version manually and check the installed kernel header files using following commands.<\/p>\n<pre># uname -r\t\r\n# ls -l \/usr\/src\/kernels\/3.10.0-862.2.3.el7.x86_64\r\n<\/pre>\n<div id=\"attachment_29547\" class=\"wp-caption aligncenter\">\n<p><a href=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2018\/05\/Check-Kernel-Version-in-CentOS-7.png\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-29547\" src=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2018\/05\/Check-Kernel-Version-in-CentOS-7.png\" alt=\"Check Kernel Version in CentOS 7\" width=\"263\" height=\"40\" aria-describedby=\"caption-attachment-29547\" data-lazy-loaded=\"true\" \/><\/a><\/p>\n<p id=\"caption-attachment-29547\" class=\"wp-caption-text\">Check Kernel Version in CentOS 7<\/p>\n<\/div>\n<h5>Sample Output<\/h5>\n<pre>total 4544\r\ndrwxr-xr-x.  32 root root    4096 May 16 12:48 arch\r\ndrwxr-xr-x.   3 root root    4096 May 16 12:48 block\r\ndrwxr-xr-x.   4 root root    4096 May 16 12:48 crypto\r\ndrwxr-xr-x. 119 root root    4096 May 16 12:48 drivers\r\ndrwxr-xr-x.   2 root root    4096 May 16 12:48 firmware\r\ndrwxr-xr-x.  75 root root    4096 May 16 12:48 fs\r\ndrwxr-xr-x.  28 root root    4096 May 16 12:48 include\r\ndrwxr-xr-x.   2 root root    4096 May 16 12:48 init\r\ndrwxr-xr-x.   2 root root    4096 May 16 12:48 ipc\r\n-rw-r--r--.   1 root root     505 May  9 19:21 Kconfig\r\ndrwxr-xr-x.  12 root root    4096 May 16 12:48 kernel\r\ndrwxr-xr-x.  10 root root    4096 May 16 12:48 lib\r\n-rw-r--r--.   1 root root   51205 May  9 19:21 Makefile\r\n-rw-r--r--.   1 root root    2305 May  9 19:21 Makefile.qlock\r\ndrwxr-xr-x.   2 root root    4096 May 16 12:48 mm\r\n-rw-r--r--.   1 root root 1093137 May  9 19:21 Module.symvers\r\ndrwxr-xr-x.  60 root root    4096 May 16 12:48 net\r\ndrwxr-xr-x.  14 root root    4096 May 16 12:48 samples\r\ndrwxr-xr-x.  13 root root    4096 May 16 12:48 scripts\r\ndrwxr-xr-x.   9 root root    4096 May 16 12:48 security\r\ndrwxr-xr-x.  24 root root    4096 May 16 12:48 sound\r\n-rw-r--r--.   1 root root 3409102 May  9 19:21 System.map\r\ndrwxr-xr-x.  17 root root    4096 May 16 12:48 tools\r\ndrwxr-xr-x.   2 root root    4096 May 16 12:48 usr\r\ndrwxr-xr-x.   4 root root    4096 May 16 12:48 virt\r\n-rw-r--r--.   1 root root      41 May  9 19:21 vmlinux.id\r\n<\/pre>\n<p>In addition, if you need\u00a0<strong>header files<\/strong>\u00a0for the Linux kernel for use by\u00a0<strong>glibc<\/strong>, install the\u00a0<strong>kernel-header<\/strong>\u00a0package using following command.<\/p>\n<pre># yum install kernel-headers   [<strong>On CentOS\/RHEL 7<\/strong>]\r\n# dnf install kernel-headers   [<strong>On Fedora 22+<\/strong>]\r\n<\/pre>\n<p>Now you are good to go with compiling your own or existing kernel modules for software such as\u00a0<a href=\"https:\/\/www.tecmint.com\/install-virtualbox-on-redhat-centos-fedora\/\" target=\"_blank\" rel=\"noopener\">VirtualBox<\/a>and many more.<\/p>\n<p>That\u2019s it! In this article, we have explained how to install\u00a0<strong>kernel-devel<\/strong>\u00a0and\u00a0<strong>kernel-header<\/strong>\u00a0packages in\u00a0<strong>CentOS\/RHEL 7<\/strong>\u00a0and\u00a0<strong>Fedora<\/strong>\u00a0systems. Remember that before you can compile kernel modules such as device driver on a Linux system, you should have necessary kernel header files installed. If you have queries, please use the comment form below to reach us.<\/p>\n<p><a href=\"https:\/\/www.tecmint.com\/install-kernel-headers-in-centos-7\/\" target=\"_blank\" rel=\"noopener\">Source<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>When you compile a custom kernel module such as device driver on a\u00a0CentOS\u00a0system, you need to have kernel header files installed on the system, which include the\u00a0C\u00a0header files for the Linux kernel. Kernel header files provide different kinds of function and structure definitions required when installing or compiling any code that interfaces with the kernel. &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-centos-7\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;How to Install Kernel Headers in CentOS 7&#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-12912","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\/12912","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=12912"}],"version-history":[{"count":1,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/posts\/12912\/revisions"}],"predecessor-version":[{"id":12913,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/posts\/12912\/revisions\/12913"}],"wp:attachment":[{"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/media?parent=12912"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/categories?post=12912"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/tags?post=12912"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}