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

后端 未结 8 960
孤街浪徒
孤街浪徒 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:49

    The easiest way is to do:

    chmod -R u+rwX,go+rX,go-w /path/to/dir
    

    which basically means:

    to change file modes -Recursively by giving:

    • user: read, write and eXecute permissions,
    • group and other users: read and eXecute permissions, but not -write permission.

    Please note that X will make a directory executable, but not a file, unless it's already searchable/executable.

    +X - make a directory or file searchable/executable by everyone if it is already searchable/executable by anyone.

    Please check man chmod for more details.

    See also: How to chmod all directories except files (recursively)? at SU

提交回复
热议问题