chmod 440: Read Only for Owner and Group, the sudoers Mode
440 is r--r-----: the owner and the owning group can read, nobody can write, and every other account is refused. It is the mode sudo requires on /etc/sudoers and on every file under /etc/sudoers.d.
At a glance
- Octal
- 440, written 0440 in four digit form
- Symbolic
- u=r,g=r,o=
- On a file
- -r--r-----
- On a directory
- dr--r-----, listable by owner and group but not enterable
- Owner
- Read only. Even the owner must relax the mode to edit in place
- Group
- Read only
- Others
- Nothing. Cannot read the contents
In detail
440 is the mode for a policy file: something that decides what is allowed, that several parties may need to read, and that nothing should be able to modify by accident. Removing write from the owner as well as everyone else means an edit has to be a deliberate two step act, which is exactly the behaviour you want around a file that grants privilege.
sudo enforces it. The sudoers file ships as 0440 owned by root, and sudo refuses to run at all if the file is writable by anyone other than the owner, reporting that the mode is wrong and exiting rather than falling back to a permissive default. Files dropped into /etc/sudoers.d are checked the same way and are silently ignored if their mode is loose.
This is why visudo exists. It edits a copy, validates the syntax, and puts the file back with the correct owner and mode, so that a typo or a stray chmod cannot leave you with a machine where sudo will not run and there is no way to fix it without a rescue boot. Editing sudoers directly is the classic way to lock yourself out.
Outside sudo, 440 suits any file a service group must read and nothing should write: a signed policy document, a licence key file, a certificate authority bundle that a deployment installs and applications only consume. Pair it with a 750 directory so that accounts outside the group cannot even see that the file exists.
The difference from 640 is the owner's write bit. 640 expects the owner to update the file as part of normal operation; 440 says updates are exceptional and should require an explicit mode change first. Choose based on how often the file legitimately changes, not on how sensitive it feels.
Examples
chmod 440 /etc/sudoers.d/deploy
chmod u=r,g=r,o= /etc/sudoers.d/deploy-r--r----- 1 root root /etc/sudoers
dr-xr-x--- 2 root root /etc/sudoers.d/
-r--r----- 1 root root /etc/sudoers.d/deploy
If the mode is loosened, sudo reports that sudoers is
writable and refuses to run rather than applying the file.# validates syntax and restores owner and mode
visudo
visudo -f /etc/sudoers.d/deploy
# never do this on a machine you cannot rescue
$EDITOR /etc/sudoersThings that catch people out
- A syntax error in sudoers can lock every account out of privilege escalation at once. Always edit through visudo, which refuses to install a file that does not parse.
- Files in /etc/sudoers.d with the wrong mode are ignored rather than rejected loudly, so a rule that simply does not apply is often a permissions problem and not a syntax one.
- 440 removes write from the owner too. Automation that rewrites the file in place will fail until the mode is relaxed, which is deliberate but needs to be handled in the script.
- 440 with the wrong group is just 400 with extra characters. Set the group explicitly, or the accounts you meant to grant read access to still get nothing.
Try it: Chmod Calculator
Tick the nine permission boxes, or type an octal or symbolic value, and get the three digit and four digit octal, the ls -l rendering and the exact chmod command back.
Chmod Calculator
LOCAL · Browser-OnlyCalculate Unix file permissions with an interactive chmod builder
Permission Matrix
| Entity | Read (4) | Write (2) | Execute (1) | Octal | Symbolic |
|---|---|---|---|---|---|
| Owner (u) | 7 | rwx | |||
| Group (g) | 5 | r-x | |||
| Others (o) | 5 | r-x |
Special Bits
Advanced permission flags for executables and directories
Generated Permissions
755rwxr-xr-x-rwxr-xr-xchmod 755 filenamechmod u=rwx,g=rx,o=rx filenamePermission Breakdown
Owner (u)
7rwx- - Read files / list directory contents
- - Write / modify / delete
- - Execute / traverse directory
Group (g)
5r-x- - Read files / list directory contents
- - Execute / traverse directory
Others (o)
5r-x- - Read files / list directory contents
- - Execute / traverse directory
Common Permissions Reference
| Octal | Symbolic | Meaning |
|---|---|---|
777 | rwxrwxrwx | Full access for everyone |
755 | rwxr-xr-x | Owner full, others read and execute |
750 | rwxr-x--- | Owner full, group read and execute |
700 | rwx------ | Owner full access only |
666 | rw-rw-rw- | Read and write for everyone |
644 | rw-r--r-- | Owner read/write, others read only |
600 | rw------- | Owner read/write only |
555 | r-xr-xr-x | Read and execute for everyone |
444 | r--r--r-- | Read only for everyone |
400 | r-------- | Owner read only |
Related File permissions
All file permissions →chmod 400: Read Only Keys and Downloaded PEM Files
400 gives the owner read and nothing to anyone else, not even write. The usual mode for a downloaded cloud key pair and how it differs from 600.
chmod 444: Read Only for Everyone, With Real Limits
444 gives read to all three classes and write to none, not even the owner. Why a 444 file can still be deleted and what actually makes a file immutable.
chmod 640: Configuration Files a Service Group Can Read
640 gives the owner read and write, the group read only, and everyone else nothing. The correct mode for configuration holding credentials.
chmod 550: Programs a Service Can Run but Cannot Change
550 gives the owner and group read and execute and everyone else nothing. The mode for a privileged script that a service must run but must not modify.
chmod 070: Group Only Access and the First Match Rule
070 grants the group everything and the owner nothing. The owner really is denied, because the kernel checks one class only, and this mode proves it.
chmod 007: Everyone Else Gets Everything, the Owner Gets Nothing
007 gives every other account full access while locking out the owner and the group. Almost always a typo for 700, and a lesson in how chmod is authorised.
Tools for this
- Chmod Calculator Free online chmod calculator - calculate Unix file permissions with an interactive chmod builder