52

My wireless driver is noisy. It prints out messages to the console every 10-30 seconds. So, if I'm working on VT1 or something, I get messages scrolling by all the time. Is there a way to shut this feature off? I like working on the virtual terminals, but this is making it hard to deal with. :)

Any ideas?

Zanna
  • 69,223
  • 56
  • 216
  • 327
dpb
  • 6,989
  • 1
  • 34
  • 60

3 Answers3

59

You can use the command

sudo dmesg -n 1

to suppress all messages from the kernel (and its drivers) except panic messages from appearing on the console.

To fix at each boot, add the command to:

/etc/rc.local
dpb
  • 6,989
  • 1
  • 34
  • 60
oddfellow
  • 2,971
  • 1
  • 18
  • 10
50

dmesg comes with two handy options for that:

-D, --console-off           disable printing messages to console
-E, --console-on            enable printing messages to console

dmesg -D is just a shortcut for dmesg -n 1, except that it stores the current log level, so that you can easily restore it with dmesg -E. So it's a bit more convenient than changing the log level with dmesg -n.

Additionally, you can check the current log level with:

$ cat /proc/sys/kernel/printk
7       4       1       7

man klogctl for more explanations on these numbers...

elboulangero
  • 654
  • 7
  • 8
  • Note that `dmesg -D` and `dmesg -E` have subsequently been broken by [capabilities](https://man7.org/linux/man-pages/man7/capabilities.7.html) (q.v. CAP_SYSLOG there). However, setting `kernel.dmesg_restrict=0` **does not** enable these two `dmesg`s; so far, I have found no way to enable them for Ubuntus after the time that the [`kernel.dmesg_restrict=1` default was instituted](https://lists.ubuntu.com/archives/ubuntu-devel/2020-June/041063.html). – Eric Towers Jun 27 '21 at 02:38
10

/proc/sys/kernel/printk

You can also set the log level directly with

echo 1 > /proc/sys/kernel/printk

which is basically what dmesg is doing.

The format of that file is explained at: https://superuser.com/a/793692/128124

loglevel command line boot parameter

Sets the initial value at boot time, which allows you to see pre-init messages.

Ciro Santilli OurBigBook.com
  • 26,663
  • 14
  • 108
  • 107
  • Hey hey, I tested myself by not reading your answer 1st and I nailed it \o/ that said can this be done with ‘sysctl’? – tijko Aug 18 '22 at 18:15