What is 644 Permission in Linux: Explanation and Usage
644 is a file permission setting that means the owner can read and write the file, while the group and others can only read it. It is commonly used to allow safe sharing of files without letting others modify them.How It Works
Linux file permissions control who can read, write, or execute a file. The number 644 is a shorthand for these permissions using three digits. Each digit represents permissions for the owner, the group, and others, respectively.
Think of it like a house with three types of visitors: the owner, family members (group), and guests (others). The owner has the keys to enter and change things (read and write), while family members and guests can only look inside (read) but cannot change anything.
Each digit is a sum of numbers: 4 means read, 2 means write, and 1 means execute. So, 6 (4+2) means read and write, and 4 means read only. Therefore, 644 means owner can read/write, group can read, and others can read.
Example
This example shows how to set a file's permission to 644 and check the result.
touch example.txt
chmod 644 example.txt
ls -l example.txtWhen to Use
Use 644 permission when you want the file owner to edit the file but allow others to only read it. This is common for configuration files, web pages, or documents that should not be changed by others but need to be accessible.
For example, website files often use 644 so the server can read them and users can view them, but only the owner can modify the content.
Key Points
- 6 means read and write for the owner.
- 4 means read-only for group and others.
644is safe for files that should not be changed by others.- It does not allow anyone to execute the file.