Systems

file permissions

File permissions decide who is allowed to do what with a file: read it, change it, or run it. On Unix-like systems (Linux, macOS) every file carries three little switches — r (read), w (write), x (execute) — and they're set separately for three groups of people: the owner, the owner's group, and everyone else.

That's what the cryptic 'rwxr-xr-x' from ls -l is showing you: the owner can read/write/run, while the group and everyone else can only read and run. The same thing gets written as a number, like 755, where each digit is just r=4 + w=2 + x=1 added up. You change them with chmod.

The one that trips up every beginner is x. A script isn't allowed to run just because it exists — it needs the execute bit. That's why you so often type chmod +x deploy.sh before ./deploy.sh will work, and why a missing x earns you a curt 'Permission denied'.

$ ls -l deploy.sh
-rw-r--r--  1 you  staff  812 deploy.sh
$ chmod +x deploy.sh   # add the execute bit
$ ./deploy.sh          # now it runs

No x, no run — chmod +x flips the execute switch on.

The number 755 isn't magic: it's three digits of r=4 + w=2 + x=1 — owner 7 (rwx), group 5 (r-x), others 5 (r-x).

Also called
chmodrwx755permission deniedexecutable bit