查看linux内核头文件linux-headers-generic是否安装
2022-10-13 15:43阅读:
一般的检查指令
下面我列举一些快速查询linux的内核版本信息的指令
~$ uname -srm
Linux 5.13.0-35-generic x86_64
~$ uname -r
5.13.0-35-generic
~$ echo linux-headers-$(uname -r)
linux-headers-5.13.0-35-generic
~$ hostnamectl
Static hostname: FX506HCB
Icon name:
computer-laptop
Chassis:
laptop
Machine ID:
a1e5f77b6e384b5c934bfb1d5bfedfaa
Boot ID:
acd777ad7ef940a5bc02a0a09d1df9e9
Operating System: Ubuntu 20.04.3 LTS
Kernel: Linux
5.13.0-35-generic
Architecture: x86-64
~$ hostnamectl | grep -i kernel
Kernel: Linux
5.13.0-35-generic
~$ cat /proc/version
Linux version 5.13.0-35-generic (buildd@ubuntu) (gcc (Ubuntu
9.3.0-17ubuntu1~20.04) 9.3.0, GNU ld (GNU Binutils
for Ubuntu) 2.34) #40~20.04.1-Ubuntu SMP Mon Mar 7 09:18:32 UTC
2022
检查是否安装:
~$ dpkg-query -s linux-headers-$(uname -r)
Package: linux-headers-5.4.0-126-generic
Status: install ok installed
Priority: optional
Section: devel
Installed-Size: 14711
Maintainer: Ubuntu Kernel Team
Architecture: amd64
Source: linux
Version: 5.4.0-126.142
Provides: linux-headers, linux-headers-3.0
Depends: linux-headers-5.4.0-126, libc6 (>= 2.14), libelf1
(>= 0.142), libssl1.1 (>= 1.1.0)
Description: Linux kernel headers for version 5.4.0 on 64 bit x86
SMP
This package provides kernel header files for version 5.4.0
on
64 bit x86 SMP.
.
This is for sites that want the latest kernel headers.
Please read
/usr/share/doc/linux-headers-5.4.0-126/debian.README.gz for
details.
~$ dpkg-query -s linux-headers-4.15.0-193-generic
Package: linux-headers-4.15.0-193-generic
Status: install ok installed
Priority: optional
Section: devel
Installed-Size: 13328
Maintainer: Ubuntu Kernel Team
Architecture: amd64
Source: linux
Version: 4.15.0-193.204
Provides: linux-headers, linux-headers-3.0
Depends: linux-headers-4.15.0-193, libc6 (>= 2.14), libelf1
(>= 0.142), libssl1.1 (>= 1.1.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-193/debian.README.gz for
details.
没有安装的样子:
~$ dpkg-query -s linux-headers-$(uname -r)
dpkg-query: package 'linux-headers-4.15.0-194-generic' is not
installed and no information is available
Use dpkg --info (= dpkg-deb --info) to examine archive files,
and dpkg --contents (= dpkg-deb --contents) to list their
contents.
安装内核头文件
~$ sudo apt-get install build-essential //install
build-essential(optional)
~$ sudo apt-get update
//install linux-headers
~$ sudo apt-get install linux-headers-$(uname -r)
或者,
~$ sudo apt-get update && sudo apt-get install
build-essential linux-headers-$(uname -r)
是否要升级安装
值得说明的是,我发现
sudo apt install linux-headers-generic
和
sudo apt-get install linux-headers-$(uname -r)
会安装不同版本的头文件,如下,
~$ sudo apt install linux-headers-generic
...
将会同时安装下列软件:
linux-headers-5.4.0-104
linux-headers-5.4.0-104-generic
下列【新】软件包将被安装:
linux-headers-5.4.0-104 linux-headers-5.4.0-104-generic
linux-headers-generic
...
您希望继续执行吗? [Y/n] n
~$ sudo apt install linux-headers-$(uname -r)
...
linux-headers-5.13.0-35-generic 已经是最新版
(5.13.0-35.40~20.04.1)。
linux-headers-5.13.0-35-generic 已设置为手动安装。
升级了 0 个软件包,新安装了 0 个软件包,要卸载 0 个软件包,有 0 个软件包未被升级。
这两个指令的不同之处在于,下面的指令
sudo apt install linux-headers-generic
sudo apt install --reinstall
linux-headers-generic
会自动安装并升级你的内核头文件,而
apt install linux-headers-$(uname -r)
这个指令不会升级你的头文件。
————————————————
版权声明:本文为CSDN博主「高精度计算机视觉」的原创文章,遵循CC 4.0
BY-SA版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/tanmx219/article/details/123510743