Overview
This article outlines the procedure for suppressing low-level kernel messages, including iptables logs, from displaying on the system console. Adjusting the kernel.printk parameter controls the verbosity of kernel logging output.
Prerequisites
- Root or sudo access is required to modify system configuration files and apply runtime parameters.
Permanent Configuration
To persistently disable console logging across reboots, update the sysctl configuration:
- Edit the /etc/sysctl.conf file using a text editor.
- Add or modify the following line to configure the log levels:
kernel.printk = 4 1 1 7
Save the file. The changes will automatically apply upon system reboot. To apply them immediately without restarting, execute:
/sbin/sysctl -p /etc/sysctl.conf
Temporary Configuration
To apply the logging change for the current session only (settings will revert after a reboot), run the following command:
echo "4 1 1 7" > /proc/sys/kernel/printk
Verification
To confirm that the new logging levels are active, check the current configuration:
cat /proc/sys/kernel/printk
The output should return 4 1 1 7.
Troubleshooting
- Permission Denied: Ensure all commands are executed with root privileges. Writing to /proc/sys/kernel/printk requires elevated access.
- Changes Not Persisting: Verify that the entry was correctly added to /etc/sysctl.conf and that no syntax errors exist in the file before running /sbin/sysctl -p /etc/sysctl.conf.
- Unexpected Output Values: If the verification command returns values other than 4 1 1 7, another service or script may be overriding the kernel parameters at runtime.