Systems

chmod Calculator

Calculate Unix permissions in octal, ls -l notation and check boxes, with setuid, setgid and Sticky bits and the exact chmod command for a file or a directory.

Set the permissions of a script, a shared directory or a private file: tick the permissions or type a mode, then copy the chmod command that matches the chosen type.

Input

chmod Calculator
Type
Owner (u)
Group (g)
Others (o)
Special bits

Runs with the owner’s rights (s).

Group rights or inheritance (s).

Only owners may delete entries (t).

1 to 4 digits from 0 to 7, for example 755 or 2775.

9 characters such as rwxr-xr-x, or 10 with the type such as drwxr-xr-x.

Common examples

Enable JavaScript to change the permissions. The result shown is mode 644 for a file.

Results

Mode 0644, -rw-r--r--.

Octal mode
0644
ls -l notation
-rw-r--r--
Octal chmod command
chmod 644 file
Symbolic chmod command
chmod u=rw,g=r,o=r,a-t file

Commands checked with GNU coreutils chmod (Linux) and macOS chmod. For a directory, the five-digit octal form and the added u-s and g-s explicitly clear setuid and setgid, which GNU would otherwise keep. ACLs and extended attributes are not taken into account.

What this mode allows

  • The owner: read the content and modify the content.
  • The group: read the content.
  • Others: read the content.

Understanding Unix permissions

Permissions and classes

Every file has three classes: owner (u), group (g) and others (o). Each gets read (r = 4), write (w = 2) and execute (x = 1); the octal digit of a class is their sum. 754 gives rwx to the owner, r-x to the group and r-- to others.

Special bits

A fourth digit, in front, adds setuid (4), setgid (2) and the Sticky bit (1). They are shown in place of execute: s or t when execute is granted, S or T otherwise.

Generated commands

The octal command sets the whole mode. The symbolic command assigns each class (u=, g=, o=) then sets the special bits explicitly. For a directory, the five-digit form (00755) and the added u-s and g-s clear setuid and setgid, which GNU/Linux chmod would otherwise keep; a+t and a-t set the Sticky bit the same way on Linux and macOS.

Precautions and limits

Do not grant write access to others without a reason: 777 or 666 let any user modify the content. Keep setuid and setgid for programs designed for them and check the result with ls -l. Commands checked with GNU coreutils chmod 9.1 and macOS chmod; ACLs, extended attributes and mount options such as nosuid may change the actual effect.

Frequently asked questions

What does chmod 755 mean?

7 for the owner (4 + 2 + 1: read, write, execute), 5 for the group and others (4 + 1: read and execute), that is rwxr-xr-x. A common mode for a script or a directory everyone can read.

What is the difference between chmod 644 and 755?

644 (rw-r--r--) grants execute to nobody: it suits data files. 755 adds execute for everyone: it suits programs, scripts and directories, which execute lets you enter.

How do I make a script executable?

Grant execute to the owner, for example 744 or 755. The generated commands set the whole mode; chmod u+x script only adds execute for the owner and leaves the rest unchanged.

What does chmod 777 mean and why avoid it?

Every permission for everyone: any user can modify or replace the file. Prefer 755 or 644, and 700 or 600 for private content; for a shared directory, 1777 adds the Sticky bit.

What are setuid, setgid and the Sticky bit for?

setuid and setgid run a program with the rights of its owner or group; on a directory, setgid makes new entries inherit its group. The Sticky bit lets only the owner of each entry delete it, as in /tmp.

Why do directory permissions behave differently?

On a directory, r lists the names, x lets you enter it and open its entries, w lets you create, rename or delete entries when combined with x. A directory in 644 therefore cannot be entered.

Back to tools home