- Как установить заголовки ядра в Ubuntu и Debian
- Установите заголовки ядра в Ubuntu и Debian
- How To Install linux-headers-generic on Ubuntu 22.04
- What is linux-headers-generic
- Install linux-headers-generic Using apt-get
- Install linux-headers-generic Using apt
- Install linux-headers-generic Using aptitude
- How To Uninstall linux-headers-generic on Ubuntu 22.04
- Uninstall linux-headers-generic And Its Dependencies
- Remove linux-headers-generic Configurations and Data
- Remove linux-headers-generic configuration, data, and all of its dependencies
- References
- Summary
- How do I install kernel header files?
- Case of Obsolete kernel package
- Linux-Headers Reinstall
- 4 Answers 4
- Find linux-headers-4.4.0-98
- Install linux-headers-4.4.0-98
- Remove linux-headers-4.4.0-98
- Cleanup leftover garbage
Как установить заголовки ядра в Ubuntu и Debian
В нашей последней статье мы объяснили, как установить заголовки ядра в CentOS 7. Заголовки ядра содержат файлы заголовков C для ядра Linux, которые предлагают различные функции и структуру. определения, необходимые при компиляции любого кода, взаимодействующего с ядром, например, модулей ядра или драйверов устройств и некоторых пользовательских программ.
Очень важно отметить, что устанавливаемый вами пакет заголовков ядра должен совпадать с текущей установленной версией ядра в вашей системе. Если ваша версия ядра поставляется с установкой дистрибутива по умолчанию или вы обновили ядро с помощью dpkg или диспетчера пакетов apt из базовых репозиториев Ubuntu или Debian, то вы должны установить соответствующие заголовки ядра только с помощью диспетчера пакетов. И если вы скомпилировали ядро из исходников, вы также должны установить заголовки ядра из исходников.
В этой статье мы объясним, как установить Kernel Headers в дистрибутивах Ubuntu и Debian Linux с помощью диспетчера пакетов по умолчанию.
Установите заголовки ядра в Ubuntu и Debian
Сначала проверьте установленную версию ядра, а также пакет заголовка ядра, который соответствует вашей версии ядра, используя следующие команды.
$ uname -r $ apt search linux-headers-$(uname -r)
В Debian, Ubuntu и их производных все заголовочные файлы ядра можно найти в каталоге /usr/src. Вы можете проверить, установлены ли в вашей системе соответствующие заголовки ядра для вашей версии ядра, используя следующую команду.
$ ls -l /usr/src/linux-headers-$(uname -r)
Из приведенного выше вывода ясно, что соответствующий каталог заголовков ядра не существует, а это означает, что пакет еще не установлен.
Прежде чем вы сможете установить соответствующие заголовки ядра, обновите индекс пакетов, чтобы получить информацию о последних выпусках пакетов, используя следующую команду.
Затем выполните следующую команду, чтобы установить пакет заголовков ядра Linux для вашей версии ядра.
$ sudo apt install linux-headers-$(uname -r)
Затем проверьте, установлены ли в вашей системе соответствующие заголовки ядра, используя следующую команду.
$ ls -l /usr/src/linux-headers-$(uname -r)
Вот и все! В этой статье мы объяснили, как установить заголовки ядра в Ubuntu и Debian Linux и других дистрибутивах в генеалогическом дереве Debian.
Всегда помните, что для компиляции модуля ядра вам понадобятся заголовки ядра Linux. Если у вас есть какие-либо вопросы или мысли, которыми вы хотите поделиться, используйте форму комментариев ниже, чтобы связаться с нами.
How To Install linux-headers-generic on Ubuntu 22.04
In this tutorial we learn how to install linux-headers-generic on Ubuntu 22.04.
What is linux-headers-generic
This package will always depend on the latest generic kernel headers available.
There are three ways to install linux-headers-generic on Ubuntu 22.04. We can use apt-get , apt and aptitude . In the following sections we will describe each method. You can choose one of them.
Install linux-headers-generic Using apt-get
Update apt database with apt-get using the following command.
After updating apt database, We can install linux-headers-generic using apt-get by running the following command:
sudo apt-get -y install linux-headers-generic
Install linux-headers-generic Using apt
Update apt database with apt using the following command.
After updating apt database, We can install linux-headers-generic using apt by running the following command:
sudo apt -y install linux-headers-generic
Install linux-headers-generic Using aptitude
If you want to follow this method, you might need to install aptitude first since aptitude is usually not installed by default on Ubuntu. Update apt database with aptitude using the following command.
After updating apt database, We can install linux-headers-generic using aptitude by running the following command:
sudo aptitude -y install linux-headers-generic
How To Uninstall linux-headers-generic on Ubuntu 22.04
To uninstall only the linux-headers-generic package we can use the following command:
sudo apt-get remove linux-headers-generic
Uninstall linux-headers-generic And Its Dependencies
To uninstall linux-headers-generic and its dependencies that are no longer needed by Ubuntu 22.04, we can use the command below:
sudo apt-get -y autoremove linux-headers-generic
Remove linux-headers-generic Configurations and Data
To remove linux-headers-generic configuration and data from Ubuntu 22.04 we can use the following command:
sudo apt-get -y purge linux-headers-generic
Remove linux-headers-generic configuration, data, and all of its dependencies
We can use the following command to remove linux-headers-generic configurations, data and all of its dependencies, we can use the following command:
sudo apt-get -y autoremove --purge linux-headers-generic
References
Summary
In this tutorial we learn how to install linux-headers-generic package on Ubuntu 22.04 using different package management tools: apt, apt-get and aptitude.
How do I install kernel header files?
You should be able to install the kernel header files for the currently running kernel by running the following in a terminal:
sudo apt-get install linux-headers-$(uname -r)
In general, the kernel header packages are named linux-header-* where «*» indicates the version & variant (generic, server, etc.).
hey thanks but could you tell me what does generic, server, etc means i want to write (kernel driver)
This won’t install the headers for future updates automatically and you’ll have to re-run this command every time. Therefore, it’s recommended to install the metapackage instead, as described in another answer.
sudo apt-get install linux-headers-generic
if you are on a Desktop installation. The apt-get will solve the dependencies and install the correct version of kernel headers.
In Debian Wheezy I get the error message «Package linux-headers-generic is not available, but is referred to by another package. [. ] E: Package ‘linux-headers-generic’ has no installation candidate»
@IQAndreas the linux-headers-generic package is ubuntu specific. On Debian you should use sudo apt-get install linux-headers-$(uname -r)
I have linux-headers-generic installed on 18.04 but still don’t have the headers for the newest and current kernel version. Maybe it’s just a bug with this version, I’ve compiled kernel modules in earlier versions so I must’ve had the correct headers back then.
Case of Obsolete kernel package
This should cover another problem when: the currently running kernel is obsolete, meaning it’s not in the repository anymore neither its headers. So the best thing to do is to update the kernel to last version in the repository.
linux-generic is a meta package to keep current version of the kernel & its headers:
sudo apt-get update sudo apt-get install linux-generic
Note: Depending on your Ubuntu edition, See if you need linux-lowlatency (Ubuntu Studio), linux-signed-generic or linux-virtual .
Linux-Headers Reinstall
I’m trying upgrade firefox but says that i need to reinstall linux-headers 4.4.0-98.I tried to install but that’s it’s what happens ‘the package linux-headers needs to be reinstalled, but i can’t find an archive for it’.
can you paste the output of sudo apt-get install —reinstall linux-headers 4.4.0-98 to your question?
Building dependency tree Reading state information. Done E: the package linux-headers 4.4.0-98 needs to be reinstaled, but i can’t find an archive for it.
4 Answers 4
First try the fix-missing feature
sudo apt upgrade --fix-missing
Second, try to install headers from the command line:
Maybe you just need these specific headers (linux-headers-4.4.0-98-generic):
sudo apt install linux-headers-4.4.0-98-generic
If that doesn’t work, see what kernel type you are using (generic, lowlatency, etc.):
This will return something like «4.15.0-30-generic» or «4.15.0-30-lowlatency». Install/Reinstall the headers that correspond to your kernel type. Eg if it is the generic kernel (most likely):
sudo apt install --reinstall linux-headers-generic
This will cause the current headers for your current kernel to be automatically installed and upgraded.
If above doesn’t work, try the following:
sudo apt update && sudo apt upgrade
Reboot to ensure you are using latest kernel.
Purge out old headers and removed unused apps/kernels:
sudo apt remove --purge linux-headers-* sudo apt autoremove && sudo apt autoclean
sudo apt install linux-headers-generic
uname -r returned 4.4.0-98-generic but after typing the command keeps saying that needs to be reinstalled.
I don’t understand whats happening.Anything i try to do(install, upgrade) give me the same message, that linux-headers 4.4.0-98 needs to be reinstalled.
These commands worked for me.
Find linux-headers-4.4.0-98
$ apt-cache search linux-headers-4.4.0-98 linux-headers-4.4.0-98 - Header files related to Linux kernel version 4.4.0 linux-headers-4.4.0-98-generic - Linux kernel headers for version 4.4.0 on 64 bit x86 SMP linux-headers-4.4.0-98-lowlatency - Linux kernel headers for version 4.4.0 on 64 bit x86 SMP
Install linux-headers-4.4.0-98
For your reinstall you will type:
sudo apt install --reinstall linux-headers-4.4.0-98-generic
But for myself it’s a new package so I’ll use:
$ sudo apt install linux-headers-4.4.0-98-generic Reading package lists. Done Building dependency tree Reading state information. Done The following additional packages will be installed: linux-headers-4.4.0-98 The following NEW packages will be installed: linux-headers-4.4.0-98 linux-headers-4.4.0-98-generic 0 upgraded, 2 newly installed, 0 to remove and 0 not upgraded. Need to get 10.7 MB of archives. After this operation, 78.2 MB of additional disk space will be used. Do you want to continue? [Y/n] y Get:1 http://ca.archive.ubuntu.com/ubuntu xenial-updates/main amd64 linux-headers-4.4.0-98 all 4.4.0-98.121 [9,913 kB] Get:2 http://ca.archive.ubuntu.com/ubuntu xenial-updates/main amd64 linux-headers-4.4.0-98-generic amd64 4.4.0-98.121 [793 kB] Fetched 10.7 MB in 3s (3,463 kB/s) Selecting previously unselected package linux-headers-4.4.0-98. (Reading database . 288111 files and directories currently installed.) Preparing to unpack . /linux-headers-4.4.0-98_4.4.0-98.121_all.deb . Unpacking linux-headers-4.4.0-98 (4.4.0-98.121) . Selecting previously unselected package linux-headers-4.4.0-98-generic. Preparing to unpack . /linux-headers-4.4.0-98-generic_4.4.0-98.121_amd64.deb . Unpacking linux-headers-4.4.0-98-generic (4.4.0-98.121) . Setting up linux-headers-4.4.0-98 (4.4.0-98.121) . Setting up linux-headers-4.4.0-98-generic (4.4.0-98.121) . Examining /etc/kernel/header_postinst.d. run-parts: executing /etc/kernel/header_postinst.d/dkms 4.4.0-98-generic /boot/vmlinuz-4.4.0-98-generic
Remove linux-headers-4.4.0-98
Because this was a test and I don’t need them on my machine:
$ sudo apt remove --purge linux-headers-4.4.0-98-generic Reading package lists. Done Building dependency tree Reading state information. Done The following package was automatically installed and is no longer required: linux-headers-4.4.0-98 Use 'sudo apt autoremove' to remove it. The following packages will be REMOVED: linux-headers-4.4.0-98-generic* 0 upgraded, 0 newly installed, 1 to remove and 0 not upgraded. After this operation, 7,431 kB disk space will be freed. Do you want to continue? [Y/n] y (Reading database . 314874 files and directories currently installed.) Removing linux-headers-4.4.0-98-generic (4.4.0-98.121) . dpkg: warning: while removing linux-headers-4.4.0-98-generic, directory '/lib/modules/4.4.0-98-generic' not empty so not removed
Cleanup leftover garbage
I see there is left over garbage in the last line so I’ll manually clean it up:
$ sudo rm -rf /lib/modules/4.4.0-98-generic $ ll /lib/modules/4.4.0-98-generic ls: cannot access '/lib/modules/4.4.0-98-generic': No such file or directory
Now 4.4.0-98 is almost removed. It is completely removed with: