Change all files and folders permissions of a directory to 644/755

后端 未结 8 976
孤街浪徒
孤街浪徒 2020-12-04 04:20

How would I change all files to 644 and all folders to 755 using chmod from the linux command prompt? (Terminal)

8条回答
  •  没有蜡笔的小新
    2020-12-04 04:53

    Do both in a single pass with:

    find -type f ... -o -type d ...
    

    As in, find type f OR type d, and do the first ... for files and the second ... for dirs. Specifically:

    find -type f -exec chmod --changes 644 {} + -o -type d -exec chmod --changes 755 {} +
    

    Leave off the --changes if you want it to work silently.

提交回复
热议问题