For casual users and less experienced fans, Linux is an open source operating system. For purists, however, the title “Linux” is reserved for the kernel that powers the operating system. If you’re curious about what the Linux kernel is, let’s answer that question, with a focus on more non-expert users.
Before explaining what the kernel is, it is important to understand the terms “user mode” and “kernel mode”. User mode is when code execution is unable to directly access hardware or reference memory. To gain access to hardware and memory, code running in user mode must delegate instructions to the system’s Application Programming Interfaces (APIs). Kernel mode is when code execution has unrestricted access to all hardware, and is reserved for the most trusted functions of the operating system.
What is the Linux kernel?
Every operating system has a kernel. Windows, macOS, iOS, Android, Chrome OS and Linux each have a low-level system that is responsible for interfacing all software with the computer’s physical hardware. Without the kernel, none of your applications would be able to use the physical computer; applications like Firefox, Chrome, LibreOffice, MS Office or Outlook would not work. The kernel is also responsible for allowing processes to exchange information using what is called Inter-Process Communication (IPC).
There are three types of kernels:
Monolithic Kernels : These kernels cover CPU, memory, IPC, device drivers, file system management, and system server calls. It is also responsible for allocating system memory to applications. These kernel types are generally better for hardware access and multitasking.
Microkernels : Microkernels take a minimalist approach and only manage CPU, memory and IPC.
Hybrid Kernels: Hybrid Kernels have the ability to decide what they want to run in User Mode or Kernel. While this provides the best of both worlds, it takes a lot more from hardware manufacturers to create drivers that interface between code execution and hardware.
How to Build Linux Kernel From Scratch
What kernel does Linux use?
As Linux uses open source, its Kernel is Monolithic, while MacOS and Windows use Hybrid Kernels. The Linux kernel was conceived in 1991 by Linus Torvalds. To this day, Mr. Torvalds remains the lead developer on the Linux kernel, while developers from around the world contribute to the Linux kernel.
In fact, it’s estimated that around 10,000 developers from over 1,000 companies have contributed to the Linux kernel (since tracking began in 2005).
Where is the kernel?
If you open a terminal window and issue the ls/boot command, you will see a file called vmlinuz-VERSION (where VERSION is the name or version number). The vmlinuz file is the current bootable Linux kernel, and the “z” indicates that the kernel is compressed; so instead of vmlinux we have vmlinuz.
The /boot directory listing.
Within that/boot directory there are other important kernel files such as initrd.img-VERSION, system.map-VERSION and config-VERSION (where VERSION is a name or a release number). These other files serve the following purposes:
- I nitrd : used as a small RAM disk that extracts and executes the real kernel file.
- S ystem.map : used for memory management, before the kernel loading.
- C onfig : instructs the kernel which options and modules to load.
Without modules, the kernel wouldn’t be very useful. The modules effectively activate the drivers needed to communicate with the hardware, without consuming all the system’s memory.
The modules also add functionality to the kernel, such as communication with peripherals, file system management, security, etc. You can list, add and remove kernel modules with the following commands:
- The lsmod will list all currently loaded kernel modules.
- The insmod load a kernel module running.
- The rmmod will unload a kernel module running.
So you see, with the help of some simple commands, the Linux kernel can be quite flexible.
The Current Kernel
At the time of this publication, the stable Linux kernel is 5.15, but not all Linux distributions will include the latest kernel. In fact, the updated distribution of the Elementary OS interface is kernel 5.4 .0-30What does this number mean? In the case of the latest kernel on Elementary OS, this means:
- 5 is the major version
- 4 is the minor version
- 0-30 is the review>
It is also possible to download different versions of the Linux kernel from kernel.org, and compile it. Compilation of the Linux kernel is a task that should only be performed for those who already have a more advanced knowledge.
An incorrectly compiled kernel can make the system unbootable. So, unless you’re ready to dive into the challenging task of compiling code at this level, use the default kernel, which is shipped and updated in your distribution of choice.
Leave a Reply