Australian Jeevitham TECHDeveloper tools

Tech / Chmod Calculator

Chmod Calculator

Tick who can read, write and run a file to get the octal number, the symbolic form and a chmod command ready to copy.

Permissions

WhoRead (4)Write (2)Execute (1)
Owner
Group
Others
Common settings

Value

What it means

How Linux file permissions work

Every file and folder on Linux and macOS has three sets of permissions: for the owner, the group and others. Each set adds up read (4), write (2) and execute (1), giving one digit from 0 to 7. So 755 means the owner can read, write and run (7), and everyone else can read and run (5) - written rwxr-xr-x.

ModeUsually used for
644Normal files, such as web pages and images
755Folders, and scripts or programs that need to run
600Private files, such as an SSH private key
700Private folders, such as ~/.ssh
777Almost never - see below

Why is 777 dangerous?

It lets every user on the system change or replace the file. On a web server, anyone who gets even a small foothold could then change your site's files. If something only works with 777, the owner or group is usually wrong - fix those with chown instead.

What do permissions mean for folders?

Read lets you list the files in a folder, write lets you add or delete files in it, and execute lets you open the folder and reach the files inside.

Careful with -R

chmod -R 755 also makes every file executable. To give folders 755 and files 644 instead, run find mydir -type d -exec chmod 755 {} + and then find mydir -type f -exec chmod 644 {} +.

The special bits

setuid runs a program as its owner, setgid runs it as its group (or, on a folder, gives new files the folder's group), and the sticky bit on a shared folder such as /tmp lets people delete only their own files.