Linux File Permissions Explained | Complete Guide with Octal Cheatsheet and Commands
Learn everything about Linux file permissions, including symbolic and octal notations, user-group-other levels, SUID, SGID, Sticky Bit, and chmod usage. This guide includes a visual cheatsheet, best practices, and real command-line examples.

Table of Contents
- What Are Linux File Permissions?
- File Permission Structure
- Octal (Numeric) Representation of Permissions
- Special File Permissions: SUID, SGID, Sticky Bit
- Changing Permissions Using chmod
- Viewing Permissions with ls -l
- Best Practices for Managing Permissions
- Common Permission Use Cases
- Conclusion
- Frequently Asked Questions (FAQs)
Understanding Linux file permissions is essential for system administrators, ethical hackers, developers, and cybersecurity professionals. Proper file permissions protect sensitive data, prevent unauthorized access, and define who can read, write, or execute files or directories. In this blog, we’ll break down everything from permission notations to special bits like SUID, SGID, and the Sticky Bit, using real-world examples and terminal commands.
What Are Linux File Permissions?
Linux file permissions determine the level of access users have to a particular file or directory. These permissions are assigned to three categories of users:
-
Owner: The user who owns the file
-
Group: Users who belong to the file's group
-
Others: Everyone else
Each of these categories can be assigned three types of permissions:
Permission | Symbol | Meaning |
---|---|---|
Read | r | View file contents or list directory contents |
Write | w | Modify file contents or create/delete files in a directory |
Execute | x | Run a file as a program or enter a directory |
File Permission Structure
A typical Linux permission string looks like:
-rwxr-xr--
Here’s how to read it:
-
First character:
-
indicates a regular file;d
is for directories. -
Next 3:
rwx
— Owner permissions (read, write, execute) -
Next 3:
r-x
— Group permissions (read, execute) -
Last 3:
r--
— Other permissions (read only)
Octal (Numeric) Representation of Permissions
Permissions can also be represented in binary or octal:
Binary | Octal | Symbol | Meaning |
---|---|---|---|
000 | 0 | --- | No permissions |
001 | 1 | --x | Execute only |
010 | 2 | -w- | Write only |
011 | 3 | -wx | Write + Execute |
100 | 4 | r-- | Read only |
101 | 5 | r-x | Read + Execute |
110 | 6 | rw- | Read + Write |
111 | 7 | rwx | Read + Write + Execute |
So a permission string like rwxr-xr--
is 754
in octal.
Special File Permissions: SUID, SGID, Sticky Bit
Linux offers three special bits that can alter how files are accessed and executed:
SUID (Set User ID)
Allows users to run an executable with the permissions of the file owner.
-
Symbol:
s
in the owner execute field -
Example:
-rwsr-xr-x
-
Command:
chmod u+s filename
SGID (Set Group ID)
Files: Similar to SUID, but applies to group permissions.
Directories: Newly created files inherit the group of the directory.
-
Symbol:
s
in the group execute field -
Example:
-rwxr-sr-x
-
Command:
chmod g+s directory
Sticky Bit
Applied to directories to restrict file deletion within them to file owners.
-
Symbol:
t
in the other execute field -
Example:
drwxrwxrwt
-
Command:
chmod +t directory
Changing Permissions Using chmod
Linux provides the chmod
command to change permissions in both symbolic and octal format.
✅ Symbolic Example:
chmod u+x script.sh # Add execute to user
chmod g-w script.sh # Remove write from group
chmod o=r file.txt # Set read-only for others
✅ Octal Example:
chmod 755 filename # rwxr-xr-x
chmod 700 filename # rwx------
chmod 644 file.txt # rw-r--r--
Viewing Permissions with ls -l
ls -l
Sample Output:
-rwxr-xr-- 1 user group 2048 Jun 19 12:30 example.sh
Breakdown:
-
-rwxr-xr--
: Permissions -
1
: Number of hard links -
user
: File owner -
group
: File’s group -
2048
: File size in bytes -
Jun 19 12:30
: Last modified -
example.sh
: Filename
Best Practices for Managing Permissions
-
Always follow the principle of least privilege.
-
Avoid using
777
unless absolutely necessary. -
Use SUID/SGID/Sticky Bit carefully to avoid privilege escalation.
-
Use groups to manage multiple users with similar permissions.
✅ Common Permission Use Cases
Use Case | Command |
---|---|
Make script executable | chmod +x script.sh |
Make file read-only | chmod 444 filename.txt |
Allow full access | chmod 777 testfile |
Secure config file | chmod 600 config.ini |
Set SUID | chmod u+s /path/to/file |
Set SGID | chmod g+s /path/to/dir |
Set Sticky Bit | chmod +t /tmp/shared_dir |
Conclusion
Linux file permissions are one of the foundational elements of system security. With a deep understanding of permission notations, octal values, and special bits like SUID, SGID, and the Sticky Bit, you'll be equipped to secure any Linux environment effectively. Use the cheatsheet provided to reinforce your knowledge and apply best practices for file access control.
FAQs
What are the 3 basic types of Linux file permissions?
Read (r), Write (w), and Execute (x).
What does chmod 755
mean in Linux?
It sets permissions to rwxr-xr-x
, allowing full access for the owner, read-execute for group and others.
What is the difference between symbolic and octal permissions?
Symbolic uses letters like rwx
, while octal uses numbers like 755
.
How do I change file permissions in Linux?
Use the chmod
command.
What is SUID in Linux?
Set User ID allows users to execute a file with the file owner's privileges.
How do you set SUID on a file?
Use: chmod u+s filename
What is the SGID bit used for?
SGID allows files in a directory to inherit the directory’s group.
How do you set the Sticky Bit on a folder?
Use: chmod +t folder_name
What does chmod 777
do?
Gives all permissions (read, write, execute) to everyone—it's risky.
How do I view file permissions in Linux?
Use: ls -l
What is rwxr-xr--
in file permissions?
It means owner can read/write/execute, group can read/execute, others can only read.
Can I set different permissions for a directory?
Yes, directories often need execute (x) permission to allow traversal.
What is the owner in Linux file permissions?
The user who created or owns the file.
How do I give read-only access to others?
Use: chmod o=r filename
What does chmod 600
do?
Grants read/write to owner, denies all access to group and others.
Why is chmod 777
considered insecure?
It allows anyone to modify or execute the file—potential security risk.
How do I recursively change permissions in a directory?
Use: chmod -R 755 /directory
What does chmod +x
do?
Adds execute permission to the specified user or group.
What does chmod a+r
mean?
Adds read permission for all (user, group, others).
How do I remove write permission for others?
Use: chmod o-w filename
What is the purpose of the Sticky Bit?
Restricts file deletion in shared directories to only the file's owner.
What is drwxrwxrwt
?
Directory with read, write, execute for all and a Sticky Bit set.
How do I assign execute permission to a script?
Use: chmod +x script.sh
What is the default permission on Linux files?
Typically 644
for files and 755
for directories.
What does chmod 444
mean?
Read-only for all.
Can I change ownership and permissions together?
Yes, using chown
for ownership and chmod
for permissions.
How do I make a file executable for everyone?
Use: chmod a+x filename
What is the difference between chmod 775
and 755
?
775
gives write permission to the group, 755
does not.
How do you give full control to a user?
Use: chmod 700 filename
How do I set permission using symbolic notation?
Example: chmod u+x,g-w filename
Can permissions affect program execution?
Yes. Lack of execute permission will prevent a script or binary from running.