Skip to content

Fix Permission Denied When Opening a Linux File: A Beginner Guide

Admin
November 18, 2026
5 min read
Beginner
πŸ’» Target OS: Ubuntu 26.04 LTS / RHEL 10

Before you begin

  • Applies to:Ubuntu 26.04 LTS and Red Hat Enterprise Linux (RHEL) 10. The permission checks are the same on both.
  • Where to start:Open Bash on the affected host as the user whose access failed.
  • What you need:Have the exact path that returned Permission denied. For the optional practice exercise, use a folder under your home directory.
Guide tools
Guide tools
0/0 Steps (0%)

Troubleshooting Steps

01

Check the user and file permissions

Start here

Replace /srv/example/report.txt with the real path. The id command shows your user and groups. namei lists each part of the path and its permissions. A user needs search permission, shown as x, on each parent directory and read permission on the file itself. ACLs and security policy can also affect access.

What you should see Β· The output shows your user and groups, plus the owner and permissions for each part of the path.

If you see something else Β· Start with the first parent directory you cannot traverse. If all parents allow traversal, check read permission on the file. If both look correct, check the file ACL before changing permissions.

Terminal window
id
ls -l -- /srv/example/report.txt
namei -l -- /srv/example/report.txt
02

Practice the narrow fix

Narrow the cause

This makes a fresh directory in your home folder and removes your own read permission from a practice file. The first cat should report Permission denied when run as a regular user. If it succeeds instead, the block restores owner read permission and exits with an error. Add owner read permission with chmod u+r and repeat. Run the block together so it stops if the practice directory or file cannot be created.

Terminal window
(
lab=$(mktemp -d "$HOME/permissions-lab.XXXXXXXX") || exit 1
printf '%s\n' 'Practice only' > "$lab/report.txt" || exit 1
chmod u-r -- "$lab/report.txt" || exit 1
if cat -- "$lab/report.txt"; then
chmod u+r -- "$lab/report.txt" || exit 1
printf 'Expected the read to fail. Practice folder: %s\n' "$lab" >&2
exit 1
fi
chmod u+r -- "$lab/report.txt" || exit 1
cat -- "$lab/report.txt" || exit 1
printf 'Practice folder: %s\n' "$lab"
)
03

Apply the lesson to the real path

Verify

Ask the owner to confirm the intended access. Correct only the relevant permission or group through the approved process, recording the old setting for rollback. Reopen the file as the intended user. If basic permissions are correct, check ACLs or ask the administrator to review security policy. Remove the practice file and empty folder with your file manager when finished.

Reference

Comments