
klogd Command in Linux
Properly managing system logs is vital for diagnosing and resolving issues within Linux environments. One key utility for handling kernel logs is klogd. This daemon is instrumental in capturing kernel messages and directing them to appropriate logging mechanisms.
The klogd (kernel log daemon) is a system service that intercepts and processes messages from the Linux kernel. Working in tandem with syslogd, it ensures that kernel messages are captured and stored in log files, which are essential for monitoring system behavior and troubleshooting issues. Gaining proficiency with klogd allows you to effectively manage kernel logs and maintain the stability and security of your Linux system.
Table of Contents
Here is a comprehensive guide to the options available with the klogd command â
- Installing of klogd Command in Linux
- Syntax of klog Command
- klogd Command Options
- Examples of klogd Command in Linux
Installing of klogd Command in Linux
To install the klogd command, you need to install the sysklogd package, which includes klogd along with other logging tools. Hereâs how you can do it on different Linux distributions −
Ubuntu/Debian −
sudo apt install sysklogd
Fedora −
sudo dnf -y install sysklogd
CentOS/RHEL −
sudo yum -y install sysklogd
Arch Linux −
sudo pacman -S sysklogd
Syntax of klog Command
The general syntax to start the klogd daemon is −
klogd [options]
Since klogd operates as a daemon, it runs continuously in the background, listening for kernel messages.
klogd Command Options
The klogd command offers several options to customize its behavior −
Option | Description |
---|---|
-c n | Sets the console message log level to n. This determines which kernel messages are printed to the console based on their priority level. |
-f <file> | Logs messages to the specified filename instead of the default /proc/kmsg. |
-i, -I | Signals the currently executing klogd daemon to reload symbol information. The -i switch reloads kernel module symbols, while the -I switch reloads both static kernel symbols and kernel module symbols. |
-n | Prevents auto-backgrounding, useful if klogd is started and controlled by init(8). |
-o | Operates in 'one-shot' mode, causing klogd to read and log all messages found in the kernel message buffers, then exit. |
-p | Enables paranoia mode, causing klogd to load kernel module symbol information whenever an Oops string is detected in the kernel message stream. |
-s | Forces klogd to use the system call interface for kernel message buffers. |
-k <file> | Uses the specified file as the source of kernel symbol information. |
-v | Displays version information and exits. |
-x | Disables EIP translation, avoiding the reading of the System.map file. |
-2 | Expands symbols and prints the line twice: once with addresses converted to symbols and once with raw text, allowing external programs like ksymoops to process the original data. |
Examples of klogd Command in Linux
Here are some practical scenarios where klogd can be effectively used −
- Starting klogd with Default Settings
- Running klogd in Foreground Mode
- Setting the Console Log Level
- Using a Custom Kernel Message Source
- Logging Only Kernel Opps Messages
Starting klogd with Default Settings
To launch klogd using the default configuration, use −
sudo klogd
This command starts the daemon, which begins processing kernel messages and forwarding them to syslogd.

Running klogd in Foreground Mode
For debugging or monitoring purposes, you might want to run klogd without detaching it from the terminal −
sudo klogd -n
This keeps klogd running in the foreground, allowing you to see real-time output.

Setting the Console Log Level
To adjust the verbosity of kernel messages displayed on the console −
sudo klogd -c 3
This sets the console log level to 3, displaying messages with priority levels 0 (emergency) through 3 (error).

Using a Custom Kernel Message Source
If you need klogd to read kernel messages from a specific file −
sudo klogd -f /path/to/custom_kmsg
Replace /path/to/custom_kmsg with the path to your custom kernel message file.
Logging Only Kernel Oops Messages
To focus on critical kernel error messages (oops), you can enable the -o option −
sudo klogd -o
This filters the logs to include only kernel oops messages, aiding in pinpointing serious issues.

Conclusion
The klogd daemon is an essential tool for managing kernel messages in Linux. By capturing and directing these messages to the appropriate logging systems, it plays a critical role in system administration and troubleshooting.
Understanding the various options and how to apply them allows you to tailor the logging process to your needs, whether it's adjusting the verbosity of console messages, focusing on specific types of kernel messages, or running the daemon in a mode suitable for debugging.