19

I want to write a permission fix script that uses find to fix permissions on files.

Mainly what I need is a find command that is able to list all files with execute bit set, regardless of the other permissions on the file (that's the trick).

migrated from serverfault.com Jul 22 '13 at 2:34

This question came from our site for system and network administrators.

  • 2
    What have you already tried? What research have you done? As written right now, you're just asking us to do your work for you, and you haven't shown any effort whatsoever in solving this yourself. – EEAA Jul 21 '13 at 14:30
  • Also, I'd highly recommend reading up on what types of questions are appropriate here before posting any more questions. You have quite a string of closed and down voted questions, and if not careful, you will likely run afoul of the automatic question ban. – EEAA Jul 21 '13 at 14:40
  • @EEAA: Sadly, I doubt that's anywhere near close to happening. If you have any rep at all it's really hard to get q-banned. – Iain Jul 21 '13 at 14:46
  • @Iain - fair enough. Hopefully he'll still heed the advice, though. – EEAA Jul 21 '13 at 14:47
  • 2
    @EEAA: I hope so too but people who can't be bothered to read manuals generally don't heed advice - they just find it easier to whinge about our attitude ... iyswim ;) – Iain Jul 21 '13 at 14:50
23

On GNU's find:

find /dir -type f -executable

On other versions, see the man page around -perm.

11

Believe it or not this is extensively documented in the find man page. On the CentOS and Ubuntu systems I have to hand there are even examples of this.

-perm /mode

Any of the permission bits mode are set for the file. Symbolic modes are accepted in this form. You must specify u',g' or `o' if you use a symbolic mode. See the EXAMPLES section for some illustrative examples. If no permission bits in mode are set, this test matches any file (the idea here is to be consistent with the behaviour of -perm -000).

So

find  . -perm /u+x

will find files where execute permission is set for the owner

find . -perm /u+x,o+x

will find files where execute permission is set for the owner and other and so on.

1

find /path/of/the/directory -type f -executable

  • @Could you please explain how that would work? – vfbsilva Jan 30 '15 at 20:45
  • Researched this : man7.org/linux/man-pages/man1/find.1.html -- the -executable flag: Matches files which are executable and directories which are searchable (in a file name resolution sense). – RayJ Nov 28 '17 at 6:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.