Master Linux Kernel Essentials: Modules, Commands, and System Configuration
This article provides a comprehensive overview of the Linux kernel, explaining its core components, memory and process management, device drivers, system calls, and security, while detailing essential commands such as uname, lsmod, modinfo, modprobe, depmod, insmod, rmmod, sysctl, and guiding readers through kernel compilation and configuration using /proc and /sys.
1. Kernel Overview
The Linux kernel is an open‑source, monolithic Unix‑like operating system core that acts as the central interface between hardware and processes, managing resources efficiently. Its main responsibilities include memory management, process scheduling, device driver mediation, and handling system calls and security.
2. Kernel Modules
2.1 uname command
Usage: uname [OPTION]... Options:
-n display node name
-r display VERSION‑RELEASE
-s display kernel name
-v display kernel version
-m display hardware name
-i display hardware platform
-p display processor type
-o display operating system
# uname -m
i686
# uname -r
2.6.32-573.22.1.el6.i686
# uname -a
Linux MyServer 2.6.32-573.22.1.el6.i686 ... i686 i386 GNU/Linux2.2 lsmod command
Shows currently loaded kernel modules.
Definition: Data is read from /proc/modules. Typical usage:
lsmod | grep -i ext4 # cat /proc/modules
iptable_filter 2173 0 - Live 0xed9b2000
ip_tables 9567 1 iptable_filter, Live 0xed9a9000
ext3 203718 1 - Live 0xed962000
jbd 65315 1 ext3, Live 0xed904000
… # lsmod | grep ext4
ext4 339812 2
jbd2 75927 1 ext4
mbcache 6017 2 ext3,ext4Field meanings:
Column 1: module name
Column 2: module size
Column 3: number of dependent modules
Column 4: list of dependent modules
2.3 modinfo command
Displays detailed information about a kernel module.
Definition: modinfo queries information for a specified module, even if it is not currently loaded.
# modinfo ext4
filename: /lib/modules/2.6.32-573.22.1.el6.i686/kernel/fs/ext4/ext4.ko
license: GPL
description: Fourth Extended Filesystem
author: Remy Card, Stephen Tweedie, Andrew Morton, Andreas Dilger, Theodore and others
srcversion: CB1B990F5A758DFB0FB12F1
depends: mbcache,jbd2
vermagic: 2.6.32-573.22.1.el6.i686 SMP mod_unload modversions 686
# modinfo btrfs
filename: /lib/modules/2.6.32-573.22.1.el6.i686/kernel/fs/btrfs/btrfs.ko
license: GPL
alias: devname:btrfs-control
alias: char-major-10-234
srcversion: B412C18B0F5BF7F1B3C941A
depends: libcrc32c,zlib_deflate,lzo_compress,lzo_decompress
vermagic: 2.6.32-573.22.1.el6.i686 SMP mod_unload modversions 6862.4 modprobe command
Loads or unloads kernel modules.
Definition: Uses configuration files ( /etc/modprobe.conf or /etc/modprobe.d/*.conf) and dependency information from modules.dep (generated by depmod) to insert or remove modules.
# modules.dep is the dependency file; modules.dep.bin is its binary form
# ls /lib/modules/2.6.32-358.6.1.el6.i686/
build modules.block modules.ieee1394map modules.ofmap modules.symbols.bin weak-updates
extra modules.ccwmap modules.inputmap modules.order modules.usbmap
kernel modules.dep modules.isapnpmap modules.pcimap source
modules.alias modules.dep.bin modules.modesetting modules.seriomap updates
modules.alias.bin modules.drm modules.networking modules.symbols vdsoSyntax examples:
modprobe -c modprobe -l -t dirname wildcard modprobe -r -v -n -i modulename …Common options:
-v verbose output
-C reload configuration
-c print configuration and exit
-n dry‑run (often with -v)
-i ignore install/remove directives in config files
-q quiet (suppress errors)
-r remove module instead of inserting
-f force (dangerous)
-l list all modules
-a insert all modules from the command line
-t force display of modules in a directory
-s log errors to syslog
2.5 depmod command
Generates kernel module dependency files and system‑information mapping files.
Syntax: depmod [-adeisvV] [-m <file>] [--help] [module_name] Key options:
-a analyze all available modules
-d debug mode
-e output unresolved symbols
-i ignore symbol version checks
-m<file> use specified symbol file
-s record errors in system log
-v verbose output
-V show version
--help display help
2.6 insmod and rmmod commands
Insert or remove kernel modules directly.
insmod: Inserts a module file into the kernel. Typical usage: insmod [filename] [module options...]. Most users prefer modprobe because it resolves dependencies automatically.
rmmod: Removes a module from the kernel. Usually invoked via modprobe -r. Options include:
-f force removal (requires CONFIG_MODULE_FORCE_UNLOAD)
-w wait until the module is no longer in use
-s log errors to syslog instead of stderr
# rmmod modulename3. /proc Filesystem
The kernel exposes internal state, statistics, and configurable parameters through the proc pseudo‑filesystem.
Typical entries include /proc/cpuinfo, /proc/meminfo, /proc/sys, and many others. Example to list the directory:
# ls /proc/
1 1173 22 29855 35 47 60 973 filesystems loadavg scsi version
10 12 23 3 36 48 600 buddyinfo fs locks self vmallocinfo
…3.1 sysctl command
Syntax: sysctl [options] [parameter] Common options:
-n print only values
-e ignore unknown keys
-N print only names
-w write a new value
-p load settings from /etc/sysctl.conf -a display all parameters
-A display all parameters in a table
Examples:
# sysctl -w kernel.sysrq=0
# sysctl -p
# sysctl -a3.2 Modifying configuration files
# cat /etc/sysctl.conf
# Kernel sysctl configuration file for Red Hat Linux
net.ipv4.ip_forward = 0
net.ipv4.conf.default.rp_filter = 1
net.ipv4.conf.default.accept_source_route = 0
kernel.sysrq = 0
kernel.core_uses_pid = 1
net.ipv4.tcp_syncookies = 1
…3.3 Practical usage
# sysctl -a
# sysctl -w kernel.sysrq=0
# sysctl -w net.ipv4.conf.default.accept_redirects=0
# echo 1 > /proc/sys/net/ipv4/ip_forward
# /sbin/sysctl -p
# /sbin/sysctl -w net.ipv4.route.flush=14. /sys Filesystem
sysfs presents hardware device attributes and configurable kernel parameters; many entries are writable for tuning.
4.1 udev
udev runs in user space and creates device nodes under /dev based on information from /sys.
It processes hardware add/remove events and loads required firmware.
Rules are read from /etc/udev/rules.d and /usr/lib/udev/rules.d.
4.2 Creating a ramdisk
Method 1 (mkinitrd):
# mkinitrd /boot/initramfs-$(uname -r).img $(uname -r)Method 2 (dracut):
# dracut /boot/initramfs-$(uname -r).img $(uname -r)4.3 Inspecting a ramdisk
# file /boot/initramfs-2.6.32-504.el6.x86_64.img
# gzip -d initramfs-2.6.32-504.el6.x86_64.img.gz
# cpio -id < ../initramfs-2.6.32-504.el6.x86_64.img
# cat init
# ls sbin5. Compiling the Kernel
5.1 Preparation
Install development groups (e.g., "Server Platform Development", "Development Tools") on CentOS 6.
Gather hardware information (CPU, PCI, USB, block devices) using cat /proc/cpuinfo, lspci, lsusb, lsblk, etc.
Obtain the kernel source from www.kernel.org.
5.2 Simple kernel installation
Copy the current kernel config as a starting point:
# cp /boot/config-$(uname -r) .config
# make menuconfig # adjust options graphically
# make -j$(nproc) # compile using all cores
# make modules_install
# make install # installs bzImage, initramfs and updates GRUB5.3 Detailed compilation steps
Configuration options: make config CLI‑based configuration make menuconfig curses UI make gconfig GTK UI make xconfig Qt UI make defconfig default configuration for the target make allnoconfig all options set to "no"
Compilation:
# make -j4 # compile with 4 parallel jobs
# make dir/ # compile only a specific subdirectory
# make drivers/net/ethernet/intel/e1000/e1000.ko # compile a single moduleCross‑compilation: make ARCH=arm64 (replace arm64 with the target architecture).
Cleaning the source tree: make clean remove most generated files make mrproper remove all generated files plus config make distclean remove everything including patches and backup files
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
MaGe Linux Operations
Founded in 2009, MaGe Education is a top Chinese high‑end IT training brand. Its graduates earn 12K+ RMB salaries, and the school has trained tens of thousands of students. It offers high‑pay courses in Linux cloud operations, Python full‑stack, automation, data analysis, AI, and Go high‑concurrency architecture. Thanks to quality courses and a solid reputation, it has talent partnerships with numerous internet firms.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
