Fix “Permission denied” on Linux
Time 6 min
Level Intermediate
Updated
Linux gives every file an owner plus read (r), write (w) and execute (x) permissions. The error appears when one of them is missing.
Read the file's permissions
ls -l script.sh
bashThe output looks like
-rw-r--r-- 1 root root: no x, so it can't run, and root owns it.Make a script executable
chmod +x script.sh ./script.sh
bash