11

I noticed this difference some time ago, but until now, I didn't bother to ask, why is that?

On Linux Mint 18 (Ubuntu-based) I can run dmesg without using sudo.

On GNU/Linux Debian 9 I must use sudo in order to use for example dmesg.

I wonder, where is this behavior coded? And can it be changed?

3 Answers 3

23

This is controlled by the dmesg_restrict sysctl entry, documented in the kernel documentation. Its default value is determined by the CONFIG_SECURITY_DMESG_RESTRICT kernel configuration value, which is typically enabled in modern distributions.

You can see the current value by running

/sbin/sysctl kernel.dmesg_restrict

and change its value using (as root)

sysctl -w kernel.dmesg_restrict=1

(to enable the restriction) or

sysctl -w kernel.dmesg_restrict=0

(to disable it and restore the old behaviour).

To make this change permanent (automatically applied at boot), write it to /etc/sysctl.conf or a configuration file under /etc/sysctl.d:

echo kernel.dmesg_restrict=0 | sudo tee -a /etc/sysctl.d/99-dmesg.conf
0
0

It is the default kernel config of newer kernels: CONFIG_SECURITY_DMESG_RESTRICT=y

0

As others have answered you can use /sbin/sysctl to inspect and change values at runtime.

However, to make these changes persistent across reboots you should add them to /etc/sysctl.conf

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .