
How to Change File Permissions in Linux (chmod 777, 755, 644)
Few things in Linux cause as much head-scratching as file permissions. The chmod command—short for “change mode” and part of the POSIX standard since the 1970s (IEEE/Open Group POSIX specification (authoritative standards body))—is the tool you use to control who can read, write, or execute a file.
Linux file permission modes: 3 sets of 3 bits (owner, group, others) ·
Common permission values: 777 (rwxrwxrwx), 755 (rwxr-xr-x), 644 (rw-r–r–), 600 (rw——-) ·
chmod command origin: change mode, part of POSIX standard since 1970s ·
Number of permission bits: 12 (9 standard + 3 special)
Quick snapshot
chmodis the standard command for changing file permissions (Red Hat)- Numeric mode uses octal digits for owner, group, others (Boston University TechWeb)
- Only file owner or root can change permissions (POSIX specification)
chmodhas been part of POSIX since the IEEE 1003.1-1988 standard (man7.org)
- After changing permissions, verify with
ls -lto confirm changes - Adjust permissions for security: avoid 777 on production servers
Five essential permissions facts that will ground every chmod decision:
| Label | Value |
|---|---|
| Command to change permissions | chmod [options] mode file |
| Most common numeric modes | 777, 755, 644, 600, 444 |
| Symbolic mode example | chmod u+rwx,g+rx,o+rx file |
| Recursive flag | -R (e.g., chmod -R 755 directory) |
| Who can change permissions | File owner or superuser (root) |
How to change file permissions to 777 in Linux?
Using numeric mode with chmod
- Numeric mode uses a three-digit octal number: the first digit for the owner, the second for the group, the third for others (Red Hat (Linux enterprise vendor)).
- Each digit is the sum of read (4), write (2), and execute (1).
- Example: 7 = 4+2+1 = rwx; 5 = 4+0+1 = r-x; 6 = 4+2+0 = rw-.
To change a file to 777, you grant read, write, and execute to everyone. This is the most permissive setting and should be used sparingly.
Setting 777 on a file
- Run
chmod 777 filenameto give all three classes full access (freeCodeCamp (developer education platform)). - Verify with
ls -l filename— the permissions will show as-rwxrwxrwx.
Setting 777 on a directory recursively
- Use
chmod -R 777 directoryto apply the same permission to the directory and all its contents (DigitalOcean (cloud hosting tutorials)). - Be cautious: changing permissions recursively can expose files you did not intend to make public.
777 means anyone who can log into the system — or any process running under any user — can modify or delete the file. For shared environments, that’s a security hole, not a convenience.
Bottom line: You should use 777 only for temporary directories where you trust all users, and never on production servers. The safer alternative is 755 or 644 for most cases.
How to change permission to a file in Linux?
Using chmod with numeric mode
- Numeric mode is the quickest way to set permissions. The command format is
chmod XXX filename, whereXXXis the octal value for owner, group, others (Boston University TechWeb (academic research support)). - Example:
chmod 644 mynotes.txtsets owner read/write, group read, others read.
Using chmod with symbolic mode (u,g,o,a + r,w,x)
- Symbolic mode uses letters:
u(owner),g(group),o(others),a(all) (Red Hat) . - Operators:
+adds permission,-removes,=sets exactly (freeCodeCamp) . - Example:
chmod u+rwx,g+rx,o+rx script.shgives owner full access, group and others read+execute.
Changing permissions for a directory
- Directories need the execute (
x) bit for users to search or traverse them (University of Massachusetts Lowell (educational resource)) . - Default directory permissions are often 755 so the owner can write and everyone can list contents.
Follow these steps to change file permissions on any file or directory:
- Check current permissions with
ls -l filename. - Determine the desired permission mode (numeric or symbolic).
- Run
chmod [mode] filenameto apply permissions. - Verify the change with
ls -l filename.
Bottom line: You should use numeric mode for one-off changes and symbolic mode for scripts or documentation to make your intent clear.
What does chmod 444 do in Linux?
Read-only permission for all
chmod 444sets read permission for owner, group, and others (Linuxize (Linux how-to guides)) .- The file becomes read-only: no write or execute access for anyone.
Use case for configuration files
- System configuration files that should never be modified by accident are often set to 444 (Red Hat) .
- Even the owner cannot modify the file without first changing permissions.
Difference from 644 and 755
- 644 gives owner write access (rw-r–r–), so the owner can edit; 444 is stricter.
- 755 allows owner to write and everyone to read/execute; 444 blocks execution.
444 prevents the owner from editing the file until permissions are changed back. This is useful for writable mounts where you want a safeguard, but it can be frustrating if you forget to reset.
The implication: 444 is best reserved for files that must never be altered without explicit permission change, such as system configuration files.
What is chmod 755 or 777?
chmod 755 explained
- 755 gives owner read, write, execute (rwx), and group and others read and execute (r-x) (Red Hat) .
- It is the standard permission for directories and executable files.
chmod 777 explained
- 777 gives full rwx to everyone (Boston University TechWeb) .
- It allows anyone to modify or execute the file.
When to use 755 vs 777
- Use 755 for web server directories, shared script folders, or any place where users need to run but not modify files.
- Use 777 only temporarily for upload directories or when debugging, then revert to 755 or 750.
Bottom line: You should use 755 as the safe default for directories and executables, and avoid 777 as it is rarely needed and almost always a security risk. If you are tempted to use 777, try 755 first.
What does chmod 600 do to a file?
Private file permission
chmod 600gives the owner read and write only (rw-), and no permissions for group or others (University of Massachusetts Lowell) .- It is the most common private permission for sensitive files.
Use for SSH keys and sensitive data
- Private SSH keys (
~/.ssh/id_rsa) must have 600 or 400 to be considered secure by the SSH client (DigitalOcean) . - Configuration files containing passwords or API tokens should also use 600.
Difference from 644 and 700
- 644 allows everyone to read the file; 600 keeps it private.
- 700 adds execute for the owner, needed for scripts but unnecessary for ordinary data files.
If your SSH private key is readable by anyone else (even read-only), the SSH daemon will refuse to use it. Setting 600 is not just a best practice — it is enforced by the software.
The pattern: 600 is the standard for any file containing secrets, enforced by SSH clients and recommended for all sensitive configurations.
How to change permissions of a folder in Linux?
Using chmod with -R flag
- The
-R(recursive) flag applies changes to the directory and all files inside it (POSIX specification) . - Example:
chmod -R 755 myprojectsets 755 on the directory and every file within.
Setting permissions for all files inside a directory
- To give files 644 and directories 755 in a single pass, use
find . -type f -exec chmod 644 {} \;and thenfind . -type d -exec chmod 755 {} \;(freeCodeCamp) . - This is safer than
-R 755because it avoids making regular files executable.
Difference between file and directory permissions
- For directories, the read bit lets you list contents; write lets you create or delete files; execute lets you enter the directory and access files (University of Massachusetts Lowell) .
- A directory without execute permission cannot be traversed, even if you have read access.
Bottom line: You must always consider the execute bit when changing folder permissions. Without it, no one can cd into the directory. Use the find approach to apply different permissions to files and subdirectories.
Confirmed facts
chmodis the standard command for changing file permissions in Linux (Red Hat).- Numeric mode uses octal digits (0-7) for owner, group, others (Boston University TechWeb).
What’s unclear
- Exact default
umaskvalues vary by distribution (Red Hat). - Whether 777 is ever appropriate depends on specific server environment.
chmodchanges any or all of the file mode bits of the named file operands.IEEE/Open Group POSIX specification (authoritative standards body)
In Linux, every file has an owner and a group, and three sets of permissions that control access for the owner, the group, and everyone else.
Red Hat Documentation (Linux enterprise vendor)
The execute permission on a directory allows users to traverse the directory and access files inside it.
Boston University TechWeb (academic research support)
For anyone managing a Linux server, the choice between 755 and 777 is the difference between a secure deployment and a potential breach. Stick with the minimum permissions needed — your future self will thank you.
man.openbsd.org, people.computing.clemson.edu, kodekloud.com, youtube.com, man7.org, linuxize.com
Frequently asked questions
What is the chmod command in Linux?
chmod (short for “change mode”) is the standard Unix/Linux command to modify file and directory permissions. It can use numeric (octal) mode or symbolic mode (POSIX specification).
How do I check current file permissions in Linux?
Use ls -l filename. The output shows a 10-character string like -rwxr-xr-x that encodes the file type and permissions for owner, group, and others (Red Hat).
What does chmod 755 mean?
755 gives the owner read, write, and execute permissions, and the group and others read and execute. It is the standard permission for directories and executable files (Boston University TechWeb).
What does chmod 644 mean?
644 gives the owner read and write permission, and everyone else read-only. It is the default for most regular files (Linuxize).
Can I change permissions for multiple files at once?
Yes. Use chmod 644 file1 file2 file3 for specific files, or chmod -R 755 directory for recursive changes. The find command also allows selective batches (freeCodeCamp).
What is the difference between chmod and chown?
chmod changes permissions (read, write, execute); chown changes ownership (which user and group own the file). Both require owner or root privileges (Red Hat).
How do I make a file executable in Linux?
Add the execute bit using chmod +x filename (symbolic) or chmod 755 filename (numeric). For a script, also ensure it has a shebang line at the top (DigitalOcean).
Understanding these common permission scenarios helps you secure your Linux system effectively.
Related reading