chmod 755 means: the owner can read, write, and execute the file. Everyone else can read and execute it, but not modify it.
chmod 755 script.sh
This is the standard permission for executable scripts and programs.
Breaking Down 755
Each digit represents permissions for a different group:
| Digit | Who | Permissions |
|---|---|---|
| 7 | Owner (you) | Read + Write + Execute |
| 5 | Group | Read + Execute |
| 5 | Others | Read + Execute |
So 755 means:
- You can do anything with the file
- Everyone else can run it and read it, but not change it
How the Numbers Work
Permissions are calculated by adding:
| Number | Permission |
|---|---|
| 4 | Read (r) |
| 2 | Write (w) |
| 1 | Execute (x) |
So:
- 7 = 4 + 2 + 1 = Read + Write + Execute
- 6 = 4 + 2 = Read + Write
- 5 = 4 + 1 = Read + Execute
- 4 = Read only
- 0 = No permissions
Common Permission Sets
| Number | Meaning | When to use |
|---|---|---|
| 755 | rwxr-xr-x | Executable scripts, programs |
| 644 | rw-r--r-- | Regular files (documents, configs) |
| 700 | rwx------ | Private executables |
| 600 | rw------- | Private files (SSH keys, secrets) |
| 777 | rwxrwxrwx | Everyone can do everything (rarely needed, often dangerous) |
Reading Permissions
To see a file's current permissions:
ls -l script.sh
Output:
-rwxr-xr-x 1 you staff 1234 Jan 15 10:00 script.sh
The -rwxr-xr-x breaks down as:
| Characters | Meaning |
|---|---|
- |
It's a file (d = directory) |
rwx |
Owner: read, write, execute |
r-x |
Group: read, execute (no write) |
r-x |
Others: read, execute (no write) |
When to Use chmod 755
Making a script executable:
chmod 755 myscript.sh
./myscript.sh
Fixing "permission denied" on a script you wrote:
chmod 755 backup.sh
After downloading an executable:
chmod 755 downloaded-tool
When to Use chmod 644
For regular files that shouldn't be executed:
chmod 644 document.txt
chmod 644 config.json
This is the default for most files.
Private Files: 600 and 700
For files only you should access:
chmod 600 ~/.ssh/id_rsa # SSH private key
chmod 700 ~/.ssh # SSH directory
SSH actually requires these permissions - it refuses to work if your key is readable by others.
The Dangerous 777
chmod 777 file.sh # Don't do this unless you know why
This lets anyone read, write, and execute. Rarely correct. If something tells you to use 777, there's usually a better solution.
Using Letters Instead of Numbers
You can also use symbolic notation:
chmod u+x script.sh # Add execute for user (owner)
chmod go-w file.txt # Remove write for group and others
chmod a+r document.pdf # Add read for all
| Symbol | Meaning |
|---|---|
| u | User (owner) |
| g | Group |
| o | Others |
| a | All (everyone) |
| + | Add permission |
| - | Remove permission |
| = | Set exactly |
Changing Folder Permissions
Folders work the same way, but execute means "can enter the directory":
chmod 755 myfolder/
For a folder and everything inside it:
chmod -R 755 myfolder/
The -R means recursive.
Why Permissions Matter
- Security: Prevents unauthorized access to sensitive files
- Functionality: Scripts need execute permission to run
- Multi-user systems: Controls what others can do with shared files
On your personal Mac, you're mostly dealing with the "owner" permissions. The others matter more on shared or server systems.
Keep Learning
Understanding permissions is part of understanding how Unix (which macOS is based on) works. The free course covers more fundamentals.
Check it out at Mac Terminal for Humans.