1、检查是否已经安装
使用dpkg-query命令检查是否有可用的内核头文件。
$ dpkg-query -s linux-headers-$(uname -r)
如果输出显示install ok installed说明已经安装成功
Package: linux-headers-4.15.0-142-generic
Status: install ok installed
2、安装内核头文件
$ sudo apt-get install linux-headers-$(uname -r)
3、验证头文件是否成功安装。
安装成功有如下提示:
$ dpkg-query -s linux-headers-$(uname -r)
Package: linux-headers-4.15.0-142-generic
Status: install ok installed
Priority: optional
Section: devel
Installed-Size: 12640
Maintainer: Ubuntu Kernel Team <kernel-team@lists.ubuntu.com>
Architecture: amd64
Source: linux-hwe
Version: 4.15.0-142.146~16.04.1
Provides: linux-headers, linux-headers-3.0
Depends: linux-headers-4.15.0-142, libc6 (>= 2.14), libelf1 (>= 0.142), libssl1.0.0 (>= 1.0.0)
Description: Linux kernel headers for version 4.15.0 on 64 bit x86 SMP
This package provides kernel header files for version 4.15.0 on
64 bit x86 SMP.
.
This is for sites that want the latest kernel headers. Please read
/usr/share/doc/linux-headers-4.15.0-142/debian.README.gz for details.
头文件默认在/usr/src下