Skip to content
Permission denied

Permission denied

DodaTech 2 min read

The Permission denied error in Linux means your user lacks the required access rights to read, write, or execute a file or directory. This guide shows you how to diagnose and fix it using standard permission commands.

What It Means

Linux uses a permission system with three tiers: owner, group, and others. Each tier has read (r), write (w), and execute (x) flags. When you try an operation your user doesn’t have permission for, the kernel blocks it and prints Permission denied.

Why It Happens

  • The file doesn’t have the execute bit set for a script or binary.
  • You’re trying to write to a directory owned by root (like /etc/ or /usr/).
  • The file is owned by another user and doesn’t grant you access.
  • A parent directory lacks execute permission, blocking access to files inside it.
  • The filesystem is mounted with restrictive options (e.g., noexec, read-only).

How to Fix It

1. Check current permissions

ls -l filename

The output shows permissions as a 10-character string like -rwxr-xr--. The first character is the file type, then three groups of three: owner, group, others.

2. Add execute permission for a script

chmod +x script.sh
./script.sh

chmod +x adds execute for all tiers. Use chmod u+x for only the owner.

3. Run a command as root with sudo

sudo apt update
sudo systemctl restart nginx

Only use sudo when you trust the command — it runs with full root privileges.

4. Change file ownership

sudo chown youruser:yourgroup filename

Replace youruser with your username. Use chown -R to change ownership recursively on directories.

5. Fix parent directory permissions

If you can’t cd into a directory, its execute bit may be missing:

chmod +x /path/to/dir

6. Check filesystem mount options

mount | grep /mountpoint

If you see noexec or ro, remount with the right options:

sudo mount -o remount,exec /mountpoint
What does chmod 755 mean?
chmod 755 sets permissions to rwxr-xr-x: owner can read/write/execute, group and others can read/execute. This is the standard for executable files and directories.
Why do I still get Permission denied with sudo?
If sudo itself fails, your user isn’t in the sudoers file. Boot into recovery mode or ask a root user to add you with usermod -aG sudo youruser.
What's the difference between chmod and chown?
chmod changes permission flags (read/write/execute). chown changes ownership (which user and group own the file). You often need both: chown to take ownership, then chmod to set the right permissions.

Built by the developers of DodaTech

Doda Browser, DodaZIP & Durga Antivirus Pro