0

Actually i want my driver messages to reach my terminal for debugging purpose. So i just try to check by following below link.

I refred following link :--
http://elinux.org/Debugging_by_printing

I am using a ubuntu in side vmplayer virtual machine. Ubuntu is running in terminal mode inside virtual machine. I am trying to send some message to kernel printk buffer, buts echo command fails.

klog demon is also running i confirmed with following command .

ps aux | grep klogd 

Cat command on proc printk entry :---

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

run echo command :---

#sudo echo "<1>Writing critical printk messages from userspace" >/dev/kmsg

But i am not able to get the message on the terminal. I am getting following error when runs above command :--

-bash: /dev/kmsg: Permission denied

Please suggest how to print on console ?

my actual requirement is to ... send messages of printk() in my driver ... directly to my console. I am just testing here from my console that messages of low priority reaches console or not .

1

Use:

echo "<1>Writing critical printk messages from userspace" | sudo tee /dev/kmsg

See this answer to understand why.

  • my actual requirement is to ... send messages of printk() directly to my console. But here you are using tee to direct same message to console & to /dev/kmsg ... is this way of using tee option is right ? I am just testing here from my console that messages of low priority reaches console or not . – user6363 Nov 27 '13 at 16:33
  • Please suggest. – user6363 Nov 27 '13 at 16:36
  • how this post is right then .. ? stackoverflow.com/questions/12972155/… – user6363 Nov 27 '13 at 16:39
  • 1
    In the stackoverflow post, the command is likely issued in a root shell (as hinted at by the # prompt). You cannot achieve the same thing simply by prepending sudo to the command, since the elevated privileges apply to the echo command (which doesn't need them), but do not flow through to the redirect to /dev/kmsg (which does). Using echo " ... " | sudo tee /dev/kmsg is one way to work around that - you could also wrap the whole command inside a shell command e.g. sudo bash -c 'echo "<1>Writing critical printk messages from userspace" >/dev/kmsg' – steeldriver Nov 27 '13 at 16:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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