広告

暗号資産取引所の登録特典

登録するだけで受け取れる特典です。条件は各取引所の告知をそのまま載せています。

chmod

パーミッション

書き方

chmod 755 [path]

ファイルとディレクトリの権限ビットを決めます。chmod -R 755 は普通のファイルまで実行可能にしてしまうので、ファイルを触らせたくなければ大文字の X を使います。

よく使うオプション

オプション意味
0755Numeric: owner, group, others, each read 4 + write 2 + execute 1
u+wSymbolic: who (u g o a), then + - =, then r w x
+xAdd the execute bit, the usual fix for a script
-RApply to a whole tree
+XExecute for directories only, never for plain files
-vName each file whose mode changed
-hBSD and macOS: change the symlink itself, not its target

例

chmod +x deploy.sh

Makes the script runnable.

chmod -R u+rwX,go+rX,go-w site/

Capital X keeps files non-executable.

chmod 600 ~/.ssh/id_ed25519

What ssh insists on for a private key.

数字モードと記号モードは同じものを指します。755 と u=rwx,go=rx は同じ意味です。

読み方

  • 角括弧 [ ] は省いてよい部分です。
  • 三点 … は複数並べられるという意味です。
  • オプションは大文字小文字を区別します — -r と -R が別物のコマンドもあります。

よくある質問

Qchmod は何をしますか。

ファイルとディレクトリの権限ビットを決めます。chmod -R 755 は普通のファイルまで実行可能にしてしまうので、ファイルを触らせたくなければ大文字の X を使います。

Qどう打ちますか。

chmod 755 [path] — 角括弧は省いてよい部分です。

Qよく使うオプションはいくつですか。

ここにまとめたのは7個です。全部は man chmod にあります。このコマンドはパーミッションの仲間です。

関連するコマンド

man ページ: man chmod