0

I'm so confused on all of these options because I know that -perm /a+x means files that have executable permissions for any user and -perm -a+x means that files that have to have executable permissions for all users but then what are the differences between a+x and a=x?

[user@j6727961 ~]$ find -name 'perm*' -perm /a+x
./perm
./perm1
[user@j6727961 ~]$ find -name 'perm*' -perm /a=x
./perm
./perm1
[user@j6727961 ~]$ ll
total 57280
drwxrwxr-x. 2 user user       54 Dec  9 20:06 exercises
-rwxrwxrwx. 1 user user        0 Dec 10 21:08 perm
----rwxrwx. 1 user user        0 Dec 10 21:09 perm1
[user@j6727961 ~]$ find -name 'perm*' -perm -a=x
./perm
[user@j6727961 ~]$ find -name 'perm*' -perm -a+x
./perm
1

For purposes of using it with find, no bit is going to be changed, both a=x and a+x means the same.


But in general, the three options are (+mode is deprecated):

 mode    # exactly
-mode    # ALL bits SET
/mode    # ANY bit  SET

That means that mode 760 will search for files with permissions exactly 760.

A -mode 220 (in binary 010 010 000, or -w--w----) will search for all files that have the write bit for owner and group (both) set, and any other bit also set, it doesn't matter,
like 630 (110 011 000 or rw- -rx ---).

And a /mode 220 will match with ANY bit set.
Like 220,230,360,270 and in fact:
any (in binary) x1x x1x xxx, where x means "don't care".

The other way to express bits set are the:

a (for all)
u (for user)
g (for group) and
o (for others)

An a+r means the same as setting (adding or binary OR) r-- r-- r-- to the permissions a file might have. Or an a+x means (add) --x--x--x or 001001001 or 111.

So, mixing both:

  • perm a+x ===> perm 111 ===> A file that has only exactly permisions 111
  • perm -a+x ===> perm -111 ===> Executable by u(ser) g(roup) AND o(thers)
  • perm /a+x ===> perm /111 ===> Executable by u(ser) g(roup) OR o(thers)

The a=x or a+x only has a specific meaning for the command chmod.
The u+x change the execute bit (set it) for the user, i.e.: OR 100. But the u=x will clear the other two bits for user and leave set only the execute bit, thus making the user permissions exactly 1.
A chmod u+rwx file will set the bits to exactly 7 or rwx for the user.
A chmod u=rwx file will do exactly the same.

For find, no bit is going to be changed, both a=x and a+x means the same.

  • in summary for my question: "For find, no bit is going to be changed, both a=x and a+x means the same." – VaTo Dec 10 '16 at 22:55
  • @Vato Well, yes, that doesn't cover the difference between -a+x and /a+x, but if that is the bit that you needed clear, then yes, that's pretty much it. – Isaac Dec 10 '16 at 23:00
  • don't get me wrong I still appreciate your answer, but for my purpose of using it with find I think that's what I was looking for. – VaTo Dec 11 '16 at 2:47

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.