Dave's Brain

Browse - Computer Tips - How can I find all the executable files in a file tree?

Date: 2016jan11
OS: Linux

Q.  How can I find all the executable files in a file tree?

A.  Use the find command like this:

find /home/myhome -type f -perm /a+x
This looks at everything below folder /home/myhome -type f limits it to just Files since directories are probably going to have the execute (change to) bit set for some user. -perm /a+x has the same syntax as chmod. This means eXecuute for Any user. Once you have found the files you can do something with them. For example, this will remove execute permission:
find /home/myhome -type f -perm /a+x -exec chmod a-x {} \;

Add a comment

Sign in to add a comment
Copyright © 2008-2017, dave - Code samples on Dave's Brain is licensed under the Creative Commons Attribution 2.5 License. However other material, including English text has all rights reserved.