DropVPS Team
Writer: Cooper Reagan
What is chmod 400 in Linux terminal?

Table of Contents
What you will read?
chmod 400 is a command in Linux that sets read-only permissions for the file owner and no permissions for group or others. This is commonly used for sensitive files like private keys.
Linux file permissions determine who can read, write, or execute a file. They are divided into three categories: Owner, Group, and Others:
| Permission | Numeric Value | Description | Example |
| Read (r) | 4 | View file contents or list directory | cat file.txt |
| Write (w) | 2 | Modify file or create/delete files | echo “text” > file.txt |
| Execute (x) | 1 | Run a file or enter directory | ./script.sh |
For example:
chmod 400 file.txt
Breakdown:
Owner = 4 (read only → r--)
Group = 0 (no permission → ---)
Others = 0 (no permission → ---)
This ensures only the owner can read the file, and nobody else has access.
Applying chmod 400
This command sets the file to read-only for the owner, removing all permissions for group and others:
touch secret.txt
chmod 400 secret.txt
Verify Permissions
Check the applied permissions to ensure they are correct. The owner should have read-only access, and no one else can read or modify the file:
ls -l secret.txt
-r-------- 1 user group size date secret.txt
Example Usage
For sensitive files like SSH private keys, this ensures security:
chmod 400 ~/.ssh/id_rsa
Only the file owner can read the key; all other access is blocked. chmod 400 protects sensitive files by granting read-only access to the owner and blocking all others, making it essential for security in Linux.