Linux EACCESMedium

Permission Denied in Linux: Causes and Quick Solutions

The article thoroughly examines the 'Permission Denied' error in Linux, explains its causes, and offers several working ways to fix it, from simple permission changes to more complex configurations.

Updated at February 16, 2026
5-10 min
Easy
FixPedia Team
ΠŸΡ€ΠΈΠΌΠ΅Π½ΠΈΠΌΠΎ ΠΊ:Ubuntu 20.04+CentOS 7+Debian 10+Fedora 35+

What the "Permission Denied" Error Means

The Permission denied error is a standard Linux system message that appears when a process running under the current user attempts to access a file, directory, socket, or other resource but lacks sufficient permissions to perform the operation. The full error text depends on the context: in a terminal, it might be bash: /path/file: Permission denied, and similar entries appear in application logs. The error is not a "code" in the traditional sense, but in Linux system calls, it corresponds to the EACCES (access error) code.

Common Causes

The error occurs due to the following common reasons:

  1. Insufficient permissions: The user lacks the necessary permissions (read r, write w, execute x) for a file or directory. For example, attempting to run a script without execute permission.
  2. Incorrect owner or group: The file belongs to another user or group, and the current user is not in the list of those granted access.
  3. Filesystem mounted with restrictions: A partition may be mounted with options that prohibit execution (noexec), device nodes (nodev), or setuid operations (nosuid). This is common for external media or network filesystems.
  4. Enabled security mechanisms: SELinux (in CentOS, RHEL, Fedora) or AppArmor (in Ubuntu, Debian) can block access at the policy level, even if standard permissions are configured correctly.
  5. Set immutable attribute: The file has the i flag (set via chattr +i), which makes it immutable for everyone, including root.
  6. Missing execute permission on a directory: Accessing a directory's contents (e.g., cd or ls) requires execute (x) permission on that directory.

Solutions

Solution 1: Check and Modify Permissions with chmod

This is the most common solution. First, identify the file or directory causing the error and check its current permissions:

ls -l /path/to/problematic/file

Example output: -rw-r--r-- 1 user group 1024 Feb 16 10:00 file. The first 9 characters represent permissions for the owner, group, and others.

To add execute permission for the file's owner:

chmod u+x /path/to/file

To add read and write permissions for the group:

chmod g+rw /path/to/file

For a directory, execute permission (x) is essential; without it, access to its contents is denied:

chmod +x /path/to/directory

⚠️ Important: Do not assign 777 permissions (full access for everyone) unnecessarily, especially for system files. This is a serious security vulnerability.

Solution 2: Change File Ownership with chown

If the file belongs to another user (e.g., root) and you have sudo privileges, change the owner:

sudo chown new_user:new_group /path/to/file

Example: Make user alex the owner of file script.sh:

sudo chown alex:alex /home/alex/script.sh

To change only the group:

sudo chgrp group /path/to/file

This is useful for collaborative group work.

Solution 3: Use sudo to Run the Command

If the operation requires elevated privileges (e.g., modifying a system file), run the command with sudo:

sudo command arguments

For example:

sudo apt update
sudo rm /var/log/old_log

πŸ’‘ Tip: Configure /etc/sudoers via visudo to allow specific passwordless commands for trusted users, but do so cautiously.

Solution 4: Check Filesystem Mount Options

Sometimes the issue is that the partition is mounted with restrictive options. Find out how the partition containing the problematic file is mounted:

mount | grep /path/to/file

Or check /etc/fstab for permanent mounts. If options include noexec, nosuid, or nodev, these can block execution or modification. External USB drives are often mounted with noexec by default.

For a temporary fix (requires sudo), remount the partition without restrictive options:

sudo mount -o remount,exec /dev/sdXY /mount/point

Note that this may compromise security. It's better to copy the file to an internal partition if possible.

Solution 5: Check and Configure SELinux/AppArmor

On SELinux-enabled distributions (CentOS, RHEL, Fedora), check the file's security context:

ls -Z /path/to/file

If the context does not match the expected type (e.g., bin_t or usr_t for executables), restore the default context:

sudo restorecon -v /path/to/file

Or set it manually:

sudo chcon -t type /path/to/file

For AppArmor (Ubuntu, Debian), check active profiles:

sudo apparmor_status

AppArmor logs are in /var/log/kern.log or /var/log/syslog. If a profile blocks access, you can disable or adjust it.

Solution 6: Remove the Immutable Attribute

A file may be protected by the i flag (immutable), which prevents any changes, even by root. Check attributes:

lsattr /path/to/file

If i appears in the output (e.g., ----i-------- file), remove the attribute:

sudo chattr -i /path/to/file

Then retry the operation. This flag is often used for critical system files or logs.

Prevention

To minimize Permission denied errors:

  1. Configure umask: Set an appropriate umask in /etc/profile or ~/.bashrc so new files are created with correct default permissions (e.g., 022 for read/execute by all, but no write).
  2. Monitor ownership and group: When creating files in multi-user directories (e.g., /var/www), immediately assign the correct owner via chown or use setgid on the directory (chmod g+s).
  3. Avoid routine sudo use: Run commands as a regular user, resorting to sudo only for administrative tasks. This reduces risks of accidental system file changes.
  4. Regularly update the system: Security updates often include fixes for SELinux/AppArmor and other access-related components.
  5. Check mounting of critical partitions: Ensure system partitions (e.g., /, /usr) are mounted without unnecessary restrictions unless required by security policy.
  6. Educate users: If you administer a server or workstation, explain basic permission principles (chmod, chown) and safe sudo usage.

F.A.Q.

What does the 'Permission denied' error mean in Linux?
How to fix Permission Denied without administrator rights?
Why does Permission Denied occur even when using sudo?
How to prevent the Permission Denied error in the future?

Hints

Check current permissions
Change permissions
Use sudo to elevate privileges
Check file owner
Check filesystem mount
FixPedia

Free encyclopedia for fixing errors. Step-by-step guides for Windows, Linux, macOS and more.

Β© 2026 FixPedia. All materials are available for free.

Made with for the community