特殊檔案權限
·1-Sbit (sticky bit): 對檔案/目錄均有效.可以了解為防删除位.一個檔案/目錄隻有屬主有權限執行删除、移動等操作,即使檔案/目錄所屬組或者其他使用者擁有寫的權限也隻能修改而不能删除/移動檔案。
·2-SGID (setgid): 隻對目錄有效. 目錄被設定該位後, 任何使用者在此目錄下建立的檔案都具有和該目錄所屬的組相同的組.
·4-SUID (setuid): 隻對檔案有效.設定使檔案在執行階段具有檔案所有者的權限. 典型的檔案是/usr/bin/passwd. 如果一般使用者執行該檔案, 則在執行過程中, 該檔案可以獲得root權限, 進而可以更改使用者的密碼.
注: 如果本來在該位上有x, 則這些特殊标志顯示為小寫字母 (s, s, t). 否則, 顯示為大寫字母 (S, S, T)
[root@rhel6 data]# touch test test1 test4
[root@rhel6 data]# mkdir test2
[root@rhel6 data]# chmod 1644 test1 "1=o+t,即設定sbit"
[root@rhel6 data]# chmod 2755 test2 "2=g+s,即設定sgid"
[root@rhel6 data]# chmod 4755 test4 "4=u+s,即設定suid"
[root@rhel6 data]# ll
-rw-r--r-- 1 root root 0 10-25 09:55 test
-rwxrwxrwt 1 root root 0 10-25 09:55 test1
drwxr-sr-x 2 root root 4096 10-25 09:55 test2
-rwsr-xr-x 1 root root 0 10-25 09:55 test4
[root@rhel6 data]# su - xfcy ;cd /data/
[xfcy@rhel6 data]$ rm test1
rm: 無法删除 “test1”: 權限不夠 //設定了sticky位,即使使用者對檔案具有寫權限,也不能删除該檔案
[xfcy@rhel6 data]$ touch test2/test2
[xfcy@rhel6 data]$ ll test2/test2
-rw-rw-r-- 1 xfcy root 0 10-25 10:31 test2/test2 //設定了SGID,任何使用者在此目錄下建立的檔案都具有和該目錄所屬的組相同的組
[xfcy@rhel6 data]$ ll /usr/bin/passwd
-rwsr-xr-x 1 root root 27768 2006-07-17 /usr/bin/passwd
[xfcy@rhel6 data]$ passwd &
[xfcy@rhel6 data]$ ps -ef | grep passwd
root 11340 11308 0 10:35 pts/0 00:00:00 /usr/bin/passwd //設定了SUID,使檔案在執行階段具有檔案所有者的權限
本文轉自Vnimos51CTO部落格,原文連結:http://blog.51cto.com/vnimos/1042805,如需轉載請自行聯系原作者