Tuesday, June 30, 2015

Clone – Permissions in Linux

Security is one of the important features of linux. Linux allows us to clone permissions from one file to other. Lets see how we can clone permissions from one file to other

[root@localhost work]# touch hai1
[root@localhost work]# chmod -R 600 hai1 

[root@localhost work]# stat hai1
  File: ‘hai1’
  Size: 0             Blocks: 0          IO Block: 4096   regular empty file
Device: 807h/2055d    Inode: 432         Links: 1
Access: (0600/-rw-------)  Uid: (    0/    root)   Gid: (    0/    root)
Context: unconfined_u:object_r:etc_runtime_t:s0
Access: 2015-06-29 16:37:24.768551308 +0530
Modify: 2015-06-29 16:37:24.768551308 +0530
Change: 2015-06-29 16:37:28.648463096 +0530

[root@localhost work]# touch hai2
[root@localhost work]# chmod -R 755 hai2

[root@localhost work]# stat hai2
  File: ‘hai2’
  Size: 0             Blocks: 0          IO Block: 4096   regular empty file
Device: 807h/2055d    Inode: 433         Links: 1
Access: (0755/-rwxr-xr-x)  Uid: (    0/    root)   Gid: (    0/    root)
Context: unconfined_u:object_r:etc_runtime_t:s0
Access: 2015-06-29 16:37:37.904252603 +0530
Modify: 2015-06-29 16:37:37.904252603 +0530
Change: 2015-06-29 16:37:43.383127957 +0530
 Birth: -

[root@localhost work]# chmod --reference=hai1 hai2

[root@localhost work]# stat hai2
  File: ‘hai2’
  Size: 0             Blocks: 0          IO Block: 4096   regular empty file
Device: 807h/2055d    Inode: 433         Links: 1
Access: (0600/-rw-------)  Uid: (    0/    root)   Gid: (    0/    root)
Context: unconfined_u:object_r:etc_runtime_t:s0
Access: 2015-06-29 16:37:37.904252603 +0530
Modify: 2015-06-29 16:37:37.904252603 +0530
Change: 2015-06-29 16:38:46.278689779 +0530

No comments :

Post a Comment