DevToolBox

chmod Calculator

Linuxファイルパーミッションを視覚的に計算。数値(755)とシンボリック(rwxr-xr-x)の相互変換。

読取 (4)書込 (2)実行 (1)Value
所有者7
グループ5
その他5
rwxr-xr-x
chmod 755

How to Use the chmod Calculator

This free chmod calculator helps you determine the correct Linux file permissions. Use the checkbox grid to set read, write, and execute permissions for owner, group, and other users. The numeric (octal) value and symbolic representation update automatically. You can also type a numeric value directly to see the corresponding permissions.

Understanding File Permissions

  • Read (4) - View file contents or list directory contents
  • Write (2) - Modify file contents or create/delete files in directory
  • Execute (1) - Run file as program or access directory
  • Owner - The user who owns the file
  • Group - Users in the file's group
  • Other - All other users

Common Permission Settings

644 (rw-r--r--) is the standard for regular files - owner can read/write, everyone else can only read. 755 (rwxr-xr-x) is standard for executables and directories - owner has full access, others can read and execute. 700(rwx------) gives only the owner access. 777 (rwxrwxrwx) gives everyone full access and should be avoided for security reasons.

How Octal Notation Works

Each digit represents permissions for one group (owner, group, other). The digit is the sum of: read (4) + write (2) + execute (1). For example, 7 means rwx (4+2+1), 5 means r-x (4+1), 6 means rw- (4+2), and 0 means no permissions. So chmod 755 sets rwxr-xr-x.

chmodパーミッション計算ツールについて

Linuxファイルパーミッションをチェックボックスで視覚的に設定できるツールです。数値(755等)とシンボリック(rwxr-xr-x)形式を相互変換し、chmodコマンドをワンクリックでコピーできます。よく使うプリセットも用意しています。

chmod Calculatorの使い方

チェックボックスで「所有者・グループ・その他」ごとに読取/書込/実行を選ぶと、数値表記(755)とシンボリック表記(rwxr-xr-x)が同時に更新されます。 逆に数値欄に「640」のように直接入力すれば、どのビットが立っているかをチェックボックスで視覚的に確認できます。 値が決まったら「コピー」ボタンで chmod 755 形式のコマンドをそのまま端末に貼り付けられます。

1. Web公開ディレクトリの権限設計

Apache/Nginx の DocumentRoot 配下は「ファイル644・ディレクトリ755」が基本形です。 PHP の設定ファイル(wp-config.php 等)のように DB パスワードを含むものは 640 や 600 まで絞り、 Web サーバーの実行ユーザー(www-data 等)が読めるかを所有者/グループで調整します。 「動かないから 777」は改ざんの入口になるため、まず所有者(chown)を疑うのが定石です。

2. SSH鍵の "permissions are too open" エラー対応

ssh は秘密鍵が他ユーザーから読める状態だと接続を拒否します。~/.ssh は 700、秘密鍵(id_rsa, id_ed25519)とauthorized_keys は 600 が安全な組み合わせです。 本ツールで 600 を選ぶと「所有者の読取+書込のみ」であることが一目で確認できます。

3. チーム共有ディレクトリの設計

同じグループのメンバーで読み書きする共有ディレクトリは 770(または 775)が起点です。 さらにディレクトリに setgid(chmod g+s dir)を立てると、配下に新規作成されるファイルが 親ディレクトリのグループを引き継ぐため、「作った人のプライマリグループになって他人が読めない」事故を防げます。

よくある落とし穴 / Common Pitfalls

chmod 自体はエラーをほとんど出しませんが、「間違った値が黙って適用される」ことが最大の危険です。実務で頻発する失敗パターンをまとめました。

chmod rarely fails loudly — the real danger is a wrong value being applied silently. These are the failure patterns we see most often in practice.

落とし穴 / Pitfall何が起きるか / What happens対処 / Fix
「動かないからとりあえず chmod 777
"Just chmod 777 to make it work"
全ユーザーが書込・実行可能になり、改ざんやWebシェル設置の入口になる
Every user can write and execute — an open door for tampering and web shells
644/755 を起点に最小権限。所有者の問題なら chown で解決する
Start from 644/755; if ownership is the real issue, fix it with chown
設定ファイルを 644/755 のまま放置
Leaving config files at 644/755
DBパスワード等が同一サーバーの他ユーザーから読める
DB passwords become readable by other users on the same host
機密を含むファイルは 600(グループ共有なら 640)に絞る
Tighten secrets to 600 (or 640 for group access)
ディレクトリの x を外す
Removing x from a directory
ディレクトリの x は「通過」権限。r だけでは一覧は見えても中のファイルにアクセスできない
On directories, x means traverse — with r alone you can list names but cannot access the files
ディレクトリは r と x をセットで付与(755/750/700)
Grant r and x together on directories (755/750/700)
chmod -R 755 をディレクトリ全体に適用
Running chmod -R 755 on a whole tree
すべてのファイルに実行ビットが付き、データファイルまで「実行可能」になる
Every file gains the execute bit — even plain data files become "executable"
find -type f / -type d で分けるか、chmod -R u+rwX の大文字 X を使う
Split with find -type f/-type d, or use the capital X in chmod -R u+rwX
setuid/setgid/sticky を意識せず数値3桁で上書き
Overwriting with 3 digits, unaware of setuid/setgid/sticky
2755(setgid)等の特殊ビットの扱いが実装依存で変わり、共有ディレクトリのグループ継承が壊れることがある
Special bits like setgid in 2755 are handled implementation-dependently and group inheritance can break
部分変更はシンボリックモード(g+s, o+t)で。4桁指定(2775等)も可
Use symbolic mode (g+s, o+t) for partial changes, or 4-digit values like 2775
chmod -R のパス間違い(余分なスペース等)
Wrong path in chmod -R (stray space, etc.)
chmod -R 755 / var/www のように / 全体へ適用され、sudo や ssh が壊れる
chmod -R 755 / var/www hits the entire / and breaks sudo and ssh
実行前にパスを確認。find ... -ls で対象を先に表示してから適用する
Double-check the path; list targets first with find ... -ls before applying
SSH秘密鍵が 644
Private SSH key left at 644
UNPROTECTED PRIVATE KEY FILE! 警告とともに ssh が鍵を無視し、接続に失敗する
ssh refuses the key with an UNPROTECTED PRIVATE KEY FILE! warning
秘密鍵は 600、~/.ssh ディレクトリは 700 にする
Set the key to 600 and the ~/.ssh directory to 700
chmod と umask の混同
Confusing chmod with umask
chmod で直しても、新規作成されるファイルはまた緩い/きつい権限になる
You fix existing files, but newly created ones come back with the wrong mode
新規作成時のデフォルトは umask(例: 022 → 644/755)で制御する
Control defaults for new files via umask (e.g. 022 → 644/755)

言語別コード例 / Code Examples by Language

計算した権限値を実際に適用するための最小サンプルです。

Minimal snippets to apply the permission value you calculated.

Shell (chmod)

# 数値モード / Numeric mode
chmod 644 config.yaml
chmod 755 deploy.sh

# シンボリックモード: 既存ビットを保ったまま部分変更
# Symbolic mode: change bits without overwriting the rest
chmod u+x deploy.sh     # 所有者に実行権を追加 / add execute for owner
chmod go-w shared.txt   # グループ・その他の書込を剥奪 / remove write
chmod g+s /srv/shared   # setgid: グループ継承 / inherit group

Shell (find で一括適用 / bulk apply with find)

# ファイルは644・ディレクトリは755に分けて適用
# Apply 644 to files and 755 to directories separately
find /var/www/html -type f -exec chmod 644 {} +
find /var/www/html -type d -exec chmod 755 {} +

# 事前確認: 644でないファイルを表示するだけ(dry-run)
# Dry-run: just list files that are not 644
find /var/www/html -type f ! -perm 644 -ls

Python

import os, stat

os.chmod("config.yaml", 0o644)   # 8進数リテラル / octal literal
os.chmod("deploy.sh", 0o755)

# statフラグで600を指定 / 600 via stat flags
os.chmod("id_ed25519", stat.S_IRUSR | stat.S_IWUSR)

# 現在の権限を8進数で確認 / inspect current mode in octal
print(oct(os.stat("deploy.sh").st_mode & 0o777))  # 0o755

Go

import (
    "fmt"
    "os"
)

_ = os.Chmod("config.yaml", 0o644)
_ = os.Chmod("deploy.sh", 0o755)

info, _ := os.Stat("deploy.sh")
fmt.Printf("%o\n", info.Mode().Perm()) // 755

Node.js

import { chmodSync, statSync } from "node:fs";

chmodSync("config.yaml", 0o644);
chmodSync("deploy.sh", 0o755);

// 現在の権限を確認 / inspect current mode
console.log((statSync("deploy.sh").mode & 0o777).toString(8)); // "755"

Before / After 実例 / Before & After

例1: スクリプトが Permission denied / Script fails with Permission denied

$ ls -l deploy.sh
-rw-r--r-- 1 deploy deploy 512 Jun 11 10:00 deploy.sh
$ ./deploy.sh
bash: ./deploy.sh: Permission denied

chmod 755 deploy.sh

$ ls -l deploy.sh
-rwxr-xr-x 1 deploy deploy 512 Jun 11 10:00 deploy.sh
$ ./deploy.sh   # 実行できる / now runs

例2: SSH秘密鍵が拒否される / SSH key rejected as too open

$ ssh -i id_ed25519 deploy@server
Permissions 0644 for 'id_ed25519' are too open.
This private key will be ignored.

chmod 600 id_ed25519

$ ls -l id_ed25519
-rw------- 1 koba koba 411 Jun 11 10:00 id_ed25519
$ ssh -i id_ed25519 deploy@server   # 接続成功 / connects

例3: 777になっていた公開ディレクトリの是正 / Fixing a world-writable web root

$ ls -ld /var/www/html
drwxrwxrwx 5 www-data www-data 4096 Jun 11 10:00 /var/www/html

find でファイル644・ディレクトリ755に一括適用 / bulk apply with find

$ ls -ld /var/www/html
drwxr-xr-x 5 www-data www-data 4096 Jun 11 10:00 /var/www/html

777 のディレクトリは誰でもファイルを設置できるため、Webシェルを置かれる典型的な侵入経路になります。

A 777 directory lets anyone drop files into it — a classic entry point for web shells.

Why browser-only? / なぜブラウザ完結か

Permission bits themselves are not secrets — but the context around them usually is. When you reach for a chmod calculator, you are often in the middle of debugging a real server: the paths you are thinking about (/home/deploy/.ssh/id_ed25519, wp-config.php) reveal usernames, deployment layout, and which files hold credentials. A server-hosted calculator could log every value you try, building a small map of your infrastructure's weak spots. This tool avoids that entirely: the octal/symbolic conversion is a few lines of JavaScript running in your browser, no input ever leaves the page, and there is no analytics attached to the fields. It also keeps working offline, which matters when you are on a restricted operations network and just need to confirm whether 750 includes group write. You can verify the claim yourself — open DevTools, switch to the Network tab, toggle the checkboxes, and watch no request fire.

パーミッション値そのものは機密ではありませんが、chmod を調べている状況は「実サーバーの障害対応中」であることが多く、 頭の中にあるパスやファイル名はユーザー名・デプロイ構成・認証情報の場所を示すヒントになります。 本ツールの変換処理はすべてブラウザ内の JavaScript で完結し、入力値が外部に送信されることはありません。 オフラインでも動作するため、隔離されたネットワークでの作業中にも使えます。DevTools の Network タブで通信が発生しないことを確認できます。

開発をもっと効率的に

PR