In Linux and Unix-like operating systems, security is built from the ground up starting with file permissions. Every file, directory, and system process is governed by strict access controls that dictate who can read, modify, or execute files.
If you have ever encountered an “Access Denied” or “Permission Denied” error when running a script, configuring a server, or pushing to a repository, understanding Unix file permissions is key. In this article, we’ll explain how permissions are structured, how octal and symbolic representations map to each other, and how to use the chmod command.
The Three Tiers of Ownership
Every file and directory in a Unix file system has three distinct tiers of user associations:
- Owner (u): The individual user who owns the file (usually the creator).
- Group (g): A designated group of users who share access to the file.
- Others (o): Every other user on the system who is not the owner and is not in the group (often referred to as “world” permissions).
The Three Permission Types (rwx)
Each of the ownership tiers has a set of three basic access permissions:
- Read (r):
- For files: Permits viewing the file’s content (e.g., using
catorless). - For directories: Permits listing the files inside the directory (using
ls).
- For files: Permits viewing the file’s content (e.g., using
- Write (w):
- For files: Permits modifying or deleting the file’s content.
- For directories: Permits creating, deleting, or renaming files within the directory.
- Execute (x):
- For files: Permits running the file as a program or script.
- For directories: Permits entering the directory (using
cd) and accessing files inside.
Representation Formats: Symbolic vs. Octal
Permissions are represented in two standard ways: Symbolic notation (text) and Octal notation (numbers).
1. Symbolic Notation
When you run ls -l in a terminal, you will see a 10-character string representing file status and permissions:
-rwxr-xr--
- The first character represents the file type (
-for regular file,dfor directory,lfor symbolic link). - Characters 2–4 represent Owner permissions:
rwx(Read, Write, and Execute). - Characters 5–7 represent Group permissions:
r-x(Read and Execute, no Write). - Characters 8–10 represent Others permissions:
r--(Read only, no Write, no Execute).
2. Octal Notation
Octal notation uses a three-digit base-8 number to define permissions, where each digit represents one of the ownership tiers (Owner, Group, Others). Each permission type has a static weight:
- Read (r) =
4 - Write (w) =
2 - Execute (x) =
1 - No Permission (-) =
0
To find the octal digit for a tier, add the weights of its active permissions:
rwx=4 + 2 + 1 = 7r-x=4 + 0 + 1 = 5r--=4 + 0 + 0 = 4
Thus, -rwxr-xr-- corresponds to the octal permission 754.
Changing Permissions with chmod
The chmod (Change Mode) utility updates file permissions using either representation.
1. Using Octal Mode
# Give owner full control, group read/execute, and others read only
chmod 754 script.sh
2. Using Symbolic Mode
Symbolic mode uses operators (+, -, =) to add, subtract, or set specific permissions:
# Add execute permission for the owner
chmod u+x script.sh
# Remove write permission for group and others
chmod go-w document.txt
# Set exact permissions: owner read/write, group/others read only
chmod u=rw,go=r config.json
Try the Interactive Permissions Calculator
Configuring server deployments or security configurations manually is error-prone. To eliminate guesswork, use our secure client-side tool:
- Unix Permissions Calculator: Check checkboxes representing permissions for Owner, Group, and Others to instantly generate symbolic strings, octal values, and the exact
chmodcommands.
Because our tool runs entirely in your browser, your security plans and system names remain completely confidential.