6.6 KiB
title | author | categories | tags | |||
---|---|---|---|---|---|---|
Lynne Teaches Tech: What is the Linux kernel? | Lynne |
|
|
Our first survey question! The submitted question asked:
- What is the Linux kernel?
- Why does apt make me install a new one every month or so?
- Why do the old ones stick around and waste space?
We'll be answering all three of these questions. Let's start with the first one.
What is the Linux kernel?
The kernel is the underlying part of a computer that makes all the low level stuff work. Things like reading files, managing which programs are running, and keeping track of memory usage are handled by the kernel.
Almost every operating system has a kernel - Windows uses the NT kernel, macOS uses the XNU kernel, and Linux distributions (including Android!) use the Linux kernel.
The kernel handles communication between the software running on your computer and the hardware your computer is made with, so you won't get far without it. This also means you can't swap it out while your computer's running, so if you update the kernel using apt (or otherwise), you'll need to restart afterwards, even if the computer doesn't tell you to (or force you to).
Note: There are methods of replacing the Linux kernel while the system is still running, but that is beyond the scope of this post.
When the kernel encounters a critical failure that it can't recover from, your computer will stop working. On Windows computers, this is known as a stop error, and when a stop error occurs, Windows will display...
This happens (much less frequently) on Linux systems too, with a much less visually appealing (although more informative, if you're able to understand what it's talking about) error screen.
So now we know what a kernel is and does - it's a piece of software that allows other software to communicate with your computer's hardware, and it's critical to everything working.
Why do I need to update the kernel so often?
This is because the Linux kernel is updated very often. There's work being done all the time to improve security, fix bugs, improve hardware support, and more. As of the time of writing, the latest kernel version is 5.x. You can see a list of update logs here - notice how short the times between each changelog are.
Most Linux distributions (including Ubuntu) won't receive every single one of these versions. There's so many of them, and many only introduce minor changes. Additionally, the Ubuntu developers need to make sure that everything works properly with the new kernel version, so it won't be available right away.
You can check the Linux kernel you're running with the command uname -r
, and you can check the latest version at kernel.org.
This doesn't answer why the kernel is updated so frequently, though.
This is because there are many, many changes made to the Linux kernel every single day, by a wide range of contributors across the world. Not every single update gets its own version number, though. With the high frequency of changes made, there are understandably many updates released in a month. Every now and then, the Ubuntu developers will pick one of these versions, work on testing it to ensure it's compatible with the rest of Ubuntu, and then release it for you to download.
Why do the old versions stick around?
This requires a more in-depth explanation of how your system handles kernel updates. I'll be talking about Ubuntu specifically here, but almost all of this applies to other Debian-based distributions too.
Even with the testing done by Ubuntu, it's impossible to know that a new kernel release will work with every single Ubuntu user on Earth. To make sure you still have a working computer at the end of the day, Ubuntu will keep the previous version of the kernel installed. If you restart, and the new kernel doesn't work properly, you can switch back to the old kernel to have a working PC.
The Ubuntu developers tend to keep older versions of the kernel around as separate packages. When your computer tries to install the Linux kernel image (linux-image-generic
), apt will tell it which particular version it needs to install.
This means that you only ever have to install linux-image-generic
and the system will automatically install the correct kernel version for you.
You can see how many kernel versions Ubuntu Bionic currently has available by checking this page.
apt will never remove a package without your permission. If a package is no longer required, you need to remove it manually by running sudo apt autoremove
. This will clean up any packages that aren't currently in use, including older Linux kernels.
You'll notice that uname -r
will give you the same result before and after updating the kernel. Even though the new kernel update was installed, it's not active yet. You need to restart your computer to start using the new kernel version.
So, in short: to get rid of those old, unused kernel versions, try rebooting (to make sure you're running the latest kernel), then run sudo apt autoremove
.
Summary
The Linux kernel is a critical piece of your computer's software. Without it, nothing will work, and if it crashes, the whole system comes down with it. It can't be updated without a reboot. New versions are frequently releases, and the Ubuntu team tests and releases a new version once every month or so. Ubuntu keeps old versions around for various reasons, but you can get rid of the ones you aren't using fairly easily.