How to change permissions for a folder and its subfolders/files in one step?

后端 未结 19 2123
情歌与酒
情歌与酒 2020-11-22 13:20

I would like to change permissions of a folder and all its sub folders and files in one step (command) in Linux.

I have already tried the below command but it works

19条回答
  •  借酒劲吻你
    2020-11-22 13:56

    For already created files:

    find . \( -type f -exec chmod g=r,o=r {} \; \) , \( -type d -exec chmod g=rx,o=rx {} \; \)
    

    For future created files:

    sudo nano /etc/profile
    

    And set:

    umask 022
    

    Common modes are:

    • 077: u=rw,g=,o=
    • 007: u=rw,g=rw,o=
    • 022: u=rw,g=r,o=r
    • 002: u=rw,g=rw,o=r

提交回复
热议问题