chmod Change file permissions
Sets who can read, write and run a file or folder. You reach for it to make a script executable, to lock a private file down, or to fix a "Permission denied" error. Permissions can be given as a number (such as 755) or as letters (such as u+x).
Synopsis
chmod [-fhv] [-R [-H | -L | -P]] mode file ...
chmod 755 file
chmod u+x file
Common options
| Option or form | What it does |
|---|---|
-R | Apply the change to a folder and everything inside it. Use with care |
-v | Verbose: print each file as its mode is changed. Repeat it (-vv) to also see the old and new modes |
-f | Stay quiet about files that cannot be changed, and do not report failure in the exit status |
-h | If the target is a symbolic link, change the link itself instead of the file it points to |
-H, -L, -P | With -R, choose how symbolic links are treated: -H follows links named on the command line, -L follows all links, -P follows none (the default) |
u+x | Symbolic mode. Who: u (owner), g (group), o (others), a (all). Action: + adds, - removes, = sets exactly. Permission: r read, w write, x run or enter |
755 | Octal mode. Three digits for owner, group and others. Read is 4, write is 2, execute is 1, and you add them up. 7 is rwx, 5 is r-x, 6 is rw-, 4 is r-- |
X | A symbolic permission: execute only if the item is a folder or already executable by someone. Useful with -R so plain files do not become executable |
Examples
chmod u+x script.sh && ./script.sh
hello
chmod 644 notes.txt && ls -l notes.txt
chmod 600 data.csv && ls -l data.csv
chmod go-w notes.txt && ls -l notes.txt
chmod 755 script.sh && ls -l script.sh
chmod -R u+rwX,go+rX docs && ls -lR docs
Notes
- Reading octal: each digit is a sum. Read = 4, write = 2, execute = 1. So 755 is rwxr-xr-x (owner everything, others read and run), and 644 is rw-r--r-- (owner read and write, others read only). The digits go in the order owner, group, others.
- Never use 777. It lets every user on the machine change and replace the file. If something says "Permission denied", find out which user needs access and grant exactly that. Usually 755 for programs and folders, or 644 for plain files, is enough.
- chmod -R changes every file and folder under the target, and a wrong mode can break a system or project. Check the path first, never point it at /, your home folder or a bare *, and prefer symbolic X so plain files do not all become executable. Making things executable with chmod -R 755 is a common mistake.
- A folder needs the x (execute) bit to be entered or searched. Without it you cannot cd into the folder or open files inside it, even if you can list names with r.
- Only the file owner or the super user can change a mode. To change who owns a file, use chown instead. On macOS, chmod can also edit access control lists with options such as -a and -N, which most day-to-day work does not need.
See also
Last reviewed 2026-10-07.