Linux prevent unprivileged users from viewing dmesg

http‮www//:s‬.lautturi.com
Linux prevent unprivileged users from viewing dmesg

On Linux systems, the dmesg command allows users to view the kernel message buffer, which contains information about the system's hardware and software. By default, the dmesg command can be run by any user, but you can prevent unprivileged users from viewing the kernel message buffer by modifying the permissions on the /dev/kmsg device file.

Here are the steps to prevent unprivileged users from viewing the kernel message buffer on a Linux system:

  1. Open a terminal and log in as the root user:
sudo -i
  1. Change the permissions on the /dev/kmsg device file:
chmod 600 /dev/kmsg

This will prevent unprivileged users from reading or writing to the /dev/kmsg file.

  1. To allow only certain users or groups to view the kernel message buffer, you can use the chown command to change the owner and group of the /dev/kmsg file:
chown root:syslog /dev/kmsg

This will set the owner of the /dev/kmsg file to root and the group to syslog. Only users in the syslog group will be able to read the kernel message buffer.

  1. To allow all users to view the kernel message buffer again, you can set the permissions and owner/group back to the default:
chmod 644 /dev/kmsg
chown root:root /dev/kmsg
Created Time:2017-10-30 10:17:42  Author:lautturi