Error Permission denied (code EACCES) in Linux means that the current user does not have the necessary rights to perform the operation. It can occur when running scripts, opening files, or trying to modify system directories.
Main Causes
- Insufficient permissions on the file or folder
- Missing execute bit on the script
- Attempting to access system directories without
sudo - Incorrect file owner
Method 1: Run with sudo
If the operation requires administrator rights:
sudo command
Example:
sudo apt update
Method 2: Add execute permission
If the error occurs when running a script:
chmod +x script.sh
./script.sh
Method 3: Check permissions
Check the current permissions:
ls -l filename
If you need to change the owner:
sudo chown user:user filename
Method 4: Check directory permissions
Even if the file is accessible, the parent directory may be closed:
ls -ld directory
If necessary, change the permissions:
sudo chmod 755 directory
Conclusion
The EACCES error in Linux is almost always related to access rights. Using sudo, correctly setting chmod, and chown usually fully resolve the issue.