Skip to content

chmod 444

chmod 444 sets r--r--r--: the owner, the group and everyone else can read the file, and no one can modify or execute it.

Permission matrix

Which permission bits each class has
WhoRead (4)Write (2)Execute (1)Digit
Owner (u)YesNoNo4
Group (g)YesNoNo4
Others (o)YesNoNo4

Execute means different things by type. On a file it lets the kernel run it as a program. On a directory it is search permission: entering it (cd) and reaching the files inside by name. Read on a directory only lists names.

What each class can do with a file and with a directory
WhoOn a fileOn a directory
Owner (u)Read the contentsList names only; cannot enter or open entries
Group (g)Read the contentsList names only; cannot enter or open entries
Others (o)Read the contentsList names only; cannot enter or open entries

Facts

Representations of this mode
Octal444 (0444)
Symbolicr--r--r--
ls -l, file-r--r--r--
ls -l, directorydr--r--r--
Equivalent symbolic commandchmod a=r
Default umask that creates itNone of the common umasks; set it explicitly with chmod
How Git records a file with it100644 (not executable)
Special bitsNone

When to use it

  • Content that must never change after it is written. Git stores its loose objects in .git/objects as -r--r--r--, since an object whose content changed would no longer match its hash.
  • Reference files you want to protect from your own accidental edits: most editors open them read-only or warn before writing.

When not to use it

  • As protection against deletion: rm only needs write permission on the directory. It asks "remove write-protected regular file?" and then deletes it if you confirm; rm -f does not even ask.
  • Files containing secrets: every account can read them. Use 400 or 440.

Commands

Set it on one file or directory
chmod 444 LICENSE
chmod a=r LICENSE   # same result
Check the result
stat -c '%a %A %n' LICENSE     # Linux (GNU stat): 444 -r--r--r--
stat -f '%Lp %Sp %N' LICENSE   # macOS and BSD

Applying it to a whole tree

chmod -R would put the same mode on files and directories alike. Set directories to 555 and files to 444 separately:

find . -type d -exec chmod 555 {} +
find . -type f -exec chmod 444 {} +

Or in one pass with a capital X, which adds execute only to directories and to files that already had it: chmod -R a=rX ..

Git and the execute bit

Git stores only one permission fact per file: 100755 if the owner execute bit is set, 100644 otherwise. A file with this mode is committed as 100644; the group and others bits never reach the repository. On Windows, or where core.fileMode is false, set the bit with git update-index --chmod=+x.

Frequently asked questions

What does chmod 444 mean?
Owner 4, group 4, others 4: read only, r--r--r--.
How do I edit a file with 444 permissions?
If you own it, run chmod u+w file (or chmod 644), edit, and optionally set it back. Otherwise you need the owner or root.
Does 444 make a file immutable?
No. The owner can change the mode, root ignores it, and anyone with write access to the directory can delete or replace the file. For real immutability on Linux use chattr +i as root.

Last reviewed by Arielton Oberek.