Linux Kernel Cheat Sheet

Here’s a cheat sheet for Linux kernel concepts:

Kernel Basics

Kernel Version:

uname -r

Kernel Configuration:

zcat /proc/config.gz | less

Load Kernel Module:

modprobe <module_name>

Processes and System Calls

List Running Processes:

ps aux

Process Information:

top

System Calls:

strace <command>

Device Management

List Devices:

lspci
lsusb

View Block Devices:

lsblk

Device Information:

udevadm info -a -p $(udevadm info -q path -n /dev/sdX)

Kernel Logs

View Kernel Logs:

dmesg

Kernel Ring Buffer:

journalctl -k

Memory Management

Memory Information:

free -m

Swap Information:

swapon -s

Networking

Network Interfaces:

ip link show

Routing Table:

ip route show

Firewall Rules:

iptables -L

Kernel Modules

List Loaded Modules:

lsmod

Module Information:

modinfo <module_name>

Unload Module:

modprobe -r <module_name>

Filesystems

List Mounted Filesystems:

mount

Filesystem Information:

df -h

Check and Repair Filesystem:

fsck /dev/sdX

Kernel Compilation

Download Kernel Source:

wget https://www.kernel.org/pub/linux/kernel/v<version>/linux-<version>.tar.xz

Extract Kernel Source:

tar -xvf linux-<version>.tar.xz

Configure Kernel:

make menuconfig

Compile and Install:

make && make modules_install && make install

Kernel Parameters

View Kernel Parameters:

cat /proc/cmdline

Set Kernel Parameters (temporary):

sysctl -w <parameter_name>=<value>

Set Kernel Parameters (permanent): Add parameters to /etc/sysctl.conf and run sysctl -p.

This cheat sheet covers some essential Linux kernel commands and concepts. Kernel management involves more advanced topics, and the commands may vary based on the specific Linux distribution. Always refer to the documentation for detailed information.