chmodでパーミッションの変更

sasaki 月曜, 2006-03-20 14:32

Webサーバ上のファイルのパーミッション(アクセス権)を一括で変更したい。ということがよくある。

 

■SGID(グループIDにs)をとる

$ ls -l
drwxr-sr-x   2 towns3   other        512 Oct 18 18:23 images
$ chmod g-s images

■SGID(グループIDにs)を一括でとりたい

drwxr-sr-xとなっているディレクトリを確認する。

find . -type d -perm -02000
find . -type d -perm -02000 -print | xargs -i ls -ld {}



drwxr-sr-x   2 apache   apache       512 Jan 27  2005 ./imeges
drwxr-sr-x   2 apache   apache      1024 Nov 13  2002 ./products

一括でsを外す。

find . -type d -perm -02000 -print | xargs -i chmod g-s {}