20 Find oneliners for changing file and folder permissions

20 Find oneliners for changing file and folder permissions

In this tutorial I will show you the 20 Find oneliners for changing file and folder permissions in Linux.

1. Add execution rights for the user to all the files in the current directory:

find . -type f -exec chmod u+x {} +

2. Add execution rights for the user to all the directories in the current directory:

find . -type d -exec chmod u+x {} +

3. Remove the group and others execution rights for all the files in the current directory:

find . -type f -exec chmod go-x {} +

4. Remove the group and others execution rights for all the folders in the current directory:

find . -type d -exec chmod go-x {} +

5. Set the rwx permissions for the user on all the files in the current directory:

find . -type f -exec chmod u=rwx {} +

6. Set the rwx permissions for the user on all the folders in the current directory:

find . -type d -exec chmod u=rwx {} +

7. Add sticky bit to all the directories in the current folder:

find . -type d -exec chmod +t {} +

8. Remove sticky bit from all the directories in the current folder:

find . -type d -exec chmod -t {} +

9. Add setuid to all the files in the current folder:

find . -type f -exec chmod u+s {} +

10. Remove the setuid from all the files in the current folder:

find . -type f -exec chmod u-s {} +

11. Add the setgid to all the files in the current folder:

find . -type f -exec chmod g+s {} +

12. Remove the setgid from all the files in the current directory:

find . -type f -exec chmod g-s {} +

13. Remove the write permission for everybody and set rwx for the user, on all the files in the current directory:

find . -type f -exec chmod a-w,u=rwx {} +

14. Remove the write permission for everybody and set rwx for the user, on all the directories in the current directory:

find . -type d -exec chmod a-w,u=rwx {} +

15. Set 755 permissions on all the files in the current directory:

find . -type f -exec chmod 755 {} +

16. Set 644 on all the directories in the current folder:

find . -type d -exec chmod 644 {} +

17. Set the permissions of file1 to all the files in the directory:

find . -type f -exec chmod –reference file1 * {} +

18. Set the permissions of dir1 to all the directories in the current folder:

find . -type d -exec chmod –reference dir1 * {} +

19. Remove all the setuid and setgid permissions on all the files in the current directory:

find . -type f -exec chmod -s {} +

20. Set the group and other permissions to 0 (zero) on all the files in the current directory:

find . -type f -exec chmod go= {}+

 
Enjoyed this video?
20 Find oneliners for changing file and folder permissions
"No Thanks. Please Close This Box!"