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

后端 未结 19 2045
情歌与酒
情歌与酒 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 14:03

    You want to make sure that appropriate files and directories are chmod-ed/permissions for those are appropriate. For all directories you want

    find /opt/lampp/htdocs -type d -exec chmod 711 {} \;
    

    And for all the images, JavaScript, CSS, HTML...well, you shouldn't execute them. So use

    chmod 644 img/* js/* html/*
    

    But for all the logic code (for instance PHP code), you should set permissions such that the user can't see that code:

    chmod 600 file
    

提交回复
热议问题