Linux Lab 4: Exploring the Linux Kernel¶
This lab focuses on gathering system information related to the Linux kernel and hardware devices. It covers checking the kernel version, understanding version numbering, viewing kernel logs, and listing block devices.
Table of Contents¶
Key Concepts¶
- Kernel: The core component of the operating system that manages hardware resources (CPU, memory, disk) and provides services to applications.
uname: A command to print system information. The-rflag specifically prints the kernel release.- Kernel Versioning: Linux kernel versions typically follow a
major.minor.patch-buildformat (e.g.,5.15.0-1083). dmesg: A command to display the kernel ring buffer, which contains messages generated by the kernel during boot and runtime (e.g., hardware detection, driver loading).- Block Devices: Storage devices that transfer data in blocks (e.g., hard drives, SSDs, USB drives).
Step-by-Step Walkthrough¶
1. Checking the Kernel Version¶
Question: What is the exact version of kernel running in this system?
Answer: 5.15.0-1083-gcp
Explanation:
To find the running kernel version, use the uname command with the -r flag:
uname -r
# Output: 5.15.0-1083-gcp
2. Understanding Kernel Version Numbers¶
Question: What is the Kernel Version in 4.15.0-88-generic?
Answer: 4
Explanation:
In standard semantic versioning for the Linux kernel (e.g., 4.15.0), the first digit represents the main Kernel Version.
* 4: Kernel Version
* 15: Major Revision
* 0: Minor Revision / Patch Level
3. Identifying the Major Version¶
Question: What is the major version number of the kernel 4.15.0-88-generic?
Answer: 15
Explanation:
The Major Revision is the second number in the version string, immediately following the first dot.
In 4.15.0, the number 15 indicates significant updates and new features added to the version 4 kernel series.
4. Viewing Kernel Logs (dmesg)¶
Question: What is the command to print the messages generated by the kernel?
Answer: dmesg
Explanation:
* dmesg (display message): This command prints the contents of the kernel ring buffer. It is the primary tool for troubleshooting hardware issues or seeing what happened during the boot process.
* Other options you might see (like kmsg, kernel_log) are not standard commands for printing these logs to the terminal in this way.
5. Listing Block Devices (lsblk)¶
Question: How many block devices of type disk are present in the system?
Answer: 5
Explanation: To list block devices, use the command:
lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 20G 0 disk <-- Disk 1
|-sda1 8:1 0 19.9G 0 part /dev...
...
nvme0n1 259:0 0 375G 0 disk <-- Disk 2
nvme0n2 259:1 0 375G 0 disk <-- Disk 3
nvme0n3 259:2 0 375G 0 disk <-- Disk 4
nvme0n4 259:3 0 375G 0 disk <-- Disk 5
TYPE column explicitly says disk.
* Partitions (like sda1, sda14) have the type part and are not counted as separate physical disks.
Command Reference¶
| Command | Purpose | Example |
|---|---|---|
uname -r |
Prints the kernel release version | uname -r |
dmesg |
Prints or controls the kernel ring buffer | dmesg | grep usb |
lsblk |
Lists information about all available or specified block devices | lsblk |
lscpu |
Displays information about the CPU architecture | lscpu |
free -h |
Displays amount of free and used memory in the system | free -h |