Check kernel config with zcat /proc/config.gz
In this step, we'll explore how to check the Linux kernel configuration using the command line. The kernel configuration determines which features are built into the kernel and how it behaves.
The kernel configuration is stored in a file named /proc/config.gz
. This file is a compressed version of the kernel configuration. To view the contents of this file, we'll use the zcat
command.
zcat
is a command-line utility that allows you to view the contents of a compressed file without actually decompressing it. It's particularly useful for viewing large compressed files, as it saves you the time and disk space required to decompress the entire file.
To check the kernel configuration, open your terminal and type the following command:
zcat /proc/config.gz
This command will output the kernel configuration to your terminal. Since the output is quite long, it might scroll past quickly. To view the output one page at a time, you can pipe the output to the less
command:
zcat /proc/config.gz | less
Now, you can use the arrow keys to scroll through the configuration. Press q
to exit less
.
The kernel configuration file consists of a series of lines, each defining a specific configuration option. These options control various aspects of the kernel, such as which hardware drivers are included, which networking protocols are supported, and which security features are enabled.
Let's search for a specific configuration option. For example, let's check if the CONFIG_LOCALVERSION
option is set. This option specifies a custom version string for the kernel.
To search for this option, we can use the grep
command. grep
is a powerful command-line utility that allows you to search for specific patterns in text files.
Type the following command in your terminal:
zcat /proc/config.gz | grep CONFIG_LOCALVERSION
If the CONFIG_LOCALVERSION
option is set, you'll see a line similar to this:
CONFIG_LOCALVERSION="-labex"
The exact value of CONFIG_LOCALVERSION
may vary depending on the kernel configuration. If the option is not set, grep
will not output anything.
You can search for other configuration options as well. For example, you can check if the CONFIG_DEBUG_INFO
option is enabled. This option enables the generation of debugging information, which can be useful for troubleshooting kernel issues.
zcat /proc/config.gz | grep CONFIG_DEBUG_INFO
A typical output would be:
CONFIG_DEBUG_INFO=y
This indicates that debug information is enabled in the kernel configuration.
By examining the kernel configuration, you can gain valuable insights into how your system is configured and which features are enabled. This information can be useful for troubleshooting issues, optimizing performance, and customizing your system to meet your specific needs.