You type a command, expecting a clean run, and instead you get:
bash: ./deploy.sh: Permission denied.
It's that frustrating error that halts deployments, derails builds, or stalls server updates—often forcing you to waste hours hunting down a single permission flag. Almost every Linux user has encountered it, and despite its commonality, it still sparks panic and downtime.
Here’s the deal—it doesn’t mean something is broken. It means you’re trying to do something you don’t have rights for. Linux is just enforcing its security boundaries.
In this article, we’ll explore why this error happens, what it means, and how to fix it safely—without compromising security.
The “Permission Denied” error in Linux appears when a user doesn’t have proper access rights to read, write, or execute a file.
In real-world setups—like containers, multi-user environments, or CI/CD pipelines—permissions can get messy fast.
chmod 777, and now it’s chaos.It’s not just about “forgot to add +x”. It’s about how Linux enforces boundaries to keep your system secure.
Every file and folder in Linux has three types of access—read (r), write (w), and execute (x)—applied to three entities:
| Category | Symbol | Description |
|---|---|---|
| User | u | Owner of the file |
| Group | g | Members of the file’s group |
| Others | o | Everyone else |
Example:
-rwxr-xr-- 1 dev dev 1234 Oct 10 12:00 app.sh
The owner (dev) can read, write, and execute; the group can read and execute; others can only read.
Each right is represented by a number:
So chmod 755 file.sh = 7 (rwx) for owner, 5 (r-x) for group, 5 (r-x) for others.
You cloned a repo and tried:
./build.sh
The shell throws “Permission denied.” Fix:
chmod +x build.sh
git update-index --chmod=+x build.sh
Error: Permission denied (publickey). Fix:
chmod 600 ~/.ssh/id_rsa
chown $USER:$USER ~/.ssh/id_rsa
sudo chown -R www-data:www-data storage
sudo chmod -R 750 storage
UID mismatch between host and container:
docker run --user $(id -u):$(id -g) ...
sudo chown -R 1000:1000 /data
Need root rights for system configs:
sudo nano /etc/nginx/nginx.conf
See also: Website Optimization: Choosing Between NGINX and Apache
ls -l filenamechmod +x script.shsudo chown youruser:youruser /path/to/dirsudo commandgetenforce
sudo ausearch -m avcchmod 744 file → owner full, others read-onlychmod 755 file → owner full, others can read and executechmod 777 file → everyone can do everything (not recommended!)Rule of thumb:
Three special flags that modify how execution and ownership behave:
mount | grep your_folderumask 022.auditctl -w /etc/ -p w -k perms
ausearch -k perms
“Permission Denied” isn’t a bug—it’s Linux doing its job to prevent unsafe actions. Understanding ownership and rights makes the error predictable and fixable.
In production, small permission misconfigurations can snowball into costly downtime. To avoid manual headaches, consider our managed VPS services, which handle permissions, security, and maintenance automatically, letting you focus on your code instead.
chmod +x script.sh to add the flag, or make it permanent with git update-index --chmod=+x script.sh.755 for scripts and 644 for configs.auditd.