DevToolsmith

Chmod 644

chmod 644 sets the permissions to rw-r--r--: it lets the owner read and write, and everyone else only read. Here is exactly what that allows on files and directories, when to use it, and the commands to apply it.

Runs 100% in your browser — nothing is uploaded

ClassreadwriteexecuteValue
owner6
group4
others4
Common:
$ chmod 644 file.sh
$ chmod u=rw,g=r,o=r file.sh
  • • The owner can read and write.
  • • The group can read.
  • • Everyone else can read.

What chmod 644 means

WhoDigitLettersOn a fileOn a directory
owner 6 rw- Can read and modify Can list files (write has no effect without execute)
group 4 r-- Can read Can list files
others 4 r-- Can read Can list files

Each digit is the sum of read (4), write (2) and execute (1). In ls -l output it looks like this:

$ ls -l
-rw-r--r--  1 alice  staff  1834 Oct 21 10:30 example.txt
  • The owner can read and write.
  • The group can read.
  • Everyone else can read.

When to use 644

  • Regular files
  • Web pages, images, CSS and JS
  • Most config files

644 is the default for new files on most systems: a umask of 022 turns 666 into 644. It is the right mode for website files. The web server can read them, but a compromised PHP script running as another user can’t change them. Config files with passwords should be 600 or 640 instead.

644 is also the default mode for new files, with umask 022.

Is chmod 644 safe?

Yes, for regular files. Other users can read it, but can’t change it. Don’t use it for files that contain secrets.

Commands

# One file
chmod 644 file

# Same thing in symbolic form
chmod u=rw,g=r,o=r file

# Every file under a tree (leaves directories alone)
find /path/to/dir -type f -exec chmod 644 {} +

# Check the result
stat -c '%a %A %n' file    # Linux
stat -f '%Lp %Sp %N' file  # macOS

Avoid chmod -R 644 on a whole tree: it gives files and directories the same mode. The find form above changes only files.

Compare with similar modes

ModeSymbolicDifference
744 rwxr--r-- Gives the owner full access and everyone else read-only access
664 rw-rw-r-- Lets the owner and group read and write, and others only read
640 rw-r----- Lets the owner read and write, the group read, and others nothing
444 r--r--r-- Lets everyone read, but nobody write or execute

Other chmod values

777 · 775 · 770 · 755 · 751 · 750 · 744 · 711 · 700 · 666 · 664 · 660 · 640 · 600 · 555 · 500 · 444 · 400 · 000 · 1777 · 2775 · 4755

Need a different combination? Use the Chmod Calculator.

Sources

Spotted a mistake? Email hello@devtoolsmith.com and we’ll fix it.

Frequently asked questions

What does chmod 644 mean?

chmod 644 sets the permissions to rw-r--r--. The owner can read and write. The group can read. Everyone else can read.

Is chmod 644 safe?

Yes, for regular files. Other users can read it, but can’t change it. Don’t use it for files that contain secrets.