How to Disable the Ubuntu ‘Dmesg’ Restrictions

The Unprivileged Kernel Log

The dmesg command is one of the most critical diagnostic tools in Linux. It reads the kernel ring buffer, displaying hardware initialization logs, driver errors, and low-level system events. Historically, any user logged into a Linux system could run dmesg to view these logs. However, in modern versions of Ubuntu, Canonical changed the default security policy to restrict dmesg access strictly to the root user (or users utilizing sudo).

This change was made for security reasons: kernel logs can sometimes leak sensitive information, such as memory addresses, which could aid an attacker in crafting a local privilege escalation exploit. While this makes sense on a shared, multi-user server, it is highly annoying on a single-user desktop or a dedicated development environment where you constantly need to check hardware logs without typing your password every time. If you prefer convenience over this specific security hardening, you can disable the restriction.

How to Remove Dmesg Restrictions

You can allow standard, unprivileged users to read the kernel log by modifying the sysctl configuration.

  1. Open your Ubuntu Terminal.
  2. To temporarily disable the restriction (until the next reboot), you can modify the kernel parameter directly:
sudo sysctl -w kernel.dmesg_restrict=0
  1. To make this change permanent across reboots, you must add it to a sysctl configuration file. Open a new file in the sysctl directory using nano:
sudo nano /etc/sysctl.d/99-dmesg-unrestrict.conf
  1. Paste the following line into the file:
kernel.dmesg_restrict=0
  1. Save the file by pressing Ctrl + O, Enter, and then exit nano with Ctrl + X.
  2. Apply the new configuration immediately without rebooting:
sudo sysctl --system

From now on, any standard user on your Ubuntu system can open a terminal and simply type dmesg to view the kernel logs, completely bypassing the need for sudo.

Get the best tech tips delivered straight to your inbox.

Join thousands of readers mastering Apple, Google, Microsoft, and Linux.