Programster's Blog

Tutorials focusing on Linux, programming, and open-source

Stop Kernel Messages Showing In Console

When working on a Linux box, it can be annoying if kernel messages keep polluting your screen, so that you can't run your commands to diagnose the system. This is often things like the network port entering promiscuous mode if you are running virtual machines.

To stop the messages appearing in the console, we just need to uncomment the kernel.printk line as stated in the /etc/sysctl.conf file:

# Uncomment the following to stop low-level messages on console
#kernel.printk = 3 4 1 3

... and then run the command to apply the changes:

sudo sysctl -p

Script

If you want, you can run the following script to to do all of this for you:

SEARCH="#kernel.printk ="
REPLACE="kernel.printk ="
FILEPATH="/etc/sysctl.conf"
sudo sed -i "s;$SEARCH;$REPLACE;" $FILEPATH

# Apply the changes
sudo sysctl -p

References

Last updated: 16th May 2024
First published: 16th May 2024

This blog is created by Stuart Page

I'm a freelance web developer and technology consultant based in Surrey, UK, with over 10 years experience in web development, DevOps, Linux Administration, and IT solutions.

Need support with your infrastructure or web services?

Get in touch