LoginSignup
3
10

More than 5 years have passed since last update.

findでまとめてパーミッション変更

Posted at

注意
投稿練習のため自身のweblogに投稿した内容(findでまとめてパーミッション変更 - hadacchi blog)を転載したものです.

課題

sambaでファイルサーバを運用している時に,別ユーザでのアクセスが問題になることがまれによくある.
なのでディレクトリは755に,ファイルは644にしたい.

find + chmod

# まとめてchmodに渡す.数が多いとコマンドの上限文字数を越える
$ find . -type d -exec chmod 755 {} +
# 1つずつchmodに渡す.数が多いとえらい時間がかかる
$ find . -type d -exec chmod 755 {} \;

find + xargs + chmod

# まとめてchmodに渡す.数が多いとコマンドの上限文字数を越える
$ find . -type d -print0 | xargs -0 chmod 755
# 20ずつまとめてchmodに渡す.上3つと比べるとマシ
$ find . -type d -print0 | xargs -0 -n 20 chmod 755

ちなみに,こちらの記事(ファイルやディレクトリのパーミッションを一括で置換したい - Qiita)のようにchmodだけでやる方法があるらしく,多分これが一番速い(試してないけど)

3
10
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
10