What Is the Linux Kernel?

Kernels act as traffic cops between hardware and software

CSS code on a screen

Sai Kiran Anagani / Unsplash

To casual users and less-than-hardcore fans, Linux is an operating system. To purists, however, the title Linux is reserved for the kernel that powers the operating system.

Modes

Before we explain what a kernel is, it’s important to understand the terms user mode and kernel mode. User mode is when executing code has no ability to directly access hardware or reference memory. To gain access to hardware and memory, code running in user mode must delegate instructions to system Application Programming Interfaces. Kernel mode is when executing code has unrestricted access to all hardware—it's reserved for the most trusted functions of an operating system.

What Is a Kernel?

Every operating system has a kernel. Windows, macOS, iOS, Android, Chrome OS, and Linux each have a low-level system that's responsible for interfacing all applications with the physical hardware of the computer. Without the kernel, none of your applications would be able to make use of the physical computer; apps like Firefox, Chrome, LibreOffice, or Outlook wouldn’t work. The kernel is also responsible for allowing processes to exchange information using what is called Inter-Process Communication.

There are (generally speaking) three types of kernels:

  • Monolithic kernels: These kernels encompass the CPU, memory, IPC, device drivers, file system management, and system server calls. It's also responsible for handing off free system memory to applications. These types of kernels are typically better at accessing hardware and multitasking.
  • Microkernels: Microkernels take a minimalist approach and only manage the CPU, memory, and IPC.
  • Hybrid kernels: Hybrid Kernels have the ability to decide what they want to run in either User or Kernel Mode. Although this provides the best of both worlds, it requires much more from the hardware manufacturers to create drivers that serve to interface between running code and hardware.

Linux uses an open source, Monolithic Kernel, whereas macOS and Windows both use Hybrid Kernels. The Linux kernel was conceived in 1991 by Linus Torvalds. To this day, Torvalds continues to be the lead developer on the Linux kernel, while developers from all over the world contribute to the Linux kernel. In fact, it's estimated that nearly 10,000 developers, from more than 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 command ls /boot, you’ll see a file called vmlinuz-VERSION (Where VERSION is the release name or number). The vmlinuz file is the actual bootable Linux kernel, and the z indicates the kernel is compressed—so instead of vmlinux we have vmlinuz.

The listing of the /boot directory.

Within that /boot directory are other important kernel files, such as initrd.img-VERSION, system.map-VERSION, and config-VERSION (Where VERSION is either a name or release number). These other files serve the following purposes:

  • initrd: Used as a small RAMdisk that extracts and executes the actual kernel file.
  • system.map: Used for memory management, prior to the kernel loading.
  • config: Instructs the kernel on what options and modules to load.

Modules

Without modules, the kernel wouldn’t be much use. Modules effectively turn on the drivers necessary to communicate with hardware without consuming all of your system memory. Modules also add functionality to the kernel, such as communicating with peripherals, managing file systems, security, etc. List, add, and remove modules to the kernel with the following commands:

  • lsmod lists all of the currently loaded kernel modules.
  • insmod loads a kernel module into the running kernel.
  • rmmod unloads a module from the running kernel.

With the help of some simple commands, the Linux kernel can be quite flexible.

The Current Kernel

Linux kernels
kernel.org

The Linux kernel updates frequently, but not all Linux distributions will include the latest kernel.

You're free to download different versions of the Linux kernel from kernel.org and compile it yourself. The compilation of the Linux kernel is a task best left to those who really know what they're doing. An improperly compiled kernel can render a system unbootable. So, unless you're ready to dive into the challenging task of compiling code on this level, use the default kernel that ships and updates on your distribution of choice.