How to set attribute permission for Unix file

16 viewsLinux
0

what is attributes permission ? How to  set the permission ? Is any one can delete the files once permission is set  ?

 

 

Attribute permission in linux used to secure files from accidential deletion or modification. Even root account don’t have permission to delete the files.

root@VM1-TEST ~]# touch /tmp/test
[root@VM1-TEST ~]# ls -l /tmp/test
-rw-r–r–. 1 root root 0 Dec 26 20:27 /tmp/test

Adding attribute permissions
============================
[root@VM1-TEST ~]# chattr +i /tmp/test

[root@VM1-TEST ~]# ls -l /tmp/test
-rw-r–r–. 1 root root 0 Dec 26 20:27 /tmp/test

[root@VM1-TEST ~]# lsattr /tmp/test
—-i———– /tmp/test

[root@VM1-TEST ~]# rm -rf /tmp/test
rm: cannot remove ‘/tmp/test’: Operation not permitted

Removing attribute permission for file
========================================

[root@VM1-TEST ~]# chattr -i /tmp/test

[root@VM1-TEST ~]# lsattr /tmp/test
—————- /tmp/test

Edited question