How to remove executable bit recursively from files (not directories)

With GNU chmod (on Ubuntu) single command variant (starting in the current directory):

chmod -R -x+X .


  • -R - operate recursively
  • -x - remove executable flags for all users
  • +X - set executable flags for all users if it is a directory

In this case the capital X applies only to directories because all executable flags were cleared by -x. Otherwise +X sets executable flag(s) also if the flag was originally set for any of user, group or others.

With BSD chmod (which is present on Mac OS X) you have to do it separately in two commands:

sudo chmod -R -x * && sudo chmod -R +X *

(If you want to include hidden files in the main directory as well, you likely need to change * to . (point), but it is untested.)

If you cd into the correct path first:

find . -type f -exec chmod -x {} \;


chmod -x $(find . -type f)

The find finds all files of type 'f' (which means regular file) in the path . and then calls chmod -x on each file. The {} gets substituted for the file name and the \; terminates the chmod command.

Under Linux and Unix in a terminal window or On Mac OS X, use this in

find . -type f -print0 | xargs -0 chmod -x