Chmod Calculator - Unix File & Folder Permissions Converter

Chmod Calculator is a user-friendly tool that helps you calculate and understand Unix file permissions. By providing an interactive interface, it eliminates the need for manual binary or octal arithmetic, allowing you to instantly generate the exact chmod terminal commands you need.

The Objective

To convert permissions between checkboxes, octal notations (like 755), and symbolic strings (like rwxr-xr-x), and to generate correct chmod commands for file systems.

The Tools You Have

  • Target Selection: Toggle between individual File permissions or Folder / Directory permissions.
  • Recursive Mode (-R): Enable the -R flag to apply permission changes recursively to all nested files and subdirectories.
  • File Permissions Grid: A checkbox matrix to set Read (r), Write (w), and Execute (x) permissions for the Owner, Group, and Others classes.
  • Special Flags: Toggles for setuid, setgid, and sticky bit flags.
  • Interactive Formats: Text fields showing the current Octal and Symbolic representations that you can edit directly.
  • Command Generator: Shows the ready-to-run chmod command for a custom file or folder target in either Octal or Symbolic mode, with a copy button.
  • Terminal Preview: Shows a live simulation of a terminal ls -l command (with leading d for directories and recursive sub-tree previews).

The Rules to Follow

What is chmod?

Chmod means ‘change mode’ and it changes file or directory mode bits (the way a file can be accessed). You can use chmod in the command line to change file or directory permissions on Unix or Unix-like systems such as Linux or BSD.

How to use chmod?

You can change file permissions in this format:

chmod [options] [mode] [file_name]

You can change permissions using alphanumeric characters (e.g. a+rwx) or with octal numbers (e.g. 777).

What are permissions?

Each file on a system has a set of permissions associated with it, meaning which users have access and what type of access they have.

There are three types of users:

  1. User (u): The user who owns the file.
  2. Group (g): The file’s defined ownership group.
  3. Other (o): Everyone else.

Each of these types of users can have three types of file access:

  1. Read (r): The ability to look at the contents of a file (value = 4).
  2. Write (w): The ability to change the contents of a file (value = 2).
  3. Execute (x): The ability to run the contents of a file (value = 1).

Simple Strategy

Use the following popular octal modes for standard scenarios:

  • 777 (rwxrwxrwx): Everyone has full read, write, and execute permissions. (Highly insecure!)
  • 755 (rwxr-xr-x): Owner has full permissions. Group and others can read and execute. (Standard for web directories).
  • 644 (rw-r--r--): Owner can read and write. Group and others can only read. (Standard for web files).
  • 600 (rw-------): Only the owner can read and write. (Standard for private SSH keys).
  • 400 (r--------): Owner can read only. Everyone else has no access.

Example of Play

  1. Enter your file’s name in the Filename input box.
  2. Select the checkboxes for the permissions you want to assign.
  3. Click the Copy button on the generated command line.
  4. Paste it into your Unix/Linux terminal shell.

Tips for Beginners

Chmod Options

You can extend chmod permissions with 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.
  • --reference=RFile: Use the reference file’s mode instead of MODE values.

Special Modes

  • setuid (4000): Allows users to run an executable with the permissions of the executable’s owner.
  • setgid (2000): In directories, causes new files and subdirectories created within it to inherit its group ID.
  • sticky bit (1000): Restricted deletion flag — only the owner or root can rename or delete files in that directory.

Have fun!