How to Fix ‘tail: cannot open for reading: Permission denied’ in Linux

Monitoring real-time server activity, debugging web application errors, or inspecting system performance in Linux frequently involves following log files using the tail -f command. However, running tail against files in /var/log/, system directories, or another user’s home folder can abruptly fail with an error: tail: cannot open '/path/to/logfile.log' for reading: Permission denied. This error indicates that your active Linux user account lacks the necessary read permissions (r) along the entire filesystem path hierarchy leading to the targeted file.

Why Does tail Fail with Permission Denied?

Linux utilizes strict discretionary access control (DAC) and optional mandatory access control (MAC) security layers. The permission failure occurs due to:

  • Missing Read Permissions on the Target File: The file mode bits (e.g. -rw-r-----) restricting read rights exclusively to the owning user or group.
  • Missing Traversal (Execute) Permissions on Parent Folders: In Linux, accessing a file requires execute (x) permissions on every parent directory in the path; if a directory like /var/log/nginx/ has mode 0700, non-root users cannot reach files inside it even if the file itself has world-read rights.
  • Unprivileged User Account Execution: Attempting to inspect sensitive system logs (such as /var/log/auth.log or /var/log/syslog) reserved exclusively for root or members of the adm / systemd-journal groups.
  • Access Control List (ACL) Restrictions: Extended POSIX ACLs overriding standard Unix permission bits.
  • Mandatory Access Control (AppArmor / SELinux): Security policies confining terminal shells or container environments from accessing host log files.

Step 1: Prepend sudo to Run with Elevated Privileges

For protected administrative system logs in /var/log/, run the command with superuser rights.

  1. Prepend sudo to the command:
    sudo tail -f /var/log/syslog
  2. Enter your user account password when prompted.
  3. To follow multiple log streams simultaneously with administrative privileges:
    sudo tail -f /var/log/nginx/access.log /var/log/nginx/error.log

Step 2: Add Your User to the adm or systemd-journal Group

Avoid typing sudo repeatedly by granting your user account standard log-auditing group membership.

  1. Check the group ownership of system log files:
    ls -l /var/log/syslog
    (System logs are typically owned by group adm).
  2. Add your username to the adm group:
    sudo usermod -aG adm $USER
  3. If using systemd journal logs, also add your user to the systemd-journal group:
    sudo usermod -aG systemd-journal $USER
  4. Log out of your Linux session (exit) and log back in to apply the updated group token. You can now tail system logs without sudo.

Step 3: Check Parent Directory Traversal Permissions

Ensure that all parent folders possess execute (+x) permissions allowing directory traversal.

  1. Inspect directory permissions for the entire path using namei:
    namei -l /var/log/nginx/error.log
  2. Examine the output: each folder (/, var, log, nginx) must include r-x permissions for other users or your assigned group.
  3. If a parent folder lacks execute rights, grant traversal access:
    sudo chmod o+x /var/log/nginx

Step 4: Inspect and Configure Access Control Lists (ACLs)

Grant persistent read rights to specific user accounts without altering standard global permissions.

  1. Check if extended ACL rules are active on the file:
    getfacl /path/to/logfile.log
  2. Grant explicit read permission to your personal user account using setfacl:
    sudo setfacl -m u:$USER:r /path/to/logfile.log
  3. To grant recursive read and traversal permissions across an entire log directory:
    sudo setfacl -R -m u:$USER:rx /var/log/application/
  4. Verify that tail -f now streams log entries smoothly.

Step 5: Check SELinux Enforcing Mode (RHEL / CentOS / Fedora)

If permissions appear correct but access remains blocked on enterprise Linux distributions, inspect SELinux denials.

  1. Check current SELinux status:
    getenforce
  2. If set to Enforcing, inspect audit logs for permission denials:
    sudo ausearch -m avc -ts recent
  3. Restore correct security contexts on the log directory:
    sudo restorecon -Rv /var/log/application/

Get the best tech tips delivered straight to your inbox.

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