File permissions

Tick the boxes, or type an octal or symbolic mode
WhoRead 4Write 2Execute 1Digit
Owner7
Group5
Others5
Special0
Common
3 or 4 digits

As shown by ls -l

Used in the commands

Commands

Both set exactly the same permissions
  • chmod 755 file
  • chmod u=rwx,g=rx,o=rx file

In binary

Each octal digit is 3 bits: read, write, execute
  1. 7111rwxOwner
  2. 5101r-xGroup
  3. 5101r-xOthers

What it means

  • Owner can read, write and execute.
  • Group can read and execute.
  • Others can read and execute.
Guide

How to calculate chmod permissions

  1. Tick Read, Write and Execute for the owner, the group and everyone else, or type a mode like 755 or rwxr-xr-x.
  2. Each digit is the sum of read (4), write (2) and execute (1) for one class of user: 7 = 4 + 2 + 1, and 5 = 4 + 1.
  3. Copy the command and run it in a terminal, for example chmod 755 script.sh.

Worked example

Working out chmod 755, one class of user at a time:

WhoPermissionsSumDigit
Ownerrwx4 + 2 + 17
Groupr-x4 + 0 + 15
Othersr-x4 + 0 + 15

rwxr-xr-x → chmod 755

  • 755 is the usual choice for scripts and folders, and 644 for ordinary files.
  • Avoid 777: it lets every user on the system change or replace the file.
  • Want the bits of any octal number? Use the octal to binary converter.
Learn

How Linux file permissions work

Owner, group and others, the numbers behind chmod, the special bits and umask.

Every file on Linux, macOS and other Unix systems has a permission mode like 755 or rw-r--r--, and a chmod calculator works out those numbers and letters for you. Tick the permissions above, or type a mode like 755 or rwxr-xr-x, and you'll get the matching octal value, symbolic form, binary bits and a ready-to-run chmod command. Here's how Unix permissions work, what the common chmod values mean, and how the special bits fit in.

How Linux file permissions work

Every file and folder has an owner and a group, and three sets of permissions: one for the owner, one for members of the group, and one for others, meaning everyone else. Each set has three switches: read (r), write (w) and execute (x). Run ls -l and you'll see them as a string like -rwxr-xr-x. The first character is the file type (- for a file, d for a directory), and the next nine are the owner, group and others permissions, three letters each, with a dash where a permission is off.

How chmod numbers work

The chmod command can set all nine permissions with a three-digit number, one digit per class. Read is worth 4, write is worth 2 and execute is worth 1, and each digit is the sum of the permissions that are on. Read, write and execute together are 4 + 2 + 1 = 7. Read and execute are 4 + 1 = 5. Read and write are 4 + 2 = 6. So chmod 755 gives the owner everything (7) and gives the group and others read and execute (5), which is rwxr-xr-x.

Permissions in binary

The numbers aren't arbitrary. Each chmod digit is an octal digit, and every octal digit is exactly three bits: one for read, one for write and one for execute. 7 is 111, 5 is 101 and 4 is 100, so 755 is the nine bits 111 101 101, a 1 wherever a permission is on. That's why permissions are written in octal rather than decimal. The In binary panel shows the bits for any mode, and the octal to binary converter explains the grouping.

Common chmod values

ModeSymbolicTypical use
755rwxr-xr-xScripts, programs and folders
644rw-r--r--Ordinary files such as web pages and documents
600rw-------Private files, like SSH keys
700rwx------Private folders and scripts, like ~/.ssh
775rwxrwxr-xShared folders a group can write to
664rw-rw-r--Shared files a group can edit
444r--r--r--Read-only for everyone
777rwxrwxrwxEveryone can do anything (avoid)

SSH is strict about this: it refuses to use a private key that other users can read, so keys need 600 and the ~/.ssh folder 700. chmod 777 is almost never the right fix for a permission error, because it lets any user or compromised process on the machine change the file.

Permissions on directories

The same three letters mean slightly different things for a folder. Read lets you list the names inside it, write lets you create, rename and delete files in it, and execute lets you enter it with cd and reach the files inside. A folder needs execute to be usable at all, which is why folders are usually 755 or 700 while plain files are 644 or 600.

Setuid, setgid and the sticky bit

A fourth, leading digit sets three special bits, worth 4, 2 and 1 just like the others:

ModeBitSymbolicUsed for
4755Setuid (4)rwsr-xr-xPrograms that need their owner's rights, like passwd
2775Setgid (2)rwxrwsr-xShared folders where new files keep the folder's group
1777Sticky (1)rwxrwxrwtShared folders like /tmp, where users can't delete each other's files

In the symbolic form, the special bits replace the execute letter: s for setuid and setgid, t for sticky. A capital S or T means the special bit is set but execute isn't, which is usually a mistake.

Symbolic chmod and umask

chmod also accepts letters, which change permissions without retyping the rest: chmod u+x script.sh adds execute for the owner, chmod go-w file removes write for the group and others, and chmod u=rwx,g=rx,o=rx file sets the same thing as 755. The calculator shows that form under Commands. New files get their starting permissions from the umask, which removes bits from a default of 666 for files and 777 for folders. The common umask 022 removes write for group and others, so new files are 644 and new folders 755.

Working safely with chmod

  • Paste the permissions straight from ls -l, including the leading - or d.
  • Add -R to apply a mode to a folder and everything in it, but be careful: files and folders usually need different modes.
  • To read the current mode as a number, run stat -c %a file on Linux.

When in doubt, start from 644 for files and 755 for folders and scripts, then tighten from there. It's rarely right to reach for 777.

FAQ

Frequently asked questions

Quick answers about the chmod calculator and how it works.

What does chmod 755 mean?

The owner can read, write and execute (7 = 4 + 2 + 1), and the group and everyone else can read and execute (5 = 4 + 1). In symbolic form it's rwxr-xr-x. It's the standard mode for scripts, programs and folders.

What does chmod 644 mean?

The owner can read and write (6 = 4 + 2), and everyone else can only read (4). That's rw-r--r--, the usual mode for ordinary files such as web pages, images and documents.

Is chmod 777 safe?

Rarely. 777 (rwxrwxrwx) lets every user and every process on the system read, change and run the file, so a single compromised account can replace it. Fix permission errors by changing the owner with chown, or use 755 or 775 instead.

How do I calculate chmod numbers?

Add up read (4), write (2) and execute (1) for each of the owner, group and others, and write the three sums in that order. Read and write for the owner (6), read for the group (4) and nothing for others (0) gives 640. The checkboxes above do the arithmetic for you.

What are setuid, setgid and the sticky bit?

They're three special bits set by a fourth, leading digit: setuid (4) runs a program with its owner's rights, setgid (2) runs it with its group's rights and makes new files in a folder inherit the folder's group, and sticky (1) stops users deleting each other's files in a shared folder. /tmp is 1777, shown as rwxrwxrwt.

What do capital S and T mean in permissions?

A lowercase s or t means the special bit and execute are both set. A capital S or T means the special bit is set but execute isn't, as in rwSr--r-- (4644). That combination has no useful effect, so it's usually a mistake.

Still have a question?Contact us