Let me explain how to work chmod +t.
You know about permissions a lot of! Chmod 777 and you cannot delete files in directory? Why? Please check for output ls -l? Do you see -t permission?
t permission is sticky bit. When we set sticky bit, only owner has use permission write on file. Noboady can write files in this dicectory only owner.
write to file = vi (edit), touch, rm, rm -rf
write to file (with sticky bit) = vi (edit), touch, rm, rm -rf only owner even though chmod 777 to directory
1) How to check? (you see t)
[root@station ~]# ll /mnt/
total 0
drwxr-xr-t 2 root root 6 Feb 5 11:29 test
2) How to set?
[root@station ~]# chmod +t /mnt/test/
[root@station ~]# chmod 1777 /mnt/test/
3) How to works?
a) audrey create file
[audrey@kosice ~]$ touch /mnt/test/1.txt
[audrey@kosice ~]$ ll /mnt/test/1.txt
-rw-rw-r-- 1 audrey audrey 0 Feb 5 11:31 /mnt/test/1.txt
b) michael create file
[michael@kosice ~]$ touch /mnt/test/2.txt
[michael@kosice ~]$ ll /mnt/test/
total 0
-rw-rw-r-- 1 audrey audrey 0 Feb 5 11:31 1.txt
-rw-rw-r-- 1 michael michael 0 Feb 5 11:31 2.txt
c) michael wanted remove the file
[michael@kosice ~]$ rm -rf /mnt/test/1.txt
rm: cannot remove '/mnt/test/1.txt': Operation not permitted
d) michael wanted to edit the file
[michael@kosice ~]$ echo I am hacker >> /mnt/test/1.txt
-bash: /mnt/test/1.txt: Permission denied
Žiadne komentáre:
Zverejnenie komentára