Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Use chmod -R MODE DIRECTORY to apply permission changes to a directory and its descendants. The important choice is MODE: a single recursive mode affects both files and directories, even though they often need different permissions. For mixed trees, symbolic modes such as u+rwX can avoid making every ordinary file executable. GNU/Linux and macOS share core permission concepts, but GNU-specific options and symlink behavior should not be assumed on a Mac.

What chmod -R does

The -R option tells chmod to process the named directory and its hierarchy. POSIX specifies recursive processing of the directory and its files, while the GNU Coreutils manual documents the same behavior for GNU/Linux (GNU Coreutils chmod manual; POSIX chmod(1p)).

General form:

chmod -R MODE DIRECTORY

For example, this GNU/Linux command adds owner read/write and conditional execute/search permissions, then removes all permissions from group and other:

chmod -R u+rwX,go-rwx -- ./project

-- marks the end of options so a path beginning with a hyphen is treated as a path, not an option. This form is GNU-specific; check man chmod on macOS before using -- or any other GNU-only option. The mode also makes ./project private to its owner, which may break shared access or applications that run under another account.

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Choose a mode that fits files and directories

Permission bits apply differently depending on the item’s type. On a regular file, execute means the file can be run as a program; on a directory, execute means search or traversal—being able to access entries through that directory. Directory read permits listing names, and directory write permits changing entries (Apple’s archived Shell Script Security: Changing File Permissions and File System Details describe these permission concepts).

Use symbolic modes for targeted changes

Symbolic modes identify classes and operations: u is owner, g group, o other, and a all. The + operator adds selected bits, - removes them, and = sets the selected classes to the listed bits, removing other bits in those classes. GNU documentation notes qualifications for set-ID bits on directories when using assignment (GNU Coreutils chmod manual).

  • chmod -R go-w DIRECTORY removes group and other write permission without replacing the rest of their mode bits.
  • chmod -R u+rwX DIRECTORY adds owner read/write, plus execute on directories and on files that already have at least one execute bit. Capital X is useful in mixed trees because it does not make every ordinary file executable. POSIX describes conditional X as commonly useful with recursive changes (POSIX chmod(1p)).

Choose the classes and bits for the intended users. Do not treat either example as a universal repair command: removing group access can disrupt shared work, and adding owner write access may not suit a protected or managed tree.

Use octal modes only when one fixed pattern is intended

Octal digits combine read (4), write (2), and execute (1) for owner, group, and other. For example, 755 means owner rwx, group r-x, and other r-x; 644 means owner rw-, group r--, and other r--. Apple’s archived documentation explains numeric and human-readable modes (Shell Script Security: Changing File Permissions).

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

A recursive command such as chmod -R 755 DIRECTORY assigns that same pattern to every file and directory. It can make every regular file executable; chmod -R 644 DIRECTORY can remove directory search permission, making contents inaccessible. If files and directories need different fixed patterns, a single recursive octal mode is not a good fit; plan separate, type-aware operations rather than applying one pattern blindly.

Does chmod -R follow symbolic links?

There is no safe cross-platform answer based on the command name alone. GNU chmod documents traversal controls -H, -L, and -P; its manual says -H is the default with -R, and -L follows every symlink to a directory encountered. GNU recursive traversal normally ignores symlinks encountered inside the tree, while a symlink supplied as the command-line operand has distinct behavior (GNU Coreutils chmod manual). These are GNU manual details, not macOS guarantees.

POSIX specifies recursive processing but does not establish that GNU traversal options or defaults are available everywhere (POSIX chmod(1p)). Apple’s archived permission guidance does not establish the current macOS command-line traversal defaults. On the Mac you will use, read man chmod and inspect symlinks and their destinations before choosing traversal behavior. Avoid following links recursively until you know which targets would be changed.

Check the path, access needs, and platform first

  1. Confirm the target. Inspect the exact directory before running a recursive change. Quote paths containing spaces, for example "./Project Files". Use -- before a path that could begin with a hyphen only when the installed implementation supports it.
  2. Decide who needs access. Consider the owner, group, other users, programs, shared files, and special directories. A directory’s search permission is not the same as a file’s execute permission.
  3. Prefer the smallest change that meets the goal. For one class-specific adjustment, use a symbolic change such as go-w. For conditional execute/search across a mixed tree, consider capital X. Use a fixed octal pattern recursively only when that same pattern is appropriate for both files and directories.
  4. Check local behavior. Consult man chmod on the actual Linux or macOS system for supported options and symlink semantics. POSIX warns that changing directory permissions before descendants can cause operations to fail when access is removed; changing them last can cause problems when restoring access in a restricted hierarchy. Its advice is direct: “Users should not try to make a hierarchy inaccessible to themselves” (POSIX chmod(1p), Application Usage).
  5. Review the result. Inspect representative files and directories, then confirm the relevant user or application can still perform its work. This is especially important after broad changes or where symlinks are present.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Ownership, privileges, and access controls can affect the result

POSIX says a process generally needs an effective user ID matching the file owner, or appropriate privileges, to change mode bits. Apple’s archived guidance likewise says users can change permissions on files they own, while root can change permissions more broadly subject to filesystem flags (POSIX chmod(1p); Apple Shell Script Security). Do not reach for sudo chmod -R as a routine first step: elevated access increases the potential impact of a mistaken path or mode.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Mode bits may not be the only access rules. macOS supports POSIX access control lists (ACLs), and POSIX leaves effects on additional access-control mechanisms implementation-defined (Apple File System Details; Apple Understanding Permissions; POSIX chmod(1p)). If access still differs from what ls -l appears to show, inspect ACLs and relevant filesystem or platform controls too.

Set-user-ID, set-group-ID, and sticky bits are special modes, not ordinary read/write/execute choices. GNU documents that system policy may clear or ignore set-ID bits; the sticky bit on a directory restricts unprivileged users from removing or renaming entries belonging to others, except where they own the file or directory (GNU Coreutils chmod manual). Avoid changing special bits recursively unless you understand the effect for that tree and platform.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.