How to view and browse the linux kernel source?

29/12/2020
Chưa phân loại
The Linux Kernel is the operating system (OS) core which allows it to support and manage the hardware, protocols and more. In this tutorial the kernel source structure will be briefly explained. The kernel’s root folder located at /usr/src/, usually /usr/src/linux* contains it’s source like the one you can browse at https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/tree/?h=v5.1.3

The source directory contains the following subdirectories called kernel tree, learning the structure of the kernel tree and the function of each path is the first step to start browsing the kernel.

Kernel tree root directory:

Documentation/: kernel source documentation.

LICENSES/: It contains the licenses to be applied to the kernel source and individual source files which may have different licenses. Inside this directory you will find 3 subdirectories: preferred (GNU GPL), exceptions listed in the COPYING file and other.

arch/: source codes for specific architectures (e.g powerpc, x86,etc). Inside this directory you’ll find subdirectories belonging to each supported architecture lie i386, sparc, arm, etc.

block/: block I/O layer, contains code for the management of block devices (such as hard disks, dvd, floppy disks, etc.) and their requests.

Certs/:
certificates and sign files to enable module signature to make the kernel load signed modules, this can be useful to prevent malicious code from running with kernel modules like rootkits.

Crypto/: Crypto API. Contains cryptographic ciphers which handles cryptographic and compression tasks.

drivers/: Hardware device drivers. Contains code of device drivers to support hardware, inside this directory you’ll find subdirectories for each hardware such as video, bluetooth,etc (any hardware supported).

fs/: code for the Virtual File System and additional filesystems. This directory contains the code to support, read and write filesystems.

include/: kernel headers. This directory contains C headers for kernel files such as functions to compile code.

init/: kernel boot. Contains source code related to the initialization of the kernel. The source code is stored in a file called  mainc.c within the directory /init. The code initializes the kernel and some initial processes.

ipc/: Inter-Process Communication such as signals and pipes.

kernel/: Core subsystems, such as the scheduler signal handling code, etc.

lib/: library routines common string operations, hardware dependent operations, debugging routines and command line parsing code.

mm/:  Memory management and virtual memory. The kernel manages both the hardware and virtual memory (swap). This directory stores code for the memory management.

net/: Network stack. Contains code related to communication protocols such as IP, TCP,UP, etc.

samples/: sample code and configuration files.

scripts/: scripts to build the kernel.

security/: Linux Security Module (LSM)  is a framework to enable security policies to access modules control.

sound/: The sound subsystem, here you’ll find sound drivers and code related to sound such as ALSA,


tools/:
tools for compressed kernel development such as ACPI, cgroup, USB testing tools, vhost test module, GPIO, IIO and spi tools, Inter energy policy tool among more.

usr/: initramfs which roots the filesystem and init in the kernel memory cache.

virt/: Virtualization, this directory contains the KVM (Kernel Virtual Machine) module for hypervisor.

These are the main subdirectories of the kernel tree and their function, hope its helpful for you.

ONET IDC thành lập vào năm 2012, là công ty chuyên nghiệp tại Việt Nam trong lĩnh vực cung cấp dịch vụ Hosting, VPS, máy chủ vật lý, dịch vụ Firewall Anti DDoS, SSL… Với 10 năm xây dựng và phát triển, ứng dụng nhiều công nghệ hiện đại, ONET IDC đã giúp hàng ngàn khách hàng tin tưởng lựa chọn, mang lại sự ổn định tuyệt đối cho website của khách hàng để thúc đẩy việc kinh doanh đạt được hiệu quả và thành công.
Bài viết liên quan

Linux date Command

The date command is a simplistic command that, by default, shows the current date and time of the system. However, its...
29/12/2020

Differences Between Release Engineering and DevOps

Today most companies are adopting some form of DevOps and configuration management philosophy. They are automating their...
28/12/2020

Bash jq command

JSON data are used for various purposes. But JSON data can’t be read easily from JSON file by using bash script like...
29/12/2020
Bài Viết

Bài Viết Mới Cập Nhật

VPS treo game là gì? Thuê VPS treo game giá rẻ, không lo giật lag
02/06/2025

 BitBrowser – Best Anti-Detect Browser!
26/05/2025

Dịch Vụ Xây Dựng Hệ Thống Peering Với Internet Exchange (IXP)
04/04/2025

Dịch Vụ Triển Khai VPN Site-to-Site & Remote Access
04/04/2025

Dịch Vụ Thiết Lập Hệ Thống Tường Lửa (Firewall)
04/04/2025