Quando eu faço chmod _+x -R /dir
onde "_" é qualquer combinação de (u, g, o, a), se depois eu fizer chmod g+X -R /dir
, os arquivos também ganham permissões executáveis.
Por que isso acontece? Esse comportamento só acontece se eu usar primeiro o "x" inferior e, em seguida, usar o "X" superior.
Primeiro exemplo:
[root@jesc5161 home]# chmod a-rwx -R finance/
[root@jesc5161 home]# ll
total 4
drwxr-xr-x. 3 root root 17 May 2 2015 ec2-user
d---------. 3 root finance 65 Apr 22 22:12 finance
drwx------. 9 user user 4096 Apr 22 21:28 user
[root@jesc5161 home]# ll finance/
total 0
d---------. 2 root root 6 Apr 22 21:41 accounting
----------. 1 user user 0 Apr 22 22:06 myfile1
----------. 1 user finance 0 Apr 22 22:12 myfile2
----------. 1 user user 0 Apr 22 22:12 myfile3
[root@jesc5161 home]# chmod u+x -R finance/
[root@jesc5161 home]# ll
total 4
drwxr-xr-x. 3 root root 17 May 2 2015 ec2-user
d--x------. 3 root finance 65 Apr 22 22:12 finance
drwx------. 9 user user 4096 Apr 22 21:28 user
[root@jesc5161 home]# ll finance/
total 0
d--x------. 2 root root 6 Apr 22 21:41 accounting
---x------. 1 user user 0 Apr 22 22:06 myfile1
---x------. 1 user finance 0 Apr 22 22:12 myfile2
---x------. 1 user user 0 Apr 22 22:12 myfile3
Aqui só desejo dar permissão executável ao grupo, mas os arquivos também recebem permissões executáveis:
[root@jesc5161 home]# chmod g+X -R finance/
[root@jesc5161 home]# ll
total 4
drwxr-xr-x. 3 root root 17 May 2 2015 ec2-user
d--x--x---. 3 root finance 65 Apr 22 22:12 finance
drwx------. 9 user user 4096 Apr 22 21:28 user
[root@jesc5161 home]# ll finance/
total 0
d--x--x---. 2 root root 6 Apr 22 21:41 accounting
---x--x---. 1 user user 0 Apr 22 22:06 myfile1
---x--x---. 1 user finance 0 Apr 22 22:12 myfile2
---x--x---. 1 user user 0 Apr 22 22:12 myfile3
Outro exemplo:
[root@jesc5161 home]# chmod a-rwx -R finance/
[root@jesc5161 home]# ll
total 4
drwxr-xr-x. 3 root root 17 May 2 2015 ec2-user
d---------. 3 root finance 65 Apr 22 22:12 finance
drwx------. 9 user user 4096 Apr 22 21:28 user
[root@jesc5161 home]# ll finance/
total 0
d---------. 2 root root 6 Apr 22 21:41 accounting
----------. 1 user user 0 Apr 22 22:06 myfile1
----------. 1 user finance 0 Apr 22 22:12 myfile2
----------. 1 user user 0 Apr 22 22:12 myfile3
[root@jesc5161 home]# chmod u+rwx -R finance/
[root@jesc5161 home]# ll
total 4
drwxr-xr-x. 3 root root 17 May 2 2015 ec2-user
drwx------. 3 root finance 65 Apr 22 22:12 finance
drwx------. 9 user user 4096 Apr 22 21:28 user
[root@jesc5161 home]# ll finance/
total 0
drwx------. 2 root root 6 Apr 22 21:41 accounting
-rwx------. 1 user user 0 Apr 22 22:06 myfile1
-rwx------. 1 user finance 0 Apr 22 22:12 myfile2
-rwx------. 1 user user 0 Apr 22 22:12 myfile3
Mais uma vez, desejo apenas dar permissão executável ao grupo, mas os arquivos também ganham permissões executáveis.
[root@jesc5161 home]# chmod g+X -R finance/
[root@jesc5161 home]# ll
total 4
drwxr-xr-x. 3 root root 17 May 2 2015 ec2-user
drwx--x---. 3 root finance 65 Apr 22 22:12 finance
drwx------. 9 user user 4096 Apr 22 21:28 user
[root@jesc5161 home]# ll finance/
total 0
drwx--x---. 2 root root 6 Apr 22 21:41 accounting
-rwx--x---. 1 user user 0 Apr 22 22:06 myfile1
-rwx--x---. 1 user finance 0 Apr 22 22:12 myfile2
-rwx--x---. 1 user user 0 Apr 22 22:12 myfile3
Aqui está um exemplo em que "funciona", mas como você pode ver, NÃO usei "x" inferior antes de usar o "X" superior
[root@jesc5161 home]# chmod a-rwx -R finance/
[root@jesc5161 home]# ll
total 4
drwxr-xr-x. 3 root root 17 May 2 2015 ec2-user
d---------. 3 root finance 65 Apr 22 22:12 finance
drwx------. 9 user user 4096 Apr 22 21:28 user
[root@jesc5161 home]# ll finance/
total 0
d---------. 2 root root 6 Apr 22 21:41 accounting
----------. 1 user user 0 Apr 22 22:06 myfile1
----------. 1 user finance 0 Apr 22 22:12 myfile2
----------. 1 user user 0 Apr 22 22:12 myfile3
[root@jesc5161 home]# chmod a+rw -R finance/
[root@jesc5161 home]# ll
total 4
drwxr-xr-x. 3 root root 17 May 2 2015 ec2-user
drw-rw-rw-. 3 root finance 65 Apr 22 22:12 finance
drwx------. 9 user user 4096 Apr 22 21:28 user
[root@jesc5161 home]# ll finance/
total 0
drw-rw-rw-. 2 root root 6 Apr 22 21:41 accounting
-rw-rw-rw-. 1 user user 0 Apr 22 22:06 myfile1
-rw-rw-rw-. 1 user finance 0 Apr 22 22:12 myfile2
-rw-rw-rw-. 1 user user 0 Apr 22 22:12 myfile3
[root@jesc5161 home]# chmod g+X -R finance/
[root@jesc5161 home]# ll
total 4
drwxr-xr-x. 3 root root 17 May 2 2015 ec2-user
drw-rwxrw-. 3 root finance 65 Apr 22 22:12 finance
drwx------. 9 user user 4096 Apr 22 21:28 user
[root@jesc5161 home]# ll finance/
total 0
drw-rwxrw-. 2 root root 6 Apr 22 21:41 accounting
-rw-rw-rw-. 1 user user 0 Apr 22 22:06 myfile1
-rw-rw-rw-. 1 user finance 0 Apr 22 22:12 myfile2
-rw-rw-rw-. 1 user user 0 Apr 22 22:12 myfile3
[root@jesc5161 home]# chmod o+X -R finance/
[root@jesc5161 home]# ll
total 4
drwxr-xr-x. 3 root root 17 May 2 2015 ec2-user
drw-rwxrwx. 3 root finance 65 Apr 22 22:12 finance
drwx------. 9 user user 4096 Apr 22 21:28 user
[root@jesc5161 home]# ll finance/
total 0
drw-rwxrwx. 2 root root 6 Apr 22 21:41 accounting
-rw-rw-rw-. 1 user user 0 Apr 22 22:06 myfile1
-rw-rw-rw-. 1 user finance 0 Apr 22 22:12 myfile2
-rw-rw-rw-. 1 user user 0 Apr 22 22:12 myfile3
[root@jesc5161 home]# chmod u+X -R finance/
[root@jesc5161 home]# ll
total 4
drwxr-xr-x. 3 root root 17 May 2 2015 ec2-user
drwxrwxrwx. 3 root finance 65 Apr 22 22:12 finance
drwx------. 9 user user 4096 Apr 22 21:28 user
[root@jesc5161 home]# ll finance/
total 0
drwxrwxrwx. 2 root root 6 Apr 22 21:41 accounting
-rw-rw-rw-. 1 user user 0 Apr 22 22:06 myfile1
-rw-rw-rw-. 1 user finance 0 Apr 22 22:12 myfile2
-rw-rw-rw-. 1 user user 0 Apr 22 22:12 myfile3