Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

chmod: How to recursively add execute permissions only to files which already have execute permission [closed]

I noticed:

chmod -R a+x adds execute permissions to all files, not just those who are currently executable.

Is there a way to add execute permissions only to those files who already have an execute set for the user permission?

like image 998
Clinton Avatar asked Aug 04 '11 07:08

Clinton


People also ask

What is chmod 777 and chmod 775 and chmod 755?

777 - all can read/write/execute (full access). 755 - owner can read/write/execute, group/others can read/execute. 644 - owner can read/write, group/others can read only.

What does chmod 644 do?

Permissions of 644 mean that the owner of the file has read and write access, while the group members and other users on the system only have read access. For executable files, the equivalent settings would be 700 and 755 which correspond to 600 and 644 except with execution permission.

What is the meaning of chmod 744?

chmod 744 file1. sets read, write and execute for the owner and read only for the group and all others. chmod 777 file1. sets read, write and execute for everyone.

What is the chmod 755?

755 means read and execute access for everyone and also write access for the owner of the file. When you perform chmod 755 filename command you allow everyone to read and execute the file, the owner is allowed to write to the file as well.


2 Answers

Use find:

find . -perm /u+x -execdir chmod a+x {} \;
like image 52
Oliver Charlesworth Avatar answered Oct 08 '22 23:10

Oliver Charlesworth


You can use find to get all those files:

find . -type f -perm -o+rx -print0 | xargs -0 chmod a+x

Update: add -print0 to preserve space in filenames

like image 20
Reto Aebersold Avatar answered Oct 08 '22 21:10

Reto Aebersold