Chmod Calculator
Tick the boxes or paste a mode to get the octal mode, the symbolic mode and the chmod command.
| Read4 | Write2 | Execute1 | Digit | |
|---|---|---|---|---|
| Owner | 7 | |||
| Group | 5 | |||
| Others | 5 |
chmod 755 file
What it means
- Owner can read, write and execute.
- Group can read and execute.
- Others can read and execute.
Common chmod modes
| Mode | Symbolic | Use |
|---|---|---|
| 644 | rw-r--r-- | Regular files: the owner reads and writes, everyone else reads. The usual default for files. |
| 755 | rwxr-xr-x | Programs, scripts and directories: the owner has full access, everyone else reads and executes. |
| 600 | rw------- | Private files: SSH private keys, ~/.ssh/config, credentials. Only the owner reads and writes. |
| 700 | rwx------ | Private directories and scripts: ~/.ssh, a PostgreSQL data directory. Only the owner has access. |
| 400 | r-------- | Read-only for the owner: an SSH private key, a certificate you never edit. |
| 664 | rw-rw-r-- | Shared files: owner and group read and write, others read. |
| 775 | rwxrwxr-x | Shared directories: owner and group have full access, others read and enter. |
| 777 | rwxrwxrwx | WarningEveryone can read, write and execute. Avoid it: any user can change or replace the file. Use 755 or 644 and fix the owner instead. |
How chmod permissions work
Every file has three classes of user: the owner, the group and others (everyone else). Each class gets three rights: read is worth 4, write 2 and execute 1. A class's digit is the sum of its rights, so 7 is rwx, 6 is rw-, 5 is r-x and 4 is r--. The mode 755 is owner 7, group 5, others 5.
On a directory the rights mean something else: read lists the names in it, write creates, deletes and renames entries (and needs execute too), and execute lets you enter it and reach a file by name.
ls -l shows the mode as 10 characters: the file type (- for a file, d for a directory, l for a link), then the 9 permission characters, owner first. -rwxr-xr-x is a file with mode 755.
Setuid, setgid and the sticky bit
An optional first digit sets the special bits: 4 is setuid, 2 is setgid and 1 is sticky, summed like the others. ls -l shows them in the execute slots: s or S for setuid and setgid, t or T for sticky, lowercase when execute is also set.
4755: a setuid program runs with its owner's privileges./usr/bin/passwdis setuid root so it can write the password file.2775: a shared group directory; new files inherit the directory's group.1777:/tmp; anyone can create files, but only the file's owner, the directory's owner or root can delete or rename it.
Linux ignores setuid on directories and on scripts that start with a #! line.
Fix a permission denied error
If an error sent you here, these pages walk through the fix, including the mode to set:
SSH keys and ~/.ssh
SSH refuses keys and config that others can read: private keys 600 (or 400), ~/.ssh 700, public keys 644.
- Permissions 0644 for '/home/user/.ssh/id_rsa' are too open. It is required that your private key files are NOT accessible by others in Git
- Permissions 0644 for '/home/user/.ssh/id_rsa' are too open in SSH
- WARNING: UNPROTECTED PRIVATE KEY FILE! in SSH
- It is required that your private key files are NOT accessible by others in SSH
- This private key will be ignored in SSH
- Load key "/home/user/.ssh/id_rsa": bad permissions in SSH
- Bad owner or permissions on /home/user/.ssh/config in SSH
- Bad owner or permissions on ~/.ssh/config in Git
- Bad owner or permissions on /home/user/.ssh/known_hosts in SSH
- key_write failed in SSH
- Saving key failed: /home/user/.ssh/id_rsa in SSH
- Permission denied (publickey) in SSH
- Permission denied (publickey,password) in SSH
- Permission denied (publickey,keyboard-interactive) in SSH
- Permission denied, please try again in SSH
- git@github.com: Permission denied (publickey). fatal: Could not read from remote repository in Git
- Permission denied (publickey,gssapi-keyex,gssapi-with-mic) in SSH
- Permission denied (keyboard-interactive) in SSH
- Authentication failed in SSH
- Connection closed by authenticating user in SSH
- Failed publickey for user from hostname port XXXXX ssh2 in SSH
- Access denied in SSH
- fatal: bad ownership or modes for chroot directory in SSH
- scp: Permission denied in SSH
Scripts and programs that will not run
A file needs the execute bit to run: chmod +x, or 755.
- exec user process caused: permission denied in Docker
- OCI runtime create failed: container_linux.go: starting container process caused: exec: permission denied in Docker
- npm ERR! code EACCES npm ERR! cannot execute binary file in npm
- Error: spawn EACCES in Node.js
- Error: spawn EACCES in Node.js
- PermissionError: [Errno 13] Permission denied: 'script.sh' in Python
- ERR Module failed to load: Permission denied in Redis
When chmod itself is refused
Only the file's owner or root can change its mode, and some mounts do not allow it at all.
Files and directories a process cannot read or write
Check the mode and the owner with ls -l, then grant only what the process needs.
- PermissionError: [Errno 13] Permission denied: 'filename' in Python
- Error: EACCES: permission denied, open '/root/file.txt' in Node.js
- SystemError: access denied (operating system rejected operation) in Node.js
- Error reading file: permission denied in Terraform
- Error: Error creating local file: open: permission denied in Terraform
- npm ERR! Error: EACCES: permission denied, scandir '<path>' in npm
- fatal: cannot mkdir: Permission denied in Git
- error: insufficient permission for adding an object to repository database .git/objects in Git
- fatal: unable to access '/path/to/repo/.git/config': Permission denied in Git
- [ERROR] Can't connect to /run/gunicorn.sock: Permission denied in Python
- ERR CONFIG REWRITE failed: Permission denied in Redis
- E: Archives directory /var/cache/apt/archives/partial is missing. - Acquire (13: Permission denied) in APT
- E: Could not open lock file /var/lib/dpkg/lock-frontend - open (13: Permission denied) in APT
- E: Could not open file /var/lib/dpkg/status - open (13: Permission denied) in APT
- dpkg: error: cannot remove old file '/path': Permission denied in APT
- dpkg: error: unable to create new file 'path': Permission denied in APT
Databases and data directories
PostgreSQL wants its data directory at 700 (or 750); SQLite needs write access to the database file and its directory.
- FATAL: data directory has invalid permissions in PostgreSQL
- fixing permissions on existing directory in PostgreSQL
- Initdb: could not create directory: Permission denied in PostgreSQL
- EE_CONFIG_FILE_PERMISSION_ERROR (53): Config file permission issue in MySQL
- SQLITE_PERM: Access permission denied in SQLite
- SQLITE_READONLY: Attempt to write a readonly database in SQLite
- SQLITE_READONLY_DIRECTORY: Directory containing database is read-only in SQLite
- SQLITE_READONLY_CANTLOCK: Unable to obtain a read lock in SQLite
- SQLITE_READONLY_CANTINIT: Unable to initialize WAL file in SQLite
- SQLITE_READONLY_RECOVERY: WAL mode database cannot be modified in SQLite
- SQLITE_READONLY_ROLLBACK: Cannot roll back hot journal in readonly mode in SQLite
- SQLITE_CANTOPEN: Unable to open the database file in SQLite
- node-sqlite3: SQLITE_CANTOPEN: unable to open database file in SQLite
FAQ
- What does chmod 755 mean?
- The owner can read, write and execute (7 =
rwx); the group and everyone else can read and execute (5 =r-x). It is the usual mode for scripts, programs and directories. - What is the difference between 644 and 755?
- The execute bit. 644 (
rw-r--r--) suits files you only read, like config and HTML; 755 (rwxr-xr-x) suits programs, scripts and directories, which need execute to run or to be entered. - Is chmod 777 safe?
- No. Any user on the system can change or replace the file. If you hit a permission error, fix the owner or group with
chownorchgrpand use 755 or 644. - What do s, S, t and T mean in ls -l?
- They are the special bits, shown in the execute slots:
sfor setuid (owner) or setgid (group),tfor sticky (others). Lowercase means execute is also set; uppercase means it is not. - Why does chmod 755 not clear setgid on a directory?
- GNU chmod keeps a directory's setuid and setgid bits when you give a numeric mode. Clear them with
chmod g-s diror with five digits:chmod 00755 dir. - Is what I type sent anywhere?
- No. The calculator runs in your browser, so nothing you type is sent anywhere.