Linux File Permissions
Understanding file permissions in Linux.
There are two levels of permissions assigned to the files, directories, and processes in Linux.
The first one is permission groups, which is otherwise referred to as the ownership. The three types of user groups are owners, groups, and others.
The second one is permission types, which can be read, write, or execute.
read:rwrite:wexecute:x
Example
ls -l
Response:
drwxr-xr-x 5 andre-jacquesdebeer staff 160 Aug 15 17:49 k8s
12345678910
Position meanings:
1= item typed=directoryc=characters=socketp=pipeD=Dl=symbolic link
234=> owner567=> groups8910=> others
So rwxr-xr-x means the owner of the file (andre-jacquesdebeer) can read, write, and execute, group may read and execute (not write!) and others may read and execute (again, not write!)
Number form
- 0: No permission
- 1: Execute
- 2: Write
- 4: Read
Combinations:
- rwx = 1+2+4 = 7
- rw- = 2+4 = 6
- r-x = 1+4 = 5
- r-- = 4
- -wx = 2+1 = 3
- -w- = 2
- --x = 1
Example:
sudo chmod 777 filename.txt