Symptoms
- 'Permission denied' when running a script
- Can't save changes to a file
- Can't write to a folder you expect to own
- Works with sudo but not normally
Likely causes
- CommonFile isn't marked executableScripts need execute permission set before they can be run directly.
- CommonFile or folder owned by a different user or rootFiles created by an installer or another user may not be writable by your account.
- PossibleWorking in a protected system directoryDirectories like /etc or /usr require elevated privileges to modify.
What to do
- Check current permissions with 'ls -l [filename]' to see who owns it and what access is allowed.
- To make a script executable, run 'chmod +x [filename]' then try running it again with './[filename]'.
- If the file is owned by another user or root, and it should be yours, run 'sudo chown $USER [filename]' to take ownership.
- Avoid using 'sudo' as a habitual fix for every permission issue since it can create files owned by root that cause future problems.
- If working in a system directory, confirm you actually need to modify it there versus your home folder.
- For persistent confusing permission issues, run 'namei -l [path]' to see permissions at every level of the path.
Tools and parts
- Terminal access
When to call a pro
Not typically needed; this is standard Linux administration.
Safety
Generally low risk
Generally low risk for a careful person. Stop if anything looks different from what this guide describes.