Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

cat /proc/kmsg is convenient way to follow kernel messages. But the output is unreliable. Example:

< eoyfl-o-ilF ilaltssI hwflssesJ a hwbctaealatv-psL hwmmr-sg()nc-l-TtssN oeOfso-eitr()so-l-iesQ na ycso-aksae()Umutfref()so-lce-ak()Wiet_e_yr upfrc-ufrZ <6>[640655.817496] SysRq : HELP : loglevel(0-9) reBoot Crash terminate-all-tasks(E) memory-full-oom-kill(F) kill-all-tasks(I) thaw-filesystems(J) saK show-backtrace-all-active-cpus(L) show-memory-usage(M) nice-all-RT-tasks(N) powerOff show-registers(P) show-all-timers(Q) unRaw Sync show-task-states(T) Unmount force-fb(V) show-blocked-tasks(W) Write_to_dev_sysrq dump-ftrace-buffer(Z)

(I pressed Alt+Sysrq+h thrice: first time it printed broken text without newline. Second time it printed correct text. Third time it has just exited (EOF).

What am I doing wrong? How to follow kernel messages (without dependence of various sysklogd and config files and tail -f).

Alternatively, how to use klogd to just print messages (like cat /proc/kmsg but correct) without any syslogs or klogd: Already running)?

share|improve this question
See this answer:… – Randolf Richardson Apr 14 '11 at 1:35
Also, this web page indicates that it's a ring buffer, so "tail -f" and friends might not work so well anyway (use "dmesg" instead although that won't monitor like "tail -f" can): – Randolf Richardson Apr 14 '11 at 1:35
Starting with Linux 3.5, a new /dev/kmsg interface has been implemented, which allows multiple processes to read the kernel log without corruption, and cat /dev/kmsg will automatically follow new entries. (util-linux 2.22 also implements dmesg --follow.) – grawity Dec 29 '12 at 19:56
up vote 1 down vote accepted

It seems that output of cat /proc/kmsg is garbled because there may be other consumers of kernel logging data, like syslogd and friends. For me, output characters get interleavingly to cat or syslogd (tried on Ubuntu 12.04). See also this answer:

I may imagine, cat /proc/kmsg would work reliably when booted into a pristine system (for example, kernel booted with init=/bin/sh argument). Otherwise, using dmesg command to read kernel log is expectedly easier.

share|improve this answer
Is there a dmesg which prints all messages continuously (expect of watch "dmesg | tail")? – Vi. Dec 29 '12 at 19:35
@Vi.: If you run Linux kernel ≥ 3.5, you should be able to do cat /dev/kmsg or even dmesg --follow (requires util-linux ≥ 2.22). On older systems, your only choice is to tail -f the syslog files in /var/log. – grawity Dec 29 '12 at 19:49

I was having a problem cat /proc/kmsg exiting prematurely due to it trying to display unprintable characters.

I have found that:

cat -v /proc/kmsg

removes all the unprintable characters from the output and prevents cat from exiting prematurely.

share|improve this answer
I don't think it's because of those characters. – Vi. Apr 20 at 14:53

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.