CHMOD in Linux and Unix: Understanding File Permissions and Usage
In Linux and Unix operating systems, file permissions play a vital role in system security and stability. One of the most important commands for managing these permissions is CHMOD.
Whether you are a system administrator, developer, or Linux beginner, understanding how CHMOD works will help you control access to files and directories safely and effectively.
What Is CHMOD?
CHMOD stands for change mode. It is a command used in Linux and Unix systems to modify file and directory permissions.
Each file or directory has permissions that define:
- Who can access it
- What actions they can perform
The chmod command allows you to change these permissions using either numeric (octal) or symbolic notation.
Understanding Linux and Unix File Permissions
Linux and Unix use a permission model based on three user classes:
- Owner (u) – The file creator
- Group (g) – Users in the same group
- Others (o) – Everyone else
Each class can have three types of permissions:
| Permission | Symbol | Value |
|---|---|---|
| Read | r | 4 |
| Write | w | 2 |
| Execute | x | 1 |
These values are combined to form numeric permissions.
Numeric (Octal) CHMOD Explained
Numeric CHMOD uses a three-digit number where each digit represents permissions for:
chmod 755 filename
| Digit | Meaning |
|---|---|
| 7 | Owner (rwx) |
| 5 | Group (r-x) |
| 5 | Others (r-x) |
Common Numeric CHMOD Values
| Permission | Description |
|---|---|
| 777 | Full access for everyone (unsafe) |
| 755 | Common for directories |
| 644 | Standard for files |
| 600 | Private file access |
Symbolic CHMOD Mode
Symbolic mode is more human-readable and flexible. It uses letters and operators.
Examples
chmod u+x script.sh
chmod g-w file.txt
chmod o=r public.txt
| Symbol | Meaning |
|---|---|
| u | User (owner) |
| g | Group |
| o | Others |
| a | All users |
| + | Add permission |
| – | Remove permission |
| = | Set exact permission |
Symbolic mode is especially useful when you only want to change specific permissions.
CHMOD for Files vs Directories
Permissions behave differently depending on whether they are applied to files or directories.
Files
- Read (r) – View file content
- Write (w) – Modify content
- Execute (x) – Run as a program
Directories
- Read (r) – List directory contents
- Write (w) – Create or delete files
- Execute (x) – Access files inside the directory
Understanding this difference prevents accidental access issues.
Recursive CHMOD Usage
You can apply CHMOD permissions recursively using the -R option.
chmod -R 755 /var/www/html
This command applies the permission to all subdirectories and files.
⚠️ Use recursive CHMOD carefully, especially on system directories.
Best Practices for Using CHMOD
To maintain system security:
- Avoid using
chmod 777 - Apply the principle of least privilege
- Use
755for directories - Use
644for regular files - Limit execute permission to scripts and binaries only
Correct permissions reduce the risk of unauthorized access and system compromise.
Common CHMOD Mistakes
Some frequent errors include:
- Giving write permission to everyone
- Applying execute permission to non-executable files
- Using recursive CHMOD without verification
- Changing permissions on system-critical files
Always double-check permissions before applying changes.
When Should You Use CHMOD?
You typically use CHMOD when:
- Deploying web applications
- Fixing “Permission denied” errors
- Managing shared servers
- Securing configuration files
- Setting script execution rights
CHMOD is a daily tool in Linux and Unix administration.
Conclusion
CHMOD is a fundamental command in Linux and Unix operating systems. By understanding numeric and symbolic modes, file and directory behavior, and best practices, you can manage permissions safely and efficiently.
Mastering CHMOD improves system security, stability, and professional Linux administration skills. For better understanding about chmod command line, you can also try the CHMOD calculotor tools.




