Report

Help us improve this tool

Chmod Calculator

Calculate Unix file permissions in octal, symbolic, and text representations instantly with our free online chmod calculator.

O M T

Understanding Unix File Permissions

In Unix-like operating systems (such as Linux and macOS), file permissions are a fundamental security feature designed to control access to files and directories. The permission system manages access for three distinct categories of users:

  • Owner (User): The user who created or owns the file.
  • Group: A collection of users associated with the file, allowing shared access among team members.
  • Others: All other users on the system who are not the owner and do not belong to the file's group.

Octal vs. Symbolic Notation

Unix file permissions can be defined in two ways:

  • Numeric (Octal) Notation: Uses a three-digit or four-digit number. Each digit represents a sum of permission values:
    • Read (r): Value of 4
    • Write (w): Value of 2
    • Execute (x): Value of 1
    For example, a permission of 7 (4 + 2 + 1) grants read, write, and execute access.
  • Symbolic Notation: Uses a ten-character string (such as -rwxr-xr-x). The first character denotes the file type (e.g., - for regular file, d for directory), followed by three sets of three characters representing Owner, Group, and Others permissions.

Special Unix Permissions

In addition to the standard read, write, and execute permissions, Linux systems support special permission flags that alter execution behavior:

  • SetUID (Set User ID): When set on an executable file, the program runs with the privileges of the file's owner rather than the user running it.
  • SetGID (Set Group ID): Similar to SetUID, but runs with group privileges. For directories, new files created inside inherit the group of the parent directory.
  • Sticky Bit: Primarily used on directories (like /tmp) to prevent users from deleting or renaming files owned by others, even if they have write access to the directory.

Standard Permission Configurations

Here are common permissions configurations used in web servers and general system administration:

  • 755 (rwxr-xr-x): Standard for directories. The owner has full access, while group and others can read and list files.
  • 644 (rw-r--r--): Standard for files (like HTML and PHP documents). The owner can read and write, while group and others can only read.
  • 700 (rwx------): Private directory. Only the owner can access, read, write, and execute.
  • 600 (rw-------): Private files (like SSH keys). Only the owner can read and write.

If you are working on other developer configuration scripts, you may also find our Crontab Generator and UUID Generator tools helpful.

Frequently Asked Questions

What does chmod 755 mean?

Chmod 755 grants read, write, and execute permissions to the owner (7 = 4 + 2 + 1), and read and execute permissions to both the group and others (5 = 4 + 0 + 1). This is the standard permission setting for web directories.

How do I change file permissions in the Linux terminal?

You can change permissions using the chmod command. For example, to set permissions to 755 on a file named "script.sh", run the command chmod 755 script.sh. To apply permissions recursively to a directory and all its contents, use the -R flag: chmod -R 755 folder_name.

What is the difference between chmod 777 and chmod 755?

Chmod 777 grants full read, write, and execute permissions to everyone (owner, group, and others). This is highly insecure and should generally be avoided in production environments. Chmod 755 restricts write permissions to the owner only, which prevents unauthorized modifications by other users or web processes.

What do the letters S and T mean in symbolic file permissions?

The letter s (or S) represents the SetUID/SetGID flags in the user or group execute position. The letter t (or T) represents the Sticky Bit in the others execute position. Lowercase letters (s, t) mean that the executable bit is also set, while uppercase letters (S, T) mean the executable bit is not set.

What does the first character in the symbolic permission string represent?

The first character represents the file type. A hyphen (-) indicates a regular file, d indicates a directory, l indicates a symbolic link, c indicates a character device file, and b indicates a block device file.