chmod calculator A free GUI tool for chmod & Linux file permissions

What is chmod?

The chmod command is used to control who can access files and directories on Unix and Unix-like systems. It allows you to specify three types of permissions for each file or directory: read, write, and execute.

Tip Change access permissions, change mode.
  • read (r) → allows users to open and read the file's contents
  • write (w) → allows users to modify the file's contents
  • execute (x) → allows users to run the file as a program

These permissions can be applied to three different classes of users (or entities):

  • user (u) → the owner of the file / the user who created the file
  • group (g) → other users in the file's group
  • other (o) → other users not in the file's group
  • all (a) → user + group + all

Hands-On

To see how chmod works, execute the ls -l command on your linux system. The output you get should look similar to the example below:

$ ls -l total 4 drwxr-xr-x 1 user group     0 Jun 19 11:29 directory1 -rw-r--r-- 1 user group   273 Mar 24 11:28 file1 -rwxrwxrwx 1 user group  1449 Jan 29 14:01 file2 -rwx------ 1 user group  4119 Jan 26 13:22 file3

In our example, there are a total of 4 items in the directory. The first field of each line, which consists of 10 characters, indicates the file type and permissions.

Character Meaning
1 "d" if a directory, "-" if a file
2 "r" if file is readable to user, "-" if not
3 "w" if file is writable to user, "-" if not
4 "x" if file is executable to user, "-" if not
5-7 same as 2-4, with reference to group
8-10 same as 2-4, with reference to group
Tip The field components are color coded for better understanding

With reference to the table above, we can interpret that the first item is a directory named directory1. The next item file1 is readable and writable to the user and readable to everyone on the system. file2 is readable, writable and executable by everyone. file3 is readable, writable and executable only to the user.

There are two ways to change the permissions on a file, using the symbolic mode syntax or the numeric mode syntax.

Symbolic mode
Below is the simple form of the symbolic mode syntax:
chmod [references][operator][modes] filename
See here for full syntax reference
Component Description
references shorthand (u, g, o, a) for each entity
operator
  • add (+) → add specified permissions to the file(s)
  • remove (-) → remove specified permissions from the file(s)
  • set (=) → set specified permissions for the file(s), causing the permissions to be the only ones on the files
modes / permissions zero or more letters from rwxXstugo
  • r → read
  • w → write
  • x → execute (or search for directories)
  • X → if it is a directory, enter/search directory. If it is a file and already has the execute permission, retain it and do nothing otherwise
  • s → set user or group ID on execution, used for temporary elevated privileges
  • t → restricted deletion flag / sticky bit
  • u → permissions of the file owner
  • g → permissions of users in file group
  • o → permissions of users are in neither of the two preceding categories
The full syntax pattern is [ugoa]*([-+=]([rwxXst]*|[ugo]))+
Examples
Make file1 executable to user
chmod u+x file1
Use calculator
Make file2 not readable for others
chmod o-w file2
Use calculator
Make file3 readable and executable to everyone
chmod ugo=rx file3 chmod a=rx file3
Use calculator
Make file 3 readable and writable to everyone and turn on the set group-ID
chmod =rw,g+s file3
Use calculator
Numeric mode
Below is the simple form of the numeric mode syntax:
chmod [1-4 octal digits] filename
See here for full syntax reference

In numeric mode, permissions are specified in the form of one to four octal digits (0-7). Any omitted digits are assumed to be leading zeros.

Digit Description
1st selects the set user ID (4) and set group ID (2) and restricted deletion or sticky (1) attributes
2nd selects permissions for the owner: read (4), write (2), and execute (1)
3rd selects permissions for the group users: read (4), write (2), and execute (1)
4th selects permissions for other users NOT in the file's group: read (4), write (2), and execute (1)
Examples
The octal (0-7) value is calculated by adding up the values for each digit
user (rwx) = 4 + 2 + 1 = 7
group (rx) = 4 + 1 = 5
other (rx) = 4 + 1 = 5
mode = 0755
Make file1 readable to user, group, and others
chmod 444 file1
Use calculator
Make file2 read, write, executable to user, and readable only for group, and others
chmod 744 file2
Use calculator

Syntax Reference

chmod [Options]... Mode [,Mode]... file... chmod [Options]... Numeric_Mode file... chmod [Options]... --reference=RFile file...
Use calculator
Options
  • -R, --recursive change files and directories recursively
  • -f, --silent, --quiet suppress most error messages
  • -v, --verbose output a diagnostic for every file processed
  • -c, --changes like verbose but report only when a change is made
  • --no-preserve-root do not treat '/' specially (the default)
  • --preserve-root fail to operate recursively on '/'
  • --reference=RFILE use RFILE's mode instead of MODE values
  • --help display this help and exit
  • --version output version information and exit