How to change the console_loglevel in linux?

18,249

Moved comment to answer.

You must leave a space between a number and > or the shell will redirect that file descriptor. Use

echo 5 >/proc/sys/kernel/printk

Or

dmesg -n 5
Share:
18,249

Related videos on Youtube

Lavya
Author by

Lavya

Updated on September 18, 2022

Comments

  • Lavya
    Lavya over 1 year

    I read at multiple places (e.g. here http://elinux.org/Debugging_by_printing), that you can change the console log level by echoing an integer to /proc/sys/kernel/printk. If that worked shouldn't the first integer have changed to 5 below?

    [root@localhost printk]# cat /proc/sys/kernel/printk
    4   4   1   7
    [root@localhost printk]# echo 5>/proc/sys/kernel/printk
    
    [root@localhost printk]# cat /proc/sys/kernel/printk
    4   4   1   7
    

    I tried this on multiple systems and it didn't change on any of them!

    • meuh
      meuh almost 9 years
      Ouch! You must leave a space between a number and > or the shell will redirect that file descriptor. Use echo 5 >/proc/sys/kernel/printk. Or dmesg -n 5.
    • Lavya
      Lavya almost 9 years
      you're right. that works solves the problem. thanks!
    • debug
      debug about 5 years
      sudo sh -c 'echo 8 > /proc/sys/kernel/printk'
    • Kusalananda
      Kusalananda about 5 years
      @debug Note that the user is already root.
  • ingli
    ingli over 4 years
    elinux.org/Debugging_by_printing offers an information about the meaning of different log levels
  • Stephen Kitt
    Stephen Kitt about 3 years
    In addition to that, the question has already been answered — see the comments underneath the question. The existing answer reflects the comment which resolved the asker’s problem.