Friday, January 1, 2021

File Permissions:

 

Permissions are applied on three levels:-
 Owner or User level
 Group level
 Others level
Access modes are of three types:-
 r  - read only
 w - write/edit/delete/append
 x  - execute/run a command

[root@dev ~]# chmod u=rwx,g=rw,o=r filename
[root@dev ~]# ls -l filename
-rwxrw-r--. 1 root root 13 Nov 18 15:35 filename

2 Absolute Method (numbers) In Absolute method we use numbers instead of using symbols i.e.
Read=4
Write=2
Execute=1

[root@dev ~]# chmod 764 filename
[root@dev ~]# ls -l filename
-rwxrw-r--. 1 root root 13 Nov 18 15:35 filename

Removing all permissions from others
[root@dev ~]# chmod 760 filename (where 0 indicates no permissions)

Umask:
When we create any file using touch, cat or vi commands they get created with default file permissions as stored in umask (User file creation mask).

[root@dev ~]# umask
0022

Calculation of default permissions for file and directory, basing upon the umask value
Note: For a file by default it cannot have the execute permission, so the maximum full permission for a file at the time of creation can be 666 (i.e. 777 -111 = 666), whereas a directory can have full permissions i.e. 777

The full permission for the file                         666
Minus the umask value                                   -022
The default permission for file is                     644  (rw-,r--,r--)


The full permission for the directory                777

Minus the umask value                                    - 022 

The default permission for file is                    755 (rwx, r-x, r-x)


No comments:

Post a Comment