Linux prevent unprivileged users from viewing dmesg
You can prevent unprivileged users from viewing the dmesg logs on Linux by using the following steps:
- Edit the sysctl configuration file:
sudo nano /etc/sysctl.conf- Add the following line to the end of the file:
kernel.dmesg_restrict = 1- Save and close the file.
- Reload the sysctl configuration:
sudo sysctl -pAfter these steps, unprivileged users will no longer be able to view the dmesg logs, as the dmesg_restrict flag will restrict access to it.
Note: Only the root user or users with the CAP_SYSLOG capability will be able to view the dmesg logs.
