Permission Denied
Linux Linux
Severity: MinorWhat Does This Error Mean?
Linux 'Permission denied' means your user account does not have the rights to read, write, or execute a specific file or directory. Linux has a strict permission system — every file has an owner, a group, and permissions for everyone else. This error is usually fixed by using sudo, changing file ownership with chown, or changing permissions with chmod.
Affected Models
- Ubuntu
- Debian
- Fedora
- CentOS
- Arch Linux
- Linux Mint
- openSUSE
Common Causes
- You are trying to run a command that requires root (administrator) access without using sudo
- The file is owned by a different user account and you do not have read or write permission
- The file does not have the execute permission set, preventing it from being run as a program
- A directory has restrictive permissions that block access to files inside it
- SELinux or AppArmor security policies are blocking access beyond what standard permissions allow
How to Fix It
-
Use sudo for system-level commands. If the command requires administrator access, prefix it with sudo: sudo [your command]. Enter your password when prompted.
sudo stands for 'superuser do' — it runs the command as the root (administrator) user. Only use sudo for commands that genuinely need it.
-
Check file permissions. Run: ls -l [filename] to see who owns the file and what permissions are set. The output shows the owner, group, and permission flags.
For example: -rw-r--r-- means the owner can read and write, the group and others can only read. The owner is the name shown after the permission flags.
-
Change file ownership. If you need to own the file, run: sudo chown [yourusername] [filename] or for a folder: sudo chown -R [yourusername] [foldername]
The -R flag applies the ownership change recursively to all files inside a folder.
-
Add execute permission to a script. If you are trying to run a script and get permission denied, it may be missing the execute bit. Run: chmod +x [scriptname] to add it.
A script file must have the execute permission before Linux will allow it to be run as a program.
-
Add yourself to the right group. Some resources like USB devices, serial ports, and audio are controlled by groups. Run: sudo usermod -aG [groupname] [yourusername] then log out and back in.
Common groups you might need: 'sudo' for admin, 'dialout' for serial ports, 'audio' for audio devices, 'docker' for Docker.
When to Call a Professional
Permission denied errors are standard Linux behavior and always fixable by a user with sudo access. If you are locked out of your own system entirely, you can usually recover using single-user mode or a live USB. Contact a Linux professional only if you are completely locked out and recovery mode does not help.
Frequently Asked Questions
What does 'Permission denied' in a web server context mean?
If a web server like Apache or Nginx shows a permission denied error, it means the web server process does not have read access to the file it is trying to serve. The web server typically runs as a user like 'www-data' or 'nginx.' You need to make sure the web files are readable by that user.
Is it safe to use chmod 777?
chmod 777 gives everyone on the system full read, write, and execute access to a file. For your own personal files on a single-user desktop, it is not a security risk. On a server with multiple users or a web server, chmod 777 is dangerous — it allows any user or process to modify or delete the file. Use the minimum permissions needed.
I am the only user on my computer. Why do I still get permission denied?
Linux always distinguishes between your regular user account and the root (administrator) account. Even if you are the only person using the computer, you cannot modify system files without sudo. This protects your system from accidental damage and malware.