Written by
Jenny ZengSummary: This article from iBoysoft tells you the basics about the chmod utility on Mac, helping you change read, write, and execute permissions in Mac Terminal and fixing chmod not working.
The chmod utility on Mac is used to change the file system modes or permissions of files and directories. It controls who can read, write, or execute a file. If you need to change permissions on Mac, it's necessary to learn its usage.
7 types of file permissions on Mac
There are three types of file permissions: reading, writing, and executing. Every file or folder has one or more of these permissions, forming 7 levels of access. To leverage permissions, the 7 access is granted Unix-based symbolic and octal permission notations, as shown in the table below.
Permission Type | Symbolic Notation | Octal Notation |
No permissions | --- | 0 |
Execute only | --x | 1 |
Write only | -w- | 2 |
Write and execute | -wx | 3 |
Read only | r-- | 4 |
Read and execute | r-x | 5 |
Read and write | rw- | 6 |
Read, write, and execute | rwx | 7 |
To check file permissions on Mac, run the following command in Terminal.
ls -l
This will list all files in the current directory and their permissions for the owner, group, and others.
Examples:
rw-r--r-- | Read/write access for the owner and read-only access for group and others. |
rw------- | Read/write access for the owner and no access for group and others. |
rwxrw-rw- | Full access for the owner and read/write access for group and others. |
rwxr-xr-x | Full access for the owner and read/execute access for group and others. |
When running chmod in Mac Terminal, you can use either symbolic or octal notations to specify permissions.
① Symbolic notation uses +, -, or = to add, remove, or set specific permissions for different users.
Symbol | Description |
+ | Adds a permission. |
- | Removes a permission. |
= | Sets permissions explicitly. |
User Types | Meaning |
User (u) | The owner of the file. |
Group (g) | Users in the file's group. |
Others (o) | Everyone else. |
All (a) | User, group, and others collectively. |
Examples:
chmod u+x file_path | Adds execute permission for the owner. |
chmod g-w file_path | Removes write permission for the group. |
chmod o=r file_path | Sets read-only permission for others. |
chmod a=rw- file_path | Sets read and write permissions for all users while removing execute permissions if they were previously set. |
② Octal notation uses numbers (0-7) to represent permissions for user, group, and others.
Examples:
chmod 755 file_path | Sets full permissions for the owner and read/execute for group and others. |
chmod 777 file_path | Grants full permissions for all users. |
chmod 400 file_path | Sets read-only permissions to the owner and denies all permissions to the group and others. |
chmod 644 file_path | Grants read/write access for the owner and read-only for group and others. |
Now that you know the notation of each permission, we can move on to the actual usage of the chmod utility in Terminal.
How to change permissions on Mac in Terminal using chmod?
To change file permissions on Mac, you should understand the fundamentals of chmod first.
Note: Chmod won't work if you're not the owner of the file you want to change permissions for.
The basic syntax for chmod is:
chmod options permissions file/directory_path
options:
-R: Recursive. If you use this option, you change permissions for a directory and all its contents.
permissions:
Specified in symbolic or octal notation (explained above).
file/directory_path:
Path to the file or directory whose permissions you want to change. An easy way to get the file path on Mac is to drag and drop the file into the Terminal window.
Common chmod usage examples
- Here's how to change read, write, or execute permissions via Mac Terminal in examples.
Add read/write permission to the owner without modifying other permissions:
chmod u+rw file_path
Remove execute permission for Group without changing other permissions:
chmod g-x file_path
Set read permissions for all:
chmod a=r file_path
Set read/write/execute permissions to the owner and read/execute to group and others and apply the changes to all files and subfolders of a folder:
chmod -R 755 file_path
Make a script executable:
chmod +x file_path
Help others chmod a file on a Mac by sharing this guide!
Chmod on Mac not working?
You may encounter errors when using chmod on Mac if not done correctly. Here, we summarised some common errors and solutions.
chmod: no such file or directory
This means you didn't provide a valid file or directory path. Revising the command and using the correct file path will resolve it.
chmod: operation not permitted
This message appears when Terminal doesn't have Full Disk Access. You can enable it in System Settings > Privacy & Security > Full Disk Access.
chmod: command not found
This error indicates the syntax of your command is wrong.
Chmod doesn't change permissions
If you run the chmod command successfully, but it doesn't change permissions, you're likely not the file's owner. To fix it, you can run the command below to make yourself the owner.
sudo chown -R $(whoami) .
Share this guide to benefit others who want to know chmod on Mac!