How I understand chmod without guessing the numbers
· 4 min read
chmod 755 is one of those commands many people copy before they fully understand
it. It works often enough that it becomes a habit, but file permissions are worth
understanding properly.
The chmod Calculator helps translate between the numbers and the readable permission bits. I use it when I want to check the result instead of guessing.
The simple idea
Linux file permissions answer three questions:
- What can the owner do?
- What can the group do?
- What can everyone else do?
Those three groups are usually shown as:
user group others
or shorter:
u g o
Each group can have three permissions:
| Letter | Meaning |
|---|---|
r | read |
w | write |
x | execute |
Reading permission text
When you run:
ls -l
you may see:
-rwxr-xr-x 1 ubuntu ubuntu 1234 app.sh
Focus on this part:
-rwxr-xr-x
The first character tells the type:
-means regular file;dmeans directory.
The next nine characters are permissions:
rwx r-x r-x
│ │ │
│ │ └─ others
│ └───── group
└───────── owner/user
So rwxr-xr-x means:
- owner can read, write, and execute;
- group can read and execute;
- others can read and execute.
What read, write, and execute mean for files
For files:
rmeans you can read the file;wmeans you can modify the file;xmeans you can run it as a program or script.
A shell script usually needs execute permission if you want to run it like this:
./script.sh
Without execute permission, you may see:
Permission denied
What read, write, and execute mean for directories
Directories are a little different.
For directories:
rmeans you can list names inside the directory;wmeans you can create, delete, or rename entries inside it;xmeans you can enter or traverse the directory.
The x permission on directories is important. Without it, you may not be able to
access files inside even if you know their names.
Understanding chmod numbers
The number form uses these values:
read = 4
write = 2
execute = 1
Add them together for each group.
Examples:
rwx = 4 + 2 + 1 = 7
rw- = 4 + 2 = 6
r-x = 4 + 1 = 5
r-- = 4 = 4
--- = 0
So this:
755
means:
7 = owner: rwx
5 = group: r-x
5 = others: r-x
Readable form:
rwxr-xr-x
Common permission values
These are common, but do not copy them blindly:
| Mode | Meaning | Common use |
|---|---|---|
644 | owner can write, everyone can read | normal public files |
600 | only owner can read/write | private config or keys |
755 | owner can write, everyone can read/execute | scripts and directories |
700 | only owner can access | private directories/scripts |
For private keys, 600 is common:
chmod 600 ~/.ssh/id_ed25519
For a script:
chmod 755 deploy.sh
or more narrowly:
chmod u+x deploy.sh
Symbolic chmod is often easier
You do not always need numbers.
Add execute permission for the owner:
chmod u+x script.sh
Remove write permission from others:
chmod o-w file.txt
Set exact permissions for everyone:
chmod u=rw,g=r,o= file.txt
Plain meaning:
- owner can read/write;
- group can read;
- others get no permission.
Symbolic mode is useful because it says what you are changing instead of forcing you to calculate the full number.
Step 1: inspect before changing
Before running chmod, check the current permission:
ls -l file.txt
Do not change permissions blindly. First see what they are.
Step 2: decide who needs access
Ask:
- Should only the owner access this?
- Should the group access it?
- Should everyone else access it?
- Is execute permission really needed?
For example, a config file usually does not need execute permission.
Step 3: use the chmod Calculator
Open chmod Calculator and choose the permissions you want.
The tool shows the numeric and symbolic forms. This is useful when you know the human rule but do not want to calculate the number manually.
Example decision:
owner: read/write
group: read
others: no access
Result:
640
Command:
chmod 640 file.txt
Step 4: apply and verify
Run the command:
chmod 640 file.txt
Then check again:
ls -l file.txt
Make sure the result matches what you intended.
Be careful with recursive chmod
This command changes permissions recursively:
chmod -R 755 directory
Be careful. It applies to everything inside the directory.
A common mistake is making every file executable. Directories often need execute permission, but normal files usually do not.
For complex permission fixes, use find to target files and directories separately:
find directory -type d -exec chmod 755 {} +
find directory -type f -exec chmod 644 {} +
That gives directories and files different permissions.
My chmod checklist
Before changing permissions, I check:
- What are the current permissions?
- Who owns the file?
- Does the owner need read, write, execute?
- Does the group need access?
- Should others have any access?
- Is this a file or directory?
- Am I using recursive mode accidentally?
- Did I verify with
ls -lafter changing it?
The goal is not to memorise every number. The goal is to understand who can do what. The calculator turns that decision into the correct mode.
Comments
Comments are welcome — please read the comment policy first. Powered by giscus and GitHub Discussions.