TIL about the conditional execute flag in chmod
2025-06-20 • 1 min

The conditional execute flag X (uppercase) is a special flag in chmod that:

execute/search only if the file is a directory or already has execute permission for some user (X)

In other words, it ignores any regular files that does not have the execute bit x set (non-executables). This is useful when trying to recursively chmod +x a directory of files and sub-directories without having to distinguish between the regular files and directories/executables.

# Usage

$ chmod -R u=rwX,g=rX,o=rX foo/

The above will set in foo/ and its sub-directories:

# References

Edited: 2025-06-20