What is Permission in Linux?
In Linux, permissions are access rules that determine who can read, write, or execute a file or
directory. Every file and directory has three types of permissions:
1. Types of Permissions
Read (r) – View the contents of a file or list a directory.
Write (w) – Modify a file or create/delete files in a directory.
Execute (x) – Run a file (if it is a program/script) or access a directory.
2. Categories of Users
Owner (u) – The creator of the file.
Group (g) – Users who are part of the file’s group.
Others (o) – Everyone else.
Permission Format
Permissions are displayed using the ls -l command, like:
-rwxr-xr-- 1 user group file.txt
First character: type (- for file, d for directory).
Next 3: owner permissions (rwx)
Next 3: group permissions (r-x)
Last 3: others' permissions (r--)
How to Change Permissions in Linux
Permissions can be changed using the chmod (change mode) command.
1. Symbolic Method
chmod [who][operator][permission] filename
who: u (user), g (group), o (others), a (all)
operator: + (add), - (remove), = (set exact)
permission: r, w, x
Examples:
Add execute permission for the user:
chmod u+x file.sh
Remove write permission for others:
chmod o-w file.txt
Give read and write to group:
chmod g=rw file.txt
2. Numeric (Octal) Method
Each permission is represented by a number:
Permission Binary Octal
--- 000 0
--x 001 1
-w- 010 2
-wx 011 3
r-- 100 4
r-x 101 5
rw- 110 6
rwx 111 7
Syntax:
chmod [octal code] filename
Example:
chmod 755 script.sh
User: 7 (rwx)
Group: 5 (r-x)
Others: 5 (r-x)