All About Permissions

To begin with file permissions in linux are way to controll who can access what? generally this comprises of following file permissions

read(r) → who can view
write(w) → who can modify
execute(c) → who can execute

Now each file has a set of three pople accessing it owner-group-others ex. .rw-r--r-- this means owner has read and write while group and others has read permissions. you can check file permissions using ls -l or getfacl filepath for more details. we can modify the files using octal code and chmod command.

Permission Octal bit
r 4
w 2
x 1

looking at above table the addition or removal of those will determine permisson example 755. This means all have execute and read permissions. only owner has write permission.
7 → 4+2+1 → owner → read-write-execute
5 → 4+0+1 → group → read-execute
5 → 4+0+1 → others → read-execute

information of representation

0 → no permissions
1 → execute
2 → write
3 → write-execute
4 → read
5 → read-execute
6 → read-write
7 → read-write-execute

Take look at below example

644 => .rw-r--r-- => read-write to owner. read group and others
655 => .rw-r-xr-x => read-write to owner. read-execute to group and other
777 => .rwxrwxrwx => every permission to everyone
766 => .rwxrw-rw- => all for owner and read-write for group-others
600 => .rw------- => only owner can read and write
700 => .rw------- => only owner can read-write-execute

$ touch test.txt

$ ls -l text.txt
.rw-r--r-- jayesh jayesh 0 B Fri Jan 31 03:38:36 2025  test.txt

$ chmod 766 text.txt

$ ls -l text.txt
.rwxrw-rw- jayesh jayesh 0 B Fri Jan 31 03:38:36 2025  test.txt

$ getfacl test.txt
#file: test.txt
#owner: jayesh
#group: jayesh
user::rwx
group::rw-
other::rw-