Understanding File Permissions

UNIX Systems Come With A File Control Mechanism. It Has 2 Parts:
Classes
Permissions

There Are 3 Classes…
Owner
:- They Are The Creator Of The File And Usually Have All Permissions
Group
:- A Group Of Users That Share The Same Privileges
Others
:- The General Public

There Are 3 Type Of Actions That We Can Perform On A Folder/File…
Read
:- You Can Only View The File, But Cannot Modify The Content Of The File
Write
:- You Can Edit And Modify The File
Execute
:- Execute Is Mainly Used When You Need To Run The File

When You Combine These Classes & Permissions You Can Control Who Have Access Over Your File

Every File And Folder Contain A 8-Bit Data That Control It’s Permission. In It’s Binary Form, It Will Be 000 Meaning It Will Have No Permissions At All. When You Set A “Read” Permission, It Will Add 4-Bit To The Data, Making It “100” (In Binary Format) Or A “4” In The Usual Decimal Format. Setting A “Write” Permission Will Add 2-Bit To The Data, Making It “010” And “2” In Decimal Form. Lastly, Setting An “Execute” Permission Adds 1-Bit To The Data, Which Will Result In “001”, Or ”1" In Decimal Form. In Short:

Read Is Equivalent To ‘4’.
Write Is Equivalent To ‘2’.
Execute Is Equivalent To ‘1’

0 – No Permission
1 – Execute
2 – Write
3 – Write & Execute
4 – Read
5 – Read & Execute
6 – Read & Write
7 – Read, Write & Execute

You May Ask, What About The Digit 777?
Well, The First Digit Is Assigned To The Owner, The Second Digit Is Assigned To The Group And The Third Digit Is Assigned To The Others. So For A File With ‘777’ Permission, Everyone Can Read, Write And Execute The File.

In Linux Terminal You Can Easily Change The File/Folder Permissions By Using This Command “chmod”

In Short, “chmod 777” Means Making The File Readable, Writable And Executable By Everyone.

That’s All Guys

Stay Safe & Take Care

Share This Around If You Have Found It Useful

5 Likes

doesn’t this place look sexy??
I remember I made mnemonics to remember that fucking naming of permissions but I forgot again so I just do chmod 777 filename for my life but that’s bad

noice articles tho, will be waiting for more